@wiajs/core 1.0.11 → 1.1.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/LICENSE +44 -21
- package/README.md +6 -0
- package/dist/{core.cmn.js → core.cjs} +599 -29
- package/dist/core.js +982 -17
- package/dist/core.min.js +5 -5
- package/dist/{core.esm.js → core.mjs} +599 -29
- package/package.json +3 -3
package/dist/core.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* wia core v1.
|
|
3
|
-
* (c) 2015-
|
|
2
|
+
* wia core v1.1.2
|
|
3
|
+
* (c) 2015-2024 Sibyl Yu and contributors
|
|
4
4
|
* Released under the MIT License.
|
|
5
5
|
*/
|
|
6
6
|
(function (global, factory) {
|
|
@@ -181,6 +181,9 @@
|
|
|
181
181
|
function clampInt(min, max, input) {
|
|
182
182
|
return input < min ? min : input > max ? max : input;
|
|
183
183
|
}
|
|
184
|
+
function clampDouble(min, max, input) {
|
|
185
|
+
return input < min ? min : input > max ? max : input;
|
|
186
|
+
}
|
|
184
187
|
function sanitizeDegreesDouble(degrees) {
|
|
185
188
|
return (degrees %= 360) < 0 && (degrees += 360), degrees;
|
|
186
189
|
}
|
|
@@ -231,6 +234,9 @@
|
|
|
231
234
|
function yFromLstar(lstar) {
|
|
232
235
|
return 100 * labInvf((lstar + 16) / 116);
|
|
233
236
|
}
|
|
237
|
+
function lstarFromY(y) {
|
|
238
|
+
return 116 * labF(y / 100) - 16;
|
|
239
|
+
}
|
|
234
240
|
function linearized(rgbComponent) {
|
|
235
241
|
var normalized = rgbComponent / 255;
|
|
236
242
|
return normalized <= .040449936 ? normalized / 12.92 * 100 : 100 * Math.pow((normalized + .055) / 1.055, 2.4);
|
|
@@ -411,6 +417,68 @@
|
|
|
411
417
|
bF = bC / viewingConditions.rgbD[2];
|
|
412
418
|
return argbFromXyz(1.86206786 * rF - 1.01125463 * gF + .14918677 * bF, .38752654 * rF + .62144744 * gF - .00897398 * bF, -.0158415 * rF - .03412294 * gF + 1.04996444 * bF);
|
|
413
419
|
};
|
|
420
|
+
Cam16.fromXyzInViewingConditions = function fromXyzInViewingConditions(x, y, z, viewingConditions) {
|
|
421
|
+
var rC = .401288 * x + .650173 * y - .051461 * z,
|
|
422
|
+
gC = -.250268 * x + 1.204414 * y + .045854 * z,
|
|
423
|
+
bC = -.002079 * x + .048952 * y + .953127 * z,
|
|
424
|
+
rD = viewingConditions.rgbD[0] * rC,
|
|
425
|
+
gD = viewingConditions.rgbD[1] * gC,
|
|
426
|
+
bD = viewingConditions.rgbD[2] * bC,
|
|
427
|
+
rAF = Math.pow(viewingConditions.fl * Math.abs(rD) / 100, .42),
|
|
428
|
+
gAF = Math.pow(viewingConditions.fl * Math.abs(gD) / 100, .42),
|
|
429
|
+
bAF = Math.pow(viewingConditions.fl * Math.abs(bD) / 100, .42),
|
|
430
|
+
rA = 400 * signum(rD) * rAF / (rAF + 27.13),
|
|
431
|
+
gA = 400 * signum(gD) * gAF / (gAF + 27.13),
|
|
432
|
+
bA = 400 * signum(bD) * bAF / (bAF + 27.13),
|
|
433
|
+
a = (11 * rA + -12 * gA + bA) / 11,
|
|
434
|
+
b = (rA + gA - 2 * bA) / 9,
|
|
435
|
+
u = (20 * rA + 20 * gA + 21 * bA) / 20,
|
|
436
|
+
p2 = (40 * rA + 20 * gA + bA) / 20,
|
|
437
|
+
atanDegrees = 180 * Math.atan2(b, a) / Math.PI,
|
|
438
|
+
hue = atanDegrees < 0 ? atanDegrees + 360 : atanDegrees >= 360 ? atanDegrees - 360 : atanDegrees,
|
|
439
|
+
hueRadians = hue * Math.PI / 180,
|
|
440
|
+
ac = p2 * viewingConditions.nbb,
|
|
441
|
+
J = 100 * Math.pow(ac / viewingConditions.aw, viewingConditions.c * viewingConditions.z),
|
|
442
|
+
Q = 4 / viewingConditions.c * Math.sqrt(J / 100) * (viewingConditions.aw + 4) * viewingConditions.fLRoot,
|
|
443
|
+
huePrime = hue < 20.14 ? hue + 360 : hue,
|
|
444
|
+
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),
|
|
445
|
+
alpha = Math.pow(t, .9) * Math.pow(1.64 - Math.pow(.29, viewingConditions.n), .73),
|
|
446
|
+
C = alpha * Math.sqrt(J / 100),
|
|
447
|
+
M = C * viewingConditions.fLRoot,
|
|
448
|
+
s = 50 * Math.sqrt(alpha * viewingConditions.c / (viewingConditions.aw + 4)),
|
|
449
|
+
jstar = (1 + 100 * .007) * J / (1 + .007 * J),
|
|
450
|
+
mstar = Math.log(1 + .0228 * M) / .0228,
|
|
451
|
+
astar = mstar * Math.cos(hueRadians),
|
|
452
|
+
bstar = mstar * Math.sin(hueRadians);
|
|
453
|
+
return new Cam16(hue, C, J, Q, M, s, jstar, astar, bstar);
|
|
454
|
+
};
|
|
455
|
+
_proto.xyzInViewingConditions = function xyzInViewingConditions(viewingConditions) {
|
|
456
|
+
var alpha = 0 === this.chroma || 0 === this.j ? 0 : this.chroma / Math.sqrt(this.j / 100),
|
|
457
|
+
t = Math.pow(alpha / Math.pow(1.64 - Math.pow(.29, viewingConditions.n), .73), 1 / .9),
|
|
458
|
+
hRad = this.hue * Math.PI / 180,
|
|
459
|
+
eHue = .25 * (Math.cos(hRad + 2) + 3.8),
|
|
460
|
+
ac = viewingConditions.aw * Math.pow(this.j / 100, 1 / viewingConditions.c / viewingConditions.z),
|
|
461
|
+
p1 = eHue * (5e4 / 13) * viewingConditions.nc * viewingConditions.ncb,
|
|
462
|
+
p2 = ac / viewingConditions.nbb,
|
|
463
|
+
hSin = Math.sin(hRad),
|
|
464
|
+
hCos = Math.cos(hRad),
|
|
465
|
+
gamma = 23 * (p2 + .305) * t / (23 * p1 + 11 * t * hCos + 108 * t * hSin),
|
|
466
|
+
a = gamma * hCos,
|
|
467
|
+
b = gamma * hSin,
|
|
468
|
+
rA = (460 * p2 + 451 * a + 288 * b) / 1403,
|
|
469
|
+
gA = (460 * p2 - 891 * a - 261 * b) / 1403,
|
|
470
|
+
bA = (460 * p2 - 220 * a - 6300 * b) / 1403,
|
|
471
|
+
rCBase = Math.max(0, 27.13 * Math.abs(rA) / (400 - Math.abs(rA))),
|
|
472
|
+
rC = signum(rA) * (100 / viewingConditions.fl) * Math.pow(rCBase, 1 / .42),
|
|
473
|
+
gCBase = Math.max(0, 27.13 * Math.abs(gA) / (400 - Math.abs(gA))),
|
|
474
|
+
gC = signum(gA) * (100 / viewingConditions.fl) * Math.pow(gCBase, 1 / .42),
|
|
475
|
+
bCBase = Math.max(0, 27.13 * Math.abs(bA) / (400 - Math.abs(bA))),
|
|
476
|
+
bC = signum(bA) * (100 / viewingConditions.fl) * Math.pow(bCBase, 1 / .42),
|
|
477
|
+
rF = rC / viewingConditions.rgbD[0],
|
|
478
|
+
gF = gC / viewingConditions.rgbD[1],
|
|
479
|
+
bF = bC / viewingConditions.rgbD[2];
|
|
480
|
+
return [1.86206786 * rF - 1.01125463 * gF + .14918677 * bF, .38752654 * rF + .62144744 * gF - .00897398 * bF, -.0158415 * rF - .03412294 * gF + 1.04996444 * bF];
|
|
481
|
+
};
|
|
414
482
|
return Cam16;
|
|
415
483
|
}();
|
|
416
484
|
var HctSolver = function () {
|
|
@@ -589,6 +657,11 @@
|
|
|
589
657
|
var cam = Cam16.fromInt(argb);
|
|
590
658
|
this.internalHue = cam.hue, this.internalChroma = cam.chroma, this.internalTone = lstarFromArgb(argb), this.argb = argb;
|
|
591
659
|
};
|
|
660
|
+
_proto2.inViewingConditions = function inViewingConditions(vc) {
|
|
661
|
+
var viewedInVc = Cam16.fromInt(this.toInt()).xyzInViewingConditions(vc),
|
|
662
|
+
recastInVc = Cam16.fromXyzInViewingConditions(viewedInVc[0], viewedInVc[1], viewedInVc[2], ViewingConditions.make());
|
|
663
|
+
return Hct.from(recastInVc.hue, recastInVc.chroma, lstarFromY(viewedInVc[1]));
|
|
664
|
+
};
|
|
592
665
|
_createClass(Hct, [{
|
|
593
666
|
key: "hue",
|
|
594
667
|
get: function get() {
|
|
@@ -645,22 +718,903 @@
|
|
|
645
718
|
};
|
|
646
719
|
return Blend;
|
|
647
720
|
}();
|
|
721
|
+
var Contrast = function () {
|
|
722
|
+
function Contrast() {}
|
|
723
|
+
Contrast.ratioOfTones = function ratioOfTones(toneA, toneB) {
|
|
724
|
+
return toneA = clampDouble(0, 100, toneA), toneB = clampDouble(0, 100, toneB), Contrast.ratioOfYs(yFromLstar(toneA), yFromLstar(toneB));
|
|
725
|
+
};
|
|
726
|
+
Contrast.ratioOfYs = function ratioOfYs(y1, y2) {
|
|
727
|
+
var lighter = y1 > y2 ? y1 : y2;
|
|
728
|
+
return (lighter + 5) / ((lighter === y2 ? y1 : y2) + 5);
|
|
729
|
+
};
|
|
730
|
+
Contrast.lighter = function lighter(tone, ratio) {
|
|
731
|
+
if (tone < 0 || tone > 100) return -1;
|
|
732
|
+
var darkY = yFromLstar(tone),
|
|
733
|
+
lightY = ratio * (darkY + 5) - 5,
|
|
734
|
+
realContrast = Contrast.ratioOfYs(lightY, darkY),
|
|
735
|
+
delta = Math.abs(realContrast - ratio);
|
|
736
|
+
if (realContrast < ratio && delta > .04) return -1;
|
|
737
|
+
var returnValue = lstarFromY(lightY) + .4;
|
|
738
|
+
return returnValue < 0 || returnValue > 100 ? -1 : returnValue;
|
|
739
|
+
};
|
|
740
|
+
Contrast.darker = function darker(tone, ratio) {
|
|
741
|
+
if (tone < 0 || tone > 100) return -1;
|
|
742
|
+
var lightY = yFromLstar(tone),
|
|
743
|
+
darkY = (lightY + 5) / ratio - 5,
|
|
744
|
+
realContrast = Contrast.ratioOfYs(lightY, darkY),
|
|
745
|
+
delta = Math.abs(realContrast - ratio);
|
|
746
|
+
if (realContrast < ratio && delta > .04) return -1;
|
|
747
|
+
var returnValue = lstarFromY(darkY) - .4;
|
|
748
|
+
return returnValue < 0 || returnValue > 100 ? -1 : returnValue;
|
|
749
|
+
};
|
|
750
|
+
Contrast.lighterUnsafe = function lighterUnsafe(tone, ratio) {
|
|
751
|
+
var lighterSafe = Contrast.lighter(tone, ratio);
|
|
752
|
+
return lighterSafe < 0 ? 100 : lighterSafe;
|
|
753
|
+
};
|
|
754
|
+
Contrast.darkerUnsafe = function darkerUnsafe(tone, ratio) {
|
|
755
|
+
var darkerSafe = Contrast.darker(tone, ratio);
|
|
756
|
+
return darkerSafe < 0 ? 0 : darkerSafe;
|
|
757
|
+
};
|
|
758
|
+
return Contrast;
|
|
759
|
+
}();
|
|
760
|
+
var DislikeAnalyzer = function () {
|
|
761
|
+
function DislikeAnalyzer() {}
|
|
762
|
+
DislikeAnalyzer.isDisliked = function isDisliked(hct) {
|
|
763
|
+
var huePasses = Math.round(hct.hue) >= 90 && Math.round(hct.hue) <= 111,
|
|
764
|
+
chromaPasses = Math.round(hct.chroma) > 16,
|
|
765
|
+
tonePasses = Math.round(hct.tone) < 65;
|
|
766
|
+
return huePasses && chromaPasses && tonePasses;
|
|
767
|
+
};
|
|
768
|
+
DislikeAnalyzer.fixIfDisliked = function fixIfDisliked(hct) {
|
|
769
|
+
return DislikeAnalyzer.isDisliked(hct) ? Hct.from(hct.hue, hct.chroma, 70) : hct;
|
|
770
|
+
};
|
|
771
|
+
return DislikeAnalyzer;
|
|
772
|
+
}();
|
|
773
|
+
var DynamicColor = function () {
|
|
774
|
+
DynamicColor.fromPalette = function fromPalette(args) {
|
|
775
|
+
var _args$name, _args$isBackground;
|
|
776
|
+
return new DynamicColor((_args$name = args.name) != null ? _args$name : "", args.palette, args.tone, (_args$isBackground = args.isBackground) != null ? _args$isBackground : !1, args.background, args.secondBackground, args.contrastCurve, args.toneDeltaPair);
|
|
777
|
+
};
|
|
778
|
+
function DynamicColor(name, palette, tone, isBackground, background, secondBackground, contrastCurve, toneDeltaPair) {
|
|
779
|
+
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.");
|
|
780
|
+
if (!background && contrastCurve) throw new Error("Color " + name + " has contrastCurvedefined, but background is not defined.");
|
|
781
|
+
if (background && !contrastCurve) throw new Error("Color " + name + " has backgrounddefined, but contrastCurve is not defined.");
|
|
782
|
+
}
|
|
783
|
+
var _proto3 = DynamicColor.prototype;
|
|
784
|
+
_proto3.getArgb = function getArgb(scheme) {
|
|
785
|
+
return this.getHct(scheme).toInt();
|
|
786
|
+
};
|
|
787
|
+
_proto3.getHct = function getHct(scheme) {
|
|
788
|
+
var cachedAnswer = this.hctCache.get(scheme);
|
|
789
|
+
if (null != cachedAnswer) return cachedAnswer;
|
|
790
|
+
var tone = this.getTone(scheme),
|
|
791
|
+
answer = this.palette(scheme).getHct(tone);
|
|
792
|
+
return this.hctCache.size > 4 && this.hctCache.clear(), this.hctCache.set(scheme, answer), answer;
|
|
793
|
+
};
|
|
794
|
+
_proto3.getTone = function getTone(scheme) {
|
|
795
|
+
var decreasingContrast = scheme.contrastLevel < 0;
|
|
796
|
+
if (this.toneDeltaPair) {
|
|
797
|
+
var toneDeltaPair = this.toneDeltaPair(scheme),
|
|
798
|
+
roleA = toneDeltaPair.roleA,
|
|
799
|
+
roleB = toneDeltaPair.roleB,
|
|
800
|
+
delta = toneDeltaPair.delta,
|
|
801
|
+
polarity = toneDeltaPair.polarity,
|
|
802
|
+
stayTogether = toneDeltaPair.stayTogether,
|
|
803
|
+
bgTone = this.background(scheme).getTone(scheme),
|
|
804
|
+
aIsNearer = "nearer" === polarity || "lighter" === polarity && !scheme.isDark || "darker" === polarity && scheme.isDark,
|
|
805
|
+
nearer = aIsNearer ? roleA : roleB,
|
|
806
|
+
farther = aIsNearer ? roleB : roleA,
|
|
807
|
+
amNearer = this.name === nearer.name,
|
|
808
|
+
expansionDir = scheme.isDark ? 1 : -1,
|
|
809
|
+
nContrast = nearer.contrastCurve.getContrast(scheme.contrastLevel),
|
|
810
|
+
fContrast = farther.contrastCurve.getContrast(scheme.contrastLevel),
|
|
811
|
+
nInitialTone = nearer.tone(scheme);
|
|
812
|
+
var nTone = Contrast.ratioOfTones(bgTone, nInitialTone) >= nContrast ? nInitialTone : DynamicColor.foregroundTone(bgTone, nContrast);
|
|
813
|
+
var fInitialTone = farther.tone(scheme);
|
|
814
|
+
var fTone = Contrast.ratioOfTones(bgTone, fInitialTone) >= fContrast ? fInitialTone : DynamicColor.foregroundTone(bgTone, fContrast);
|
|
815
|
+
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;
|
|
816
|
+
}
|
|
817
|
+
{
|
|
818
|
+
var answer = this.tone(scheme);
|
|
819
|
+
if (null == this.background) return answer;
|
|
820
|
+
var _bgTone = this.background(scheme).getTone(scheme),
|
|
821
|
+
desiredRatio = this.contrastCurve.getContrast(scheme.contrastLevel);
|
|
822
|
+
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) {
|
|
823
|
+
var _ref = [this.background, this.secondBackground],
|
|
824
|
+
bg1 = _ref[0],
|
|
825
|
+
bg2 = _ref[1],
|
|
826
|
+
_ref2 = [bg1(scheme).getTone(scheme), bg2(scheme).getTone(scheme)],
|
|
827
|
+
bgTone1 = _ref2[0],
|
|
828
|
+
bgTone2 = _ref2[1],
|
|
829
|
+
_ref3 = [Math.max(bgTone1, bgTone2), Math.min(bgTone1, bgTone2)],
|
|
830
|
+
upper = _ref3[0],
|
|
831
|
+
lower = _ref3[1];
|
|
832
|
+
if (Contrast.ratioOfTones(upper, answer) >= desiredRatio && Contrast.ratioOfTones(lower, answer) >= desiredRatio) return answer;
|
|
833
|
+
var lightOption = Contrast.lighter(upper, desiredRatio),
|
|
834
|
+
darkOption = Contrast.darker(lower, desiredRatio),
|
|
835
|
+
availables = [];
|
|
836
|
+
-1 !== lightOption && availables.push(lightOption), -1 !== darkOption && availables.push(darkOption);
|
|
837
|
+
return DynamicColor.tonePrefersLightForeground(bgTone1) || DynamicColor.tonePrefersLightForeground(bgTone2) ? lightOption < 0 ? 100 : lightOption : 1 === availables.length ? availables[0] : darkOption < 0 ? 0 : darkOption;
|
|
838
|
+
}
|
|
839
|
+
return answer;
|
|
840
|
+
}
|
|
841
|
+
};
|
|
842
|
+
DynamicColor.foregroundTone = function foregroundTone(bgTone, ratio) {
|
|
843
|
+
var lighterTone = Contrast.lighterUnsafe(bgTone, ratio),
|
|
844
|
+
darkerTone = Contrast.darkerUnsafe(bgTone, ratio),
|
|
845
|
+
lighterRatio = Contrast.ratioOfTones(lighterTone, bgTone),
|
|
846
|
+
darkerRatio = Contrast.ratioOfTones(darkerTone, bgTone);
|
|
847
|
+
if (DynamicColor.tonePrefersLightForeground(bgTone)) {
|
|
848
|
+
var negligibleDifference = Math.abs(lighterRatio - darkerRatio) < .1 && lighterRatio < ratio && darkerRatio < ratio;
|
|
849
|
+
return lighterRatio >= ratio || lighterRatio >= darkerRatio || negligibleDifference ? lighterTone : darkerTone;
|
|
850
|
+
}
|
|
851
|
+
return darkerRatio >= ratio || darkerRatio >= lighterRatio ? darkerTone : lighterTone;
|
|
852
|
+
};
|
|
853
|
+
DynamicColor.tonePrefersLightForeground = function tonePrefersLightForeground(tone) {
|
|
854
|
+
return Math.round(tone) < 60;
|
|
855
|
+
};
|
|
856
|
+
DynamicColor.toneAllowsLightForeground = function toneAllowsLightForeground(tone) {
|
|
857
|
+
return Math.round(tone) <= 49;
|
|
858
|
+
};
|
|
859
|
+
DynamicColor.enableLightForeground = function enableLightForeground(tone) {
|
|
860
|
+
return DynamicColor.tonePrefersLightForeground(tone) && !DynamicColor.toneAllowsLightForeground(tone) ? 49 : tone;
|
|
861
|
+
};
|
|
862
|
+
return DynamicColor;
|
|
863
|
+
}();
|
|
864
|
+
var Variant;
|
|
865
|
+
!function (Variant) {
|
|
866
|
+
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";
|
|
867
|
+
}(Variant || (Variant = {}));
|
|
868
|
+
var ContrastCurve = function () {
|
|
869
|
+
function ContrastCurve(low, normal, medium, high) {
|
|
870
|
+
this.low = low, this.normal = normal, this.medium = medium, this.high = high;
|
|
871
|
+
}
|
|
872
|
+
var _proto4 = ContrastCurve.prototype;
|
|
873
|
+
_proto4.getContrast = function getContrast(contrastLevel) {
|
|
874
|
+
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;
|
|
875
|
+
};
|
|
876
|
+
return ContrastCurve;
|
|
877
|
+
}();
|
|
878
|
+
var ToneDeltaPair = function ToneDeltaPair(roleA, roleB, delta, polarity, stayTogether) {
|
|
879
|
+
this.roleA = roleA, this.roleB = roleB, this.delta = delta, this.polarity = polarity, this.stayTogether = stayTogether;
|
|
880
|
+
};
|
|
881
|
+
function isFidelity(scheme) {
|
|
882
|
+
return scheme.variant === Variant.FIDELITY || scheme.variant === Variant.CONTENT;
|
|
883
|
+
}
|
|
884
|
+
function isMonochrome(scheme) {
|
|
885
|
+
return scheme.variant === Variant.MONOCHROME;
|
|
886
|
+
}
|
|
887
|
+
function findDesiredChromaByTone(hue, chroma, tone, byDecreasingTone) {
|
|
888
|
+
var answer = tone,
|
|
889
|
+
closestToChroma = Hct.from(hue, chroma, tone);
|
|
890
|
+
if (closestToChroma.chroma < chroma) {
|
|
891
|
+
var chromaPeak = closestToChroma.chroma;
|
|
892
|
+
for (; closestToChroma.chroma < chroma;) {
|
|
893
|
+
answer += byDecreasingTone ? -1 : 1;
|
|
894
|
+
var potentialSolution = Hct.from(hue, chroma, answer);
|
|
895
|
+
if (chromaPeak > potentialSolution.chroma) break;
|
|
896
|
+
if (Math.abs(potentialSolution.chroma - chroma) < .4) break;
|
|
897
|
+
Math.abs(potentialSolution.chroma - chroma) < Math.abs(closestToChroma.chroma - chroma) && (closestToChroma = potentialSolution), chromaPeak = Math.max(chromaPeak, potentialSolution.chroma);
|
|
898
|
+
}
|
|
899
|
+
}
|
|
900
|
+
return answer;
|
|
901
|
+
}
|
|
902
|
+
function viewingConditionsForAlbers(scheme) {
|
|
903
|
+
return ViewingConditions.make(void 0, void 0, scheme.isDark ? 30 : 80, void 0, void 0);
|
|
904
|
+
}
|
|
905
|
+
function performAlbers(prealbers, scheme) {
|
|
906
|
+
var albersd = prealbers.inViewingConditions(viewingConditionsForAlbers(scheme));
|
|
907
|
+
return DynamicColor.tonePrefersLightForeground(prealbers.tone) && !DynamicColor.toneAllowsLightForeground(albersd.tone) ? DynamicColor.enableLightForeground(prealbers.tone) : DynamicColor.enableLightForeground(albersd.tone);
|
|
908
|
+
}
|
|
909
|
+
var MaterialDynamicColors = function () {
|
|
910
|
+
function MaterialDynamicColors() {}
|
|
911
|
+
MaterialDynamicColors.highestSurface = function highestSurface(s) {
|
|
912
|
+
return s.isDark ? MaterialDynamicColors.surfaceBright : MaterialDynamicColors.surfaceDim;
|
|
913
|
+
};
|
|
914
|
+
return MaterialDynamicColors;
|
|
915
|
+
}();
|
|
916
|
+
MaterialDynamicColors.contentAccentToneDelta = 15, MaterialDynamicColors.primaryPaletteKeyColor = DynamicColor.fromPalette({
|
|
917
|
+
name: "primary_palette_key_color",
|
|
918
|
+
palette: function palette(s) {
|
|
919
|
+
return s.primaryPalette;
|
|
920
|
+
},
|
|
921
|
+
tone: function tone(s) {
|
|
922
|
+
return s.primaryPalette.keyColor.tone;
|
|
923
|
+
}
|
|
924
|
+
}), MaterialDynamicColors.secondaryPaletteKeyColor = DynamicColor.fromPalette({
|
|
925
|
+
name: "secondary_palette_key_color",
|
|
926
|
+
palette: function palette(s) {
|
|
927
|
+
return s.secondaryPalette;
|
|
928
|
+
},
|
|
929
|
+
tone: function tone(s) {
|
|
930
|
+
return s.secondaryPalette.keyColor.tone;
|
|
931
|
+
}
|
|
932
|
+
}), MaterialDynamicColors.tertiaryPaletteKeyColor = DynamicColor.fromPalette({
|
|
933
|
+
name: "tertiary_palette_key_color",
|
|
934
|
+
palette: function palette(s) {
|
|
935
|
+
return s.tertiaryPalette;
|
|
936
|
+
},
|
|
937
|
+
tone: function tone(s) {
|
|
938
|
+
return s.tertiaryPalette.keyColor.tone;
|
|
939
|
+
}
|
|
940
|
+
}), MaterialDynamicColors.neutralPaletteKeyColor = DynamicColor.fromPalette({
|
|
941
|
+
name: "neutral_palette_key_color",
|
|
942
|
+
palette: function palette(s) {
|
|
943
|
+
return s.neutralPalette;
|
|
944
|
+
},
|
|
945
|
+
tone: function tone(s) {
|
|
946
|
+
return s.neutralPalette.keyColor.tone;
|
|
947
|
+
}
|
|
948
|
+
}), MaterialDynamicColors.neutralVariantPaletteKeyColor = DynamicColor.fromPalette({
|
|
949
|
+
name: "neutral_variant_palette_key_color",
|
|
950
|
+
palette: function palette(s) {
|
|
951
|
+
return s.neutralVariantPalette;
|
|
952
|
+
},
|
|
953
|
+
tone: function tone(s) {
|
|
954
|
+
return s.neutralVariantPalette.keyColor.tone;
|
|
955
|
+
}
|
|
956
|
+
}), MaterialDynamicColors.background = DynamicColor.fromPalette({
|
|
957
|
+
name: "background",
|
|
958
|
+
palette: function palette(s) {
|
|
959
|
+
return s.neutralPalette;
|
|
960
|
+
},
|
|
961
|
+
tone: function tone(s) {
|
|
962
|
+
return s.isDark ? 6 : 98;
|
|
963
|
+
},
|
|
964
|
+
isBackground: !0
|
|
965
|
+
}), MaterialDynamicColors.onBackground = DynamicColor.fromPalette({
|
|
966
|
+
name: "on_background",
|
|
967
|
+
palette: function palette(s) {
|
|
968
|
+
return s.neutralPalette;
|
|
969
|
+
},
|
|
970
|
+
tone: function tone(s) {
|
|
971
|
+
return s.isDark ? 90 : 10;
|
|
972
|
+
},
|
|
973
|
+
background: function background(s) {
|
|
974
|
+
return MaterialDynamicColors.background;
|
|
975
|
+
},
|
|
976
|
+
contrastCurve: new ContrastCurve(3, 3, 4.5, 7)
|
|
977
|
+
}), MaterialDynamicColors.surface = DynamicColor.fromPalette({
|
|
978
|
+
name: "surface",
|
|
979
|
+
palette: function palette(s) {
|
|
980
|
+
return s.neutralPalette;
|
|
981
|
+
},
|
|
982
|
+
tone: function tone(s) {
|
|
983
|
+
return s.isDark ? 6 : 98;
|
|
984
|
+
},
|
|
985
|
+
isBackground: !0
|
|
986
|
+
}), MaterialDynamicColors.surfaceDim = DynamicColor.fromPalette({
|
|
987
|
+
name: "surface_dim",
|
|
988
|
+
palette: function palette(s) {
|
|
989
|
+
return s.neutralPalette;
|
|
990
|
+
},
|
|
991
|
+
tone: function tone(s) {
|
|
992
|
+
return s.isDark ? 6 : 87;
|
|
993
|
+
},
|
|
994
|
+
isBackground: !0
|
|
995
|
+
}), MaterialDynamicColors.surfaceBright = DynamicColor.fromPalette({
|
|
996
|
+
name: "surface_bright",
|
|
997
|
+
palette: function palette(s) {
|
|
998
|
+
return s.neutralPalette;
|
|
999
|
+
},
|
|
1000
|
+
tone: function tone(s) {
|
|
1001
|
+
return s.isDark ? 24 : 98;
|
|
1002
|
+
},
|
|
1003
|
+
isBackground: !0
|
|
1004
|
+
}), MaterialDynamicColors.surfaceContainerLowest = DynamicColor.fromPalette({
|
|
1005
|
+
name: "surface_container_lowest",
|
|
1006
|
+
palette: function palette(s) {
|
|
1007
|
+
return s.neutralPalette;
|
|
1008
|
+
},
|
|
1009
|
+
tone: function tone(s) {
|
|
1010
|
+
return s.isDark ? 4 : 100;
|
|
1011
|
+
},
|
|
1012
|
+
isBackground: !0
|
|
1013
|
+
}), MaterialDynamicColors.surfaceContainerLow = DynamicColor.fromPalette({
|
|
1014
|
+
name: "surface_container_low",
|
|
1015
|
+
palette: function palette(s) {
|
|
1016
|
+
return s.neutralPalette;
|
|
1017
|
+
},
|
|
1018
|
+
tone: function tone(s) {
|
|
1019
|
+
return s.isDark ? 10 : 96;
|
|
1020
|
+
},
|
|
1021
|
+
isBackground: !0
|
|
1022
|
+
}), MaterialDynamicColors.surfaceContainer = DynamicColor.fromPalette({
|
|
1023
|
+
name: "surface_container",
|
|
1024
|
+
palette: function palette(s) {
|
|
1025
|
+
return s.neutralPalette;
|
|
1026
|
+
},
|
|
1027
|
+
tone: function tone(s) {
|
|
1028
|
+
return s.isDark ? 12 : 94;
|
|
1029
|
+
},
|
|
1030
|
+
isBackground: !0
|
|
1031
|
+
}), MaterialDynamicColors.surfaceContainerHigh = DynamicColor.fromPalette({
|
|
1032
|
+
name: "surface_container_high",
|
|
1033
|
+
palette: function palette(s) {
|
|
1034
|
+
return s.neutralPalette;
|
|
1035
|
+
},
|
|
1036
|
+
tone: function tone(s) {
|
|
1037
|
+
return s.isDark ? 17 : 92;
|
|
1038
|
+
},
|
|
1039
|
+
isBackground: !0
|
|
1040
|
+
}), MaterialDynamicColors.surfaceContainerHighest = DynamicColor.fromPalette({
|
|
1041
|
+
name: "surface_container_highest",
|
|
1042
|
+
palette: function palette(s) {
|
|
1043
|
+
return s.neutralPalette;
|
|
1044
|
+
},
|
|
1045
|
+
tone: function tone(s) {
|
|
1046
|
+
return s.isDark ? 22 : 90;
|
|
1047
|
+
},
|
|
1048
|
+
isBackground: !0
|
|
1049
|
+
}), MaterialDynamicColors.onSurface = DynamicColor.fromPalette({
|
|
1050
|
+
name: "on_surface",
|
|
1051
|
+
palette: function palette(s) {
|
|
1052
|
+
return s.neutralPalette;
|
|
1053
|
+
},
|
|
1054
|
+
tone: function tone(s) {
|
|
1055
|
+
return s.isDark ? 90 : 10;
|
|
1056
|
+
},
|
|
1057
|
+
background: function background(s) {
|
|
1058
|
+
return MaterialDynamicColors.highestSurface(s);
|
|
1059
|
+
},
|
|
1060
|
+
contrastCurve: new ContrastCurve(4.5, 7, 11, 21)
|
|
1061
|
+
}), MaterialDynamicColors.surfaceVariant = DynamicColor.fromPalette({
|
|
1062
|
+
name: "surface_variant",
|
|
1063
|
+
palette: function palette(s) {
|
|
1064
|
+
return s.neutralVariantPalette;
|
|
1065
|
+
},
|
|
1066
|
+
tone: function tone(s) {
|
|
1067
|
+
return s.isDark ? 30 : 90;
|
|
1068
|
+
},
|
|
1069
|
+
isBackground: !0
|
|
1070
|
+
}), MaterialDynamicColors.onSurfaceVariant = DynamicColor.fromPalette({
|
|
1071
|
+
name: "on_surface_variant",
|
|
1072
|
+
palette: function palette(s) {
|
|
1073
|
+
return s.neutralVariantPalette;
|
|
1074
|
+
},
|
|
1075
|
+
tone: function tone(s) {
|
|
1076
|
+
return s.isDark ? 80 : 30;
|
|
1077
|
+
},
|
|
1078
|
+
background: function background(s) {
|
|
1079
|
+
return MaterialDynamicColors.highestSurface(s);
|
|
1080
|
+
},
|
|
1081
|
+
contrastCurve: new ContrastCurve(3, 4.5, 7, 11)
|
|
1082
|
+
}), MaterialDynamicColors.inverseSurface = DynamicColor.fromPalette({
|
|
1083
|
+
name: "inverse_surface",
|
|
1084
|
+
palette: function palette(s) {
|
|
1085
|
+
return s.neutralPalette;
|
|
1086
|
+
},
|
|
1087
|
+
tone: function tone(s) {
|
|
1088
|
+
return s.isDark ? 90 : 20;
|
|
1089
|
+
}
|
|
1090
|
+
}), MaterialDynamicColors.inverseOnSurface = DynamicColor.fromPalette({
|
|
1091
|
+
name: "inverse_on_surface",
|
|
1092
|
+
palette: function palette(s) {
|
|
1093
|
+
return s.neutralPalette;
|
|
1094
|
+
},
|
|
1095
|
+
tone: function tone(s) {
|
|
1096
|
+
return s.isDark ? 20 : 95;
|
|
1097
|
+
},
|
|
1098
|
+
background: function background(s) {
|
|
1099
|
+
return MaterialDynamicColors.inverseSurface;
|
|
1100
|
+
},
|
|
1101
|
+
contrastCurve: new ContrastCurve(4.5, 7, 11, 21)
|
|
1102
|
+
}), MaterialDynamicColors.outline = DynamicColor.fromPalette({
|
|
1103
|
+
name: "outline",
|
|
1104
|
+
palette: function palette(s) {
|
|
1105
|
+
return s.neutralVariantPalette;
|
|
1106
|
+
},
|
|
1107
|
+
tone: function tone(s) {
|
|
1108
|
+
return s.isDark ? 60 : 50;
|
|
1109
|
+
},
|
|
1110
|
+
background: function background(s) {
|
|
1111
|
+
return MaterialDynamicColors.highestSurface(s);
|
|
1112
|
+
},
|
|
1113
|
+
contrastCurve: new ContrastCurve(1.5, 3, 4.5, 7)
|
|
1114
|
+
}), MaterialDynamicColors.outlineVariant = DynamicColor.fromPalette({
|
|
1115
|
+
name: "outline_variant",
|
|
1116
|
+
palette: function palette(s) {
|
|
1117
|
+
return s.neutralVariantPalette;
|
|
1118
|
+
},
|
|
1119
|
+
tone: function tone(s) {
|
|
1120
|
+
return s.isDark ? 30 : 80;
|
|
1121
|
+
},
|
|
1122
|
+
background: function background(s) {
|
|
1123
|
+
return MaterialDynamicColors.highestSurface(s);
|
|
1124
|
+
},
|
|
1125
|
+
contrastCurve: new ContrastCurve(1, 1, 3, 7)
|
|
1126
|
+
}), MaterialDynamicColors.shadow = DynamicColor.fromPalette({
|
|
1127
|
+
name: "shadow",
|
|
1128
|
+
palette: function palette(s) {
|
|
1129
|
+
return s.neutralPalette;
|
|
1130
|
+
},
|
|
1131
|
+
tone: function tone(s) {
|
|
1132
|
+
return 0;
|
|
1133
|
+
}
|
|
1134
|
+
}), MaterialDynamicColors.scrim = DynamicColor.fromPalette({
|
|
1135
|
+
name: "scrim",
|
|
1136
|
+
palette: function palette(s) {
|
|
1137
|
+
return s.neutralPalette;
|
|
1138
|
+
},
|
|
1139
|
+
tone: function tone(s) {
|
|
1140
|
+
return 0;
|
|
1141
|
+
}
|
|
1142
|
+
}), MaterialDynamicColors.surfaceTint = DynamicColor.fromPalette({
|
|
1143
|
+
name: "surface_tint",
|
|
1144
|
+
palette: function palette(s) {
|
|
1145
|
+
return s.primaryPalette;
|
|
1146
|
+
},
|
|
1147
|
+
tone: function tone(s) {
|
|
1148
|
+
return s.isDark ? 80 : 40;
|
|
1149
|
+
},
|
|
1150
|
+
isBackground: !0
|
|
1151
|
+
}), MaterialDynamicColors.primary = DynamicColor.fromPalette({
|
|
1152
|
+
name: "primary",
|
|
1153
|
+
palette: function palette(s) {
|
|
1154
|
+
return s.primaryPalette;
|
|
1155
|
+
},
|
|
1156
|
+
tone: function tone(s) {
|
|
1157
|
+
return isMonochrome(s) ? s.isDark ? 100 : 0 : s.isDark ? 80 : 40;
|
|
1158
|
+
},
|
|
1159
|
+
isBackground: !0,
|
|
1160
|
+
background: function background(s) {
|
|
1161
|
+
return MaterialDynamicColors.highestSurface(s);
|
|
1162
|
+
},
|
|
1163
|
+
contrastCurve: new ContrastCurve(3, 4.5, 7, 11),
|
|
1164
|
+
toneDeltaPair: function toneDeltaPair(s) {
|
|
1165
|
+
return new ToneDeltaPair(MaterialDynamicColors.primaryContainer, MaterialDynamicColors.primary, 15, "nearer", !1);
|
|
1166
|
+
}
|
|
1167
|
+
}), MaterialDynamicColors.onPrimary = DynamicColor.fromPalette({
|
|
1168
|
+
name: "on_primary",
|
|
1169
|
+
palette: function palette(s) {
|
|
1170
|
+
return s.primaryPalette;
|
|
1171
|
+
},
|
|
1172
|
+
tone: function tone(s) {
|
|
1173
|
+
return isMonochrome(s) ? s.isDark ? 10 : 90 : s.isDark ? 20 : 100;
|
|
1174
|
+
},
|
|
1175
|
+
background: function background(s) {
|
|
1176
|
+
return MaterialDynamicColors.primary;
|
|
1177
|
+
},
|
|
1178
|
+
contrastCurve: new ContrastCurve(4.5, 7, 11, 21)
|
|
1179
|
+
}), MaterialDynamicColors.primaryContainer = DynamicColor.fromPalette({
|
|
1180
|
+
name: "primary_container",
|
|
1181
|
+
palette: function palette(s) {
|
|
1182
|
+
return s.primaryPalette;
|
|
1183
|
+
},
|
|
1184
|
+
tone: function tone(s) {
|
|
1185
|
+
return isFidelity(s) ? performAlbers(s.sourceColorHct, s) : isMonochrome(s) ? s.isDark ? 85 : 25 : s.isDark ? 30 : 90;
|
|
1186
|
+
},
|
|
1187
|
+
isBackground: !0,
|
|
1188
|
+
background: function background(s) {
|
|
1189
|
+
return MaterialDynamicColors.highestSurface(s);
|
|
1190
|
+
},
|
|
1191
|
+
contrastCurve: new ContrastCurve(1, 1, 3, 7),
|
|
1192
|
+
toneDeltaPair: function toneDeltaPair(s) {
|
|
1193
|
+
return new ToneDeltaPair(MaterialDynamicColors.primaryContainer, MaterialDynamicColors.primary, 15, "nearer", !1);
|
|
1194
|
+
}
|
|
1195
|
+
}), MaterialDynamicColors.onPrimaryContainer = DynamicColor.fromPalette({
|
|
1196
|
+
name: "on_primary_container",
|
|
1197
|
+
palette: function palette(s) {
|
|
1198
|
+
return s.primaryPalette;
|
|
1199
|
+
},
|
|
1200
|
+
tone: function tone(s) {
|
|
1201
|
+
return isFidelity(s) ? DynamicColor.foregroundTone(MaterialDynamicColors.primaryContainer.tone(s), 4.5) : isMonochrome(s) ? s.isDark ? 0 : 100 : s.isDark ? 90 : 10;
|
|
1202
|
+
},
|
|
1203
|
+
background: function background(s) {
|
|
1204
|
+
return MaterialDynamicColors.primaryContainer;
|
|
1205
|
+
},
|
|
1206
|
+
contrastCurve: new ContrastCurve(4.5, 7, 11, 21)
|
|
1207
|
+
}), MaterialDynamicColors.inversePrimary = DynamicColor.fromPalette({
|
|
1208
|
+
name: "inverse_primary",
|
|
1209
|
+
palette: function palette(s) {
|
|
1210
|
+
return s.primaryPalette;
|
|
1211
|
+
},
|
|
1212
|
+
tone: function tone(s) {
|
|
1213
|
+
return s.isDark ? 40 : 80;
|
|
1214
|
+
},
|
|
1215
|
+
background: function background(s) {
|
|
1216
|
+
return MaterialDynamicColors.inverseSurface;
|
|
1217
|
+
},
|
|
1218
|
+
contrastCurve: new ContrastCurve(3, 4.5, 7, 11)
|
|
1219
|
+
}), MaterialDynamicColors.secondary = DynamicColor.fromPalette({
|
|
1220
|
+
name: "secondary",
|
|
1221
|
+
palette: function palette(s) {
|
|
1222
|
+
return s.secondaryPalette;
|
|
1223
|
+
},
|
|
1224
|
+
tone: function tone(s) {
|
|
1225
|
+
return s.isDark ? 80 : 40;
|
|
1226
|
+
},
|
|
1227
|
+
isBackground: !0,
|
|
1228
|
+
background: function background(s) {
|
|
1229
|
+
return MaterialDynamicColors.highestSurface(s);
|
|
1230
|
+
},
|
|
1231
|
+
contrastCurve: new ContrastCurve(3, 4.5, 7, 11),
|
|
1232
|
+
toneDeltaPair: function toneDeltaPair(s) {
|
|
1233
|
+
return new ToneDeltaPair(MaterialDynamicColors.secondaryContainer, MaterialDynamicColors.secondary, 15, "nearer", !1);
|
|
1234
|
+
}
|
|
1235
|
+
}), MaterialDynamicColors.onSecondary = DynamicColor.fromPalette({
|
|
1236
|
+
name: "on_secondary",
|
|
1237
|
+
palette: function palette(s) {
|
|
1238
|
+
return s.secondaryPalette;
|
|
1239
|
+
},
|
|
1240
|
+
tone: function tone(s) {
|
|
1241
|
+
return isMonochrome(s) ? s.isDark ? 10 : 100 : s.isDark ? 20 : 100;
|
|
1242
|
+
},
|
|
1243
|
+
background: function background(s) {
|
|
1244
|
+
return MaterialDynamicColors.secondary;
|
|
1245
|
+
},
|
|
1246
|
+
contrastCurve: new ContrastCurve(4.5, 7, 11, 21)
|
|
1247
|
+
}), MaterialDynamicColors.secondaryContainer = DynamicColor.fromPalette({
|
|
1248
|
+
name: "secondary_container",
|
|
1249
|
+
palette: function palette(s) {
|
|
1250
|
+
return s.secondaryPalette;
|
|
1251
|
+
},
|
|
1252
|
+
tone: function tone(s) {
|
|
1253
|
+
var initialTone = s.isDark ? 30 : 90;
|
|
1254
|
+
if (isMonochrome(s)) return s.isDark ? 30 : 85;
|
|
1255
|
+
if (!isFidelity(s)) return initialTone;
|
|
1256
|
+
var answer = findDesiredChromaByTone(s.secondaryPalette.hue, s.secondaryPalette.chroma, initialTone, !s.isDark);
|
|
1257
|
+
return answer = performAlbers(s.secondaryPalette.getHct(answer), s), answer;
|
|
1258
|
+
},
|
|
1259
|
+
isBackground: !0,
|
|
1260
|
+
background: function background(s) {
|
|
1261
|
+
return MaterialDynamicColors.highestSurface(s);
|
|
1262
|
+
},
|
|
1263
|
+
contrastCurve: new ContrastCurve(1, 1, 3, 7),
|
|
1264
|
+
toneDeltaPair: function toneDeltaPair(s) {
|
|
1265
|
+
return new ToneDeltaPair(MaterialDynamicColors.secondaryContainer, MaterialDynamicColors.secondary, 15, "nearer", !1);
|
|
1266
|
+
}
|
|
1267
|
+
}), MaterialDynamicColors.onSecondaryContainer = DynamicColor.fromPalette({
|
|
1268
|
+
name: "on_secondary_container",
|
|
1269
|
+
palette: function palette(s) {
|
|
1270
|
+
return s.secondaryPalette;
|
|
1271
|
+
},
|
|
1272
|
+
tone: function tone(s) {
|
|
1273
|
+
return isFidelity(s) ? DynamicColor.foregroundTone(MaterialDynamicColors.secondaryContainer.tone(s), 4.5) : s.isDark ? 90 : 10;
|
|
1274
|
+
},
|
|
1275
|
+
background: function background(s) {
|
|
1276
|
+
return MaterialDynamicColors.secondaryContainer;
|
|
1277
|
+
},
|
|
1278
|
+
contrastCurve: new ContrastCurve(4.5, 7, 11, 21)
|
|
1279
|
+
}), MaterialDynamicColors.tertiary = DynamicColor.fromPalette({
|
|
1280
|
+
name: "tertiary",
|
|
1281
|
+
palette: function palette(s) {
|
|
1282
|
+
return s.tertiaryPalette;
|
|
1283
|
+
},
|
|
1284
|
+
tone: function tone(s) {
|
|
1285
|
+
return isMonochrome(s) ? s.isDark ? 90 : 25 : s.isDark ? 80 : 40;
|
|
1286
|
+
},
|
|
1287
|
+
isBackground: !0,
|
|
1288
|
+
background: function background(s) {
|
|
1289
|
+
return MaterialDynamicColors.highestSurface(s);
|
|
1290
|
+
},
|
|
1291
|
+
contrastCurve: new ContrastCurve(3, 4.5, 7, 11),
|
|
1292
|
+
toneDeltaPair: function toneDeltaPair(s) {
|
|
1293
|
+
return new ToneDeltaPair(MaterialDynamicColors.tertiaryContainer, MaterialDynamicColors.tertiary, 15, "nearer", !1);
|
|
1294
|
+
}
|
|
1295
|
+
}), MaterialDynamicColors.onTertiary = DynamicColor.fromPalette({
|
|
1296
|
+
name: "on_tertiary",
|
|
1297
|
+
palette: function palette(s) {
|
|
1298
|
+
return s.tertiaryPalette;
|
|
1299
|
+
},
|
|
1300
|
+
tone: function tone(s) {
|
|
1301
|
+
return isMonochrome(s) ? s.isDark ? 10 : 90 : s.isDark ? 20 : 100;
|
|
1302
|
+
},
|
|
1303
|
+
background: function background(s) {
|
|
1304
|
+
return MaterialDynamicColors.tertiary;
|
|
1305
|
+
},
|
|
1306
|
+
contrastCurve: new ContrastCurve(4.5, 7, 11, 21)
|
|
1307
|
+
}), MaterialDynamicColors.tertiaryContainer = DynamicColor.fromPalette({
|
|
1308
|
+
name: "tertiary_container",
|
|
1309
|
+
palette: function palette(s) {
|
|
1310
|
+
return s.tertiaryPalette;
|
|
1311
|
+
},
|
|
1312
|
+
tone: function tone(s) {
|
|
1313
|
+
if (isMonochrome(s)) return s.isDark ? 60 : 49;
|
|
1314
|
+
if (!isFidelity(s)) return s.isDark ? 30 : 90;
|
|
1315
|
+
var albersTone = performAlbers(s.tertiaryPalette.getHct(s.sourceColorHct.tone), s),
|
|
1316
|
+
proposedHct = s.tertiaryPalette.getHct(albersTone);
|
|
1317
|
+
return DislikeAnalyzer.fixIfDisliked(proposedHct).tone;
|
|
1318
|
+
},
|
|
1319
|
+
isBackground: !0,
|
|
1320
|
+
background: function background(s) {
|
|
1321
|
+
return MaterialDynamicColors.highestSurface(s);
|
|
1322
|
+
},
|
|
1323
|
+
contrastCurve: new ContrastCurve(1, 1, 3, 7),
|
|
1324
|
+
toneDeltaPair: function toneDeltaPair(s) {
|
|
1325
|
+
return new ToneDeltaPair(MaterialDynamicColors.tertiaryContainer, MaterialDynamicColors.tertiary, 15, "nearer", !1);
|
|
1326
|
+
}
|
|
1327
|
+
}), MaterialDynamicColors.onTertiaryContainer = DynamicColor.fromPalette({
|
|
1328
|
+
name: "on_tertiary_container",
|
|
1329
|
+
palette: function palette(s) {
|
|
1330
|
+
return s.tertiaryPalette;
|
|
1331
|
+
},
|
|
1332
|
+
tone: function tone(s) {
|
|
1333
|
+
return isMonochrome(s) ? s.isDark ? 0 : 100 : isFidelity(s) ? DynamicColor.foregroundTone(MaterialDynamicColors.tertiaryContainer.tone(s), 4.5) : s.isDark ? 90 : 10;
|
|
1334
|
+
},
|
|
1335
|
+
background: function background(s) {
|
|
1336
|
+
return MaterialDynamicColors.tertiaryContainer;
|
|
1337
|
+
},
|
|
1338
|
+
contrastCurve: new ContrastCurve(4.5, 7, 11, 21)
|
|
1339
|
+
}), MaterialDynamicColors.error = DynamicColor.fromPalette({
|
|
1340
|
+
name: "error",
|
|
1341
|
+
palette: function palette(s) {
|
|
1342
|
+
return s.errorPalette;
|
|
1343
|
+
},
|
|
1344
|
+
tone: function tone(s) {
|
|
1345
|
+
return s.isDark ? 80 : 40;
|
|
1346
|
+
},
|
|
1347
|
+
isBackground: !0,
|
|
1348
|
+
background: function background(s) {
|
|
1349
|
+
return MaterialDynamicColors.highestSurface(s);
|
|
1350
|
+
},
|
|
1351
|
+
contrastCurve: new ContrastCurve(3, 4.5, 7, 11),
|
|
1352
|
+
toneDeltaPair: function toneDeltaPair(s) {
|
|
1353
|
+
return new ToneDeltaPair(MaterialDynamicColors.errorContainer, MaterialDynamicColors.error, 15, "nearer", !1);
|
|
1354
|
+
}
|
|
1355
|
+
}), MaterialDynamicColors.onError = DynamicColor.fromPalette({
|
|
1356
|
+
name: "on_error",
|
|
1357
|
+
palette: function palette(s) {
|
|
1358
|
+
return s.errorPalette;
|
|
1359
|
+
},
|
|
1360
|
+
tone: function tone(s) {
|
|
1361
|
+
return s.isDark ? 20 : 100;
|
|
1362
|
+
},
|
|
1363
|
+
background: function background(s) {
|
|
1364
|
+
return MaterialDynamicColors.error;
|
|
1365
|
+
},
|
|
1366
|
+
contrastCurve: new ContrastCurve(4.5, 7, 11, 21)
|
|
1367
|
+
}), MaterialDynamicColors.errorContainer = DynamicColor.fromPalette({
|
|
1368
|
+
name: "error_container",
|
|
1369
|
+
palette: function palette(s) {
|
|
1370
|
+
return s.errorPalette;
|
|
1371
|
+
},
|
|
1372
|
+
tone: function tone(s) {
|
|
1373
|
+
return s.isDark ? 30 : 90;
|
|
1374
|
+
},
|
|
1375
|
+
isBackground: !0,
|
|
1376
|
+
background: function background(s) {
|
|
1377
|
+
return MaterialDynamicColors.highestSurface(s);
|
|
1378
|
+
},
|
|
1379
|
+
contrastCurve: new ContrastCurve(1, 1, 3, 7),
|
|
1380
|
+
toneDeltaPair: function toneDeltaPair(s) {
|
|
1381
|
+
return new ToneDeltaPair(MaterialDynamicColors.errorContainer, MaterialDynamicColors.error, 15, "nearer", !1);
|
|
1382
|
+
}
|
|
1383
|
+
}), MaterialDynamicColors.onErrorContainer = DynamicColor.fromPalette({
|
|
1384
|
+
name: "on_error_container",
|
|
1385
|
+
palette: function palette(s) {
|
|
1386
|
+
return s.errorPalette;
|
|
1387
|
+
},
|
|
1388
|
+
tone: function tone(s) {
|
|
1389
|
+
return s.isDark ? 90 : 10;
|
|
1390
|
+
},
|
|
1391
|
+
background: function background(s) {
|
|
1392
|
+
return MaterialDynamicColors.errorContainer;
|
|
1393
|
+
},
|
|
1394
|
+
contrastCurve: new ContrastCurve(4.5, 7, 11, 21)
|
|
1395
|
+
}), MaterialDynamicColors.primaryFixed = DynamicColor.fromPalette({
|
|
1396
|
+
name: "primary_fixed",
|
|
1397
|
+
palette: function palette(s) {
|
|
1398
|
+
return s.primaryPalette;
|
|
1399
|
+
},
|
|
1400
|
+
tone: function tone(s) {
|
|
1401
|
+
return isMonochrome(s) ? 40 : 90;
|
|
1402
|
+
},
|
|
1403
|
+
isBackground: !0,
|
|
1404
|
+
background: function background(s) {
|
|
1405
|
+
return MaterialDynamicColors.highestSurface(s);
|
|
1406
|
+
},
|
|
1407
|
+
contrastCurve: new ContrastCurve(1, 1, 3, 7),
|
|
1408
|
+
toneDeltaPair: function toneDeltaPair(s) {
|
|
1409
|
+
return new ToneDeltaPair(MaterialDynamicColors.primaryFixed, MaterialDynamicColors.primaryFixedDim, 10, "lighter", !0);
|
|
1410
|
+
}
|
|
1411
|
+
}), MaterialDynamicColors.primaryFixedDim = DynamicColor.fromPalette({
|
|
1412
|
+
name: "primary_fixed_dim",
|
|
1413
|
+
palette: function palette(s) {
|
|
1414
|
+
return s.primaryPalette;
|
|
1415
|
+
},
|
|
1416
|
+
tone: function tone(s) {
|
|
1417
|
+
return isMonochrome(s) ? 30 : 80;
|
|
1418
|
+
},
|
|
1419
|
+
isBackground: !0,
|
|
1420
|
+
background: function background(s) {
|
|
1421
|
+
return MaterialDynamicColors.highestSurface(s);
|
|
1422
|
+
},
|
|
1423
|
+
contrastCurve: new ContrastCurve(1, 1, 3, 7),
|
|
1424
|
+
toneDeltaPair: function toneDeltaPair(s) {
|
|
1425
|
+
return new ToneDeltaPair(MaterialDynamicColors.primaryFixed, MaterialDynamicColors.primaryFixedDim, 10, "lighter", !0);
|
|
1426
|
+
}
|
|
1427
|
+
}), MaterialDynamicColors.onPrimaryFixed = DynamicColor.fromPalette({
|
|
1428
|
+
name: "on_primary_fixed",
|
|
1429
|
+
palette: function palette(s) {
|
|
1430
|
+
return s.primaryPalette;
|
|
1431
|
+
},
|
|
1432
|
+
tone: function tone(s) {
|
|
1433
|
+
return isMonochrome(s) ? 100 : 10;
|
|
1434
|
+
},
|
|
1435
|
+
background: function background(s) {
|
|
1436
|
+
return MaterialDynamicColors.primaryFixedDim;
|
|
1437
|
+
},
|
|
1438
|
+
secondBackground: function secondBackground(s) {
|
|
1439
|
+
return MaterialDynamicColors.primaryFixed;
|
|
1440
|
+
},
|
|
1441
|
+
contrastCurve: new ContrastCurve(4.5, 7, 11, 21)
|
|
1442
|
+
}), MaterialDynamicColors.onPrimaryFixedVariant = DynamicColor.fromPalette({
|
|
1443
|
+
name: "on_primary_fixed_variant",
|
|
1444
|
+
palette: function palette(s) {
|
|
1445
|
+
return s.primaryPalette;
|
|
1446
|
+
},
|
|
1447
|
+
tone: function tone(s) {
|
|
1448
|
+
return isMonochrome(s) ? 90 : 30;
|
|
1449
|
+
},
|
|
1450
|
+
background: function background(s) {
|
|
1451
|
+
return MaterialDynamicColors.primaryFixedDim;
|
|
1452
|
+
},
|
|
1453
|
+
secondBackground: function secondBackground(s) {
|
|
1454
|
+
return MaterialDynamicColors.primaryFixed;
|
|
1455
|
+
},
|
|
1456
|
+
contrastCurve: new ContrastCurve(3, 4.5, 7, 11)
|
|
1457
|
+
}), MaterialDynamicColors.secondaryFixed = DynamicColor.fromPalette({
|
|
1458
|
+
name: "secondary_fixed",
|
|
1459
|
+
palette: function palette(s) {
|
|
1460
|
+
return s.secondaryPalette;
|
|
1461
|
+
},
|
|
1462
|
+
tone: function tone(s) {
|
|
1463
|
+
return isMonochrome(s) ? 80 : 90;
|
|
1464
|
+
},
|
|
1465
|
+
isBackground: !0,
|
|
1466
|
+
background: function background(s) {
|
|
1467
|
+
return MaterialDynamicColors.highestSurface(s);
|
|
1468
|
+
},
|
|
1469
|
+
contrastCurve: new ContrastCurve(1, 1, 3, 7),
|
|
1470
|
+
toneDeltaPair: function toneDeltaPair(s) {
|
|
1471
|
+
return new ToneDeltaPair(MaterialDynamicColors.secondaryFixed, MaterialDynamicColors.secondaryFixedDim, 10, "lighter", !0);
|
|
1472
|
+
}
|
|
1473
|
+
}), MaterialDynamicColors.secondaryFixedDim = DynamicColor.fromPalette({
|
|
1474
|
+
name: "secondary_fixed_dim",
|
|
1475
|
+
palette: function palette(s) {
|
|
1476
|
+
return s.secondaryPalette;
|
|
1477
|
+
},
|
|
1478
|
+
tone: function tone(s) {
|
|
1479
|
+
return isMonochrome(s) ? 70 : 80;
|
|
1480
|
+
},
|
|
1481
|
+
isBackground: !0,
|
|
1482
|
+
background: function background(s) {
|
|
1483
|
+
return MaterialDynamicColors.highestSurface(s);
|
|
1484
|
+
},
|
|
1485
|
+
contrastCurve: new ContrastCurve(1, 1, 3, 7),
|
|
1486
|
+
toneDeltaPair: function toneDeltaPair(s) {
|
|
1487
|
+
return new ToneDeltaPair(MaterialDynamicColors.secondaryFixed, MaterialDynamicColors.secondaryFixedDim, 10, "lighter", !0);
|
|
1488
|
+
}
|
|
1489
|
+
}), MaterialDynamicColors.onSecondaryFixed = DynamicColor.fromPalette({
|
|
1490
|
+
name: "on_secondary_fixed",
|
|
1491
|
+
palette: function palette(s) {
|
|
1492
|
+
return s.secondaryPalette;
|
|
1493
|
+
},
|
|
1494
|
+
tone: function tone(s) {
|
|
1495
|
+
return 10;
|
|
1496
|
+
},
|
|
1497
|
+
background: function background(s) {
|
|
1498
|
+
return MaterialDynamicColors.secondaryFixedDim;
|
|
1499
|
+
},
|
|
1500
|
+
secondBackground: function secondBackground(s) {
|
|
1501
|
+
return MaterialDynamicColors.secondaryFixed;
|
|
1502
|
+
},
|
|
1503
|
+
contrastCurve: new ContrastCurve(4.5, 7, 11, 21)
|
|
1504
|
+
}), MaterialDynamicColors.onSecondaryFixedVariant = DynamicColor.fromPalette({
|
|
1505
|
+
name: "on_secondary_fixed_variant",
|
|
1506
|
+
palette: function palette(s) {
|
|
1507
|
+
return s.secondaryPalette;
|
|
1508
|
+
},
|
|
1509
|
+
tone: function tone(s) {
|
|
1510
|
+
return isMonochrome(s) ? 25 : 30;
|
|
1511
|
+
},
|
|
1512
|
+
background: function background(s) {
|
|
1513
|
+
return MaterialDynamicColors.secondaryFixedDim;
|
|
1514
|
+
},
|
|
1515
|
+
secondBackground: function secondBackground(s) {
|
|
1516
|
+
return MaterialDynamicColors.secondaryFixed;
|
|
1517
|
+
},
|
|
1518
|
+
contrastCurve: new ContrastCurve(3, 4.5, 7, 11)
|
|
1519
|
+
}), MaterialDynamicColors.tertiaryFixed = DynamicColor.fromPalette({
|
|
1520
|
+
name: "tertiary_fixed",
|
|
1521
|
+
palette: function palette(s) {
|
|
1522
|
+
return s.tertiaryPalette;
|
|
1523
|
+
},
|
|
1524
|
+
tone: function tone(s) {
|
|
1525
|
+
return isMonochrome(s) ? 40 : 90;
|
|
1526
|
+
},
|
|
1527
|
+
isBackground: !0,
|
|
1528
|
+
background: function background(s) {
|
|
1529
|
+
return MaterialDynamicColors.highestSurface(s);
|
|
1530
|
+
},
|
|
1531
|
+
contrastCurve: new ContrastCurve(1, 1, 3, 7),
|
|
1532
|
+
toneDeltaPair: function toneDeltaPair(s) {
|
|
1533
|
+
return new ToneDeltaPair(MaterialDynamicColors.tertiaryFixed, MaterialDynamicColors.tertiaryFixedDim, 10, "lighter", !0);
|
|
1534
|
+
}
|
|
1535
|
+
}), MaterialDynamicColors.tertiaryFixedDim = DynamicColor.fromPalette({
|
|
1536
|
+
name: "tertiary_fixed_dim",
|
|
1537
|
+
palette: function palette(s) {
|
|
1538
|
+
return s.tertiaryPalette;
|
|
1539
|
+
},
|
|
1540
|
+
tone: function tone(s) {
|
|
1541
|
+
return isMonochrome(s) ? 30 : 80;
|
|
1542
|
+
},
|
|
1543
|
+
isBackground: !0,
|
|
1544
|
+
background: function background(s) {
|
|
1545
|
+
return MaterialDynamicColors.highestSurface(s);
|
|
1546
|
+
},
|
|
1547
|
+
contrastCurve: new ContrastCurve(1, 1, 3, 7),
|
|
1548
|
+
toneDeltaPair: function toneDeltaPair(s) {
|
|
1549
|
+
return new ToneDeltaPair(MaterialDynamicColors.tertiaryFixed, MaterialDynamicColors.tertiaryFixedDim, 10, "lighter", !0);
|
|
1550
|
+
}
|
|
1551
|
+
}), MaterialDynamicColors.onTertiaryFixed = DynamicColor.fromPalette({
|
|
1552
|
+
name: "on_tertiary_fixed",
|
|
1553
|
+
palette: function palette(s) {
|
|
1554
|
+
return s.tertiaryPalette;
|
|
1555
|
+
},
|
|
1556
|
+
tone: function tone(s) {
|
|
1557
|
+
return isMonochrome(s) ? 100 : 10;
|
|
1558
|
+
},
|
|
1559
|
+
background: function background(s) {
|
|
1560
|
+
return MaterialDynamicColors.tertiaryFixedDim;
|
|
1561
|
+
},
|
|
1562
|
+
secondBackground: function secondBackground(s) {
|
|
1563
|
+
return MaterialDynamicColors.tertiaryFixed;
|
|
1564
|
+
},
|
|
1565
|
+
contrastCurve: new ContrastCurve(4.5, 7, 11, 21)
|
|
1566
|
+
}), MaterialDynamicColors.onTertiaryFixedVariant = DynamicColor.fromPalette({
|
|
1567
|
+
name: "on_tertiary_fixed_variant",
|
|
1568
|
+
palette: function palette(s) {
|
|
1569
|
+
return s.tertiaryPalette;
|
|
1570
|
+
},
|
|
1571
|
+
tone: function tone(s) {
|
|
1572
|
+
return isMonochrome(s) ? 90 : 30;
|
|
1573
|
+
},
|
|
1574
|
+
background: function background(s) {
|
|
1575
|
+
return MaterialDynamicColors.tertiaryFixedDim;
|
|
1576
|
+
},
|
|
1577
|
+
secondBackground: function secondBackground(s) {
|
|
1578
|
+
return MaterialDynamicColors.tertiaryFixed;
|
|
1579
|
+
},
|
|
1580
|
+
contrastCurve: new ContrastCurve(3, 4.5, 7, 11)
|
|
1581
|
+
});
|
|
648
1582
|
var TonalPalette = function () {
|
|
649
1583
|
TonalPalette.fromInt = function fromInt(argb) {
|
|
650
1584
|
var hct = Hct.fromInt(argb);
|
|
651
|
-
return TonalPalette.
|
|
1585
|
+
return TonalPalette.fromHct(hct);
|
|
1586
|
+
};
|
|
1587
|
+
TonalPalette.fromHct = function fromHct(hct) {
|
|
1588
|
+
return new TonalPalette(hct.hue, hct.chroma, hct);
|
|
652
1589
|
};
|
|
653
1590
|
TonalPalette.fromHueAndChroma = function fromHueAndChroma(hue, chroma) {
|
|
654
|
-
return new TonalPalette(hue, chroma);
|
|
1591
|
+
return new TonalPalette(hue, chroma, TonalPalette.createKeyColor(hue, chroma));
|
|
655
1592
|
};
|
|
656
|
-
function TonalPalette(hue, chroma) {
|
|
657
|
-
this.hue = hue, this.chroma = chroma, this.cache = new Map();
|
|
1593
|
+
function TonalPalette(hue, chroma, keyColor) {
|
|
1594
|
+
this.hue = hue, this.chroma = chroma, this.keyColor = keyColor, this.cache = new Map();
|
|
658
1595
|
}
|
|
659
|
-
|
|
660
|
-
|
|
1596
|
+
TonalPalette.createKeyColor = function createKeyColor(hue, chroma) {
|
|
1597
|
+
var smallestDeltaHct = Hct.from(hue, chroma, 50),
|
|
1598
|
+
smallestDelta = Math.abs(smallestDeltaHct.chroma - chroma);
|
|
1599
|
+
for (var delta = 1; delta < 50; delta += 1) {
|
|
1600
|
+
if (Math.round(chroma) === Math.round(smallestDeltaHct.chroma)) return smallestDeltaHct;
|
|
1601
|
+
var hctAdd = Hct.from(hue, chroma, 50 + delta),
|
|
1602
|
+
hctAddDelta = Math.abs(hctAdd.chroma - chroma);
|
|
1603
|
+
hctAddDelta < smallestDelta && (smallestDelta = hctAddDelta, smallestDeltaHct = hctAdd);
|
|
1604
|
+
var hctSubtract = Hct.from(hue, chroma, 50 - delta),
|
|
1605
|
+
hctSubtractDelta = Math.abs(hctSubtract.chroma - chroma);
|
|
1606
|
+
hctSubtractDelta < smallestDelta && (smallestDelta = hctSubtractDelta, smallestDeltaHct = hctSubtract);
|
|
1607
|
+
}
|
|
1608
|
+
return smallestDeltaHct;
|
|
1609
|
+
};
|
|
1610
|
+
var _proto5 = TonalPalette.prototype;
|
|
1611
|
+
_proto5.tone = function tone(_tone) {
|
|
661
1612
|
var argb = this.cache.get(_tone);
|
|
662
1613
|
return void 0 === argb && (argb = Hct.from(this.hue, this.chroma, _tone).toInt(), this.cache.set(_tone, argb)), argb;
|
|
663
1614
|
};
|
|
1615
|
+
_proto5.getHct = function getHct(tone) {
|
|
1616
|
+
return Hct.fromInt(this.tone(tone));
|
|
1617
|
+
};
|
|
664
1618
|
return TonalPalette;
|
|
665
1619
|
}();
|
|
666
1620
|
var CorePalette = function () {
|
|
@@ -790,8 +1744,8 @@
|
|
|
790
1744
|
function Scheme(props) {
|
|
791
1745
|
this.props = props;
|
|
792
1746
|
}
|
|
793
|
-
var
|
|
794
|
-
|
|
1747
|
+
var _proto6 = Scheme.prototype;
|
|
1748
|
+
_proto6.toJSON = function toJSON() {
|
|
795
1749
|
return _extends({}, this.props);
|
|
796
1750
|
};
|
|
797
1751
|
_createClass(Scheme, [{
|
|
@@ -1649,6 +2603,10 @@
|
|
|
1649
2603
|
this.emit('local::back', view, param);
|
|
1650
2604
|
this.emit('pageBack', this);
|
|
1651
2605
|
};
|
|
2606
|
+
_proto.change = function change(view) {
|
|
2607
|
+
this.emit('local::change', view);
|
|
2608
|
+
this.emit('pageChange', this);
|
|
2609
|
+
};
|
|
1652
2610
|
_proto.hide = function hide(view) {
|
|
1653
2611
|
this.emit('local::hide', view);
|
|
1654
2612
|
this.emit('pageHide', this);
|
|
@@ -1721,8 +2679,15 @@
|
|
|
1721
2679
|
});
|
|
1722
2680
|
}
|
|
1723
2681
|
if (module.on && instance.on) {
|
|
1724
|
-
Object.keys(module.on).forEach(function (
|
|
1725
|
-
|
|
2682
|
+
Object.keys(module.on).forEach(function (eventName) {
|
|
2683
|
+
var fn = function fn() {
|
|
2684
|
+
try {
|
|
2685
|
+
module.on[eventName]();
|
|
2686
|
+
} catch (e) {
|
|
2687
|
+
console.log(moduleName + ".on" + eventName + " exp:" + e.message);
|
|
2688
|
+
}
|
|
2689
|
+
};
|
|
2690
|
+
instance.on(eventName, fn);
|
|
1726
2691
|
});
|
|
1727
2692
|
}
|
|
1728
2693
|
if (module.vnode) {
|
|
@@ -2884,7 +3849,7 @@
|
|
|
2884
3849
|
var app = this;
|
|
2885
3850
|
if (!app.colorsStyleEl) {
|
|
2886
3851
|
app.colorsStyleEl = document.createElement('style');
|
|
2887
|
-
document.head.
|
|
3852
|
+
document.head.prepend(app.colorsStyleEl);
|
|
2888
3853
|
}
|
|
2889
3854
|
app.colorsStyleEl.textContent = colorThemeCSSStyles(app.colors);
|
|
2890
3855
|
};
|
|
@@ -2954,8 +3919,8 @@
|
|
|
2954
3919
|
var app = this;
|
|
2955
3920
|
var html = document.querySelector('html');
|
|
2956
3921
|
if (app.mq.dark && app.mq.light) {
|
|
2957
|
-
app.mq.dark.
|
|
2958
|
-
app.mq.light.
|
|
3922
|
+
app.mq.dark.addEventListener('change', app.colorSchemeListener);
|
|
3923
|
+
app.mq.light.addEventListener('change', app.colorSchemeListener);
|
|
2959
3924
|
}
|
|
2960
3925
|
if (app.mq.dark && app.mq.dark.matches) {
|
|
2961
3926
|
html.classList.add('dark');
|
|
@@ -2970,8 +3935,8 @@
|
|
|
2970
3935
|
_proto.disableAutoDarkTheme = function disableAutoDarkTheme() {
|
|
2971
3936
|
if (!window.matchMedia) return;
|
|
2972
3937
|
var app = this;
|
|
2973
|
-
if (app.mq.dark) app.mq.dark.
|
|
2974
|
-
if (app.mq.light) app.mq.light.
|
|
3938
|
+
if (app.mq.dark) app.mq.dark.removeEventListener('change', app.colorSchemeListener);
|
|
3939
|
+
if (app.mq.light) app.mq.light.removeEventListener('change', app.colorSchemeListener);
|
|
2975
3940
|
};
|
|
2976
3941
|
_proto.setDarkMode = function setDarkMode(mode) {
|
|
2977
3942
|
var app = this;
|