@wiajs/core 1.0.10 → 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} +1151 -29
- package/dist/core.js +1441 -18
- package/dist/core.min.js +5 -5
- package/dist/{core.esm.js → core.mjs} +1151 -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) {
|
|
@@ -2206,6 +3171,464 @@
|
|
|
2206
3171
|
}
|
|
2207
3172
|
};
|
|
2208
3173
|
|
|
3174
|
+
var extend$1 = Utils.extend;
|
|
3175
|
+
var _$$1 = $,
|
|
3176
|
+
device$1 = _$$1.device,
|
|
3177
|
+
support$1 = _$$1.support;
|
|
3178
|
+
function initTouch() {
|
|
3179
|
+
var app = this;
|
|
3180
|
+
var params = app.params.touch;
|
|
3181
|
+
var useRipple = params[app.theme + "TouchRipple"];
|
|
3182
|
+
if (device$1.ios && device$1.webView) {
|
|
3183
|
+
window.addEventListener('touchstart', function () {});
|
|
3184
|
+
}
|
|
3185
|
+
var touchStartX;
|
|
3186
|
+
var touchStartY;
|
|
3187
|
+
var targetElement;
|
|
3188
|
+
var isMoved;
|
|
3189
|
+
var tapHoldFired;
|
|
3190
|
+
var tapHoldTimeout;
|
|
3191
|
+
var preventClick;
|
|
3192
|
+
var activableElement;
|
|
3193
|
+
var activeTimeout;
|
|
3194
|
+
var rippleWave;
|
|
3195
|
+
var rippleTarget;
|
|
3196
|
+
var rippleTimeout;
|
|
3197
|
+
function findActivableElement(el) {
|
|
3198
|
+
var target = $(el);
|
|
3199
|
+
var parents = target.parents(params.activeStateElements);
|
|
3200
|
+
if (target.closest('.no-active-state').length) {
|
|
3201
|
+
return null;
|
|
3202
|
+
}
|
|
3203
|
+
var activable;
|
|
3204
|
+
if (target.is(params.activeStateElements)) {
|
|
3205
|
+
activable = target;
|
|
3206
|
+
}
|
|
3207
|
+
if (parents.length > 0) {
|
|
3208
|
+
activable = activable ? activable.add(parents) : parents;
|
|
3209
|
+
}
|
|
3210
|
+
if (activable && activable.length > 1) {
|
|
3211
|
+
var newActivable = [];
|
|
3212
|
+
var preventPropagation;
|
|
3213
|
+
for (var i = 0; i < activable.length; i += 1) {
|
|
3214
|
+
if (!preventPropagation) {
|
|
3215
|
+
newActivable.push(activable[i]);
|
|
3216
|
+
if (activable.eq(i).hasClass('prevent-active-state-propagation') || activable.eq(i).hasClass('no-active-state-propagation')) {
|
|
3217
|
+
preventPropagation = true;
|
|
3218
|
+
}
|
|
3219
|
+
}
|
|
3220
|
+
}
|
|
3221
|
+
activable = $(newActivable);
|
|
3222
|
+
}
|
|
3223
|
+
return activable || target;
|
|
3224
|
+
}
|
|
3225
|
+
function isInsideScrollableView(el) {
|
|
3226
|
+
var pageContent = el.parents('.page-content');
|
|
3227
|
+
return pageContent.length > 0;
|
|
3228
|
+
}
|
|
3229
|
+
function addActive() {
|
|
3230
|
+
if (!activableElement) return;
|
|
3231
|
+
activableElement.addClass('active-state');
|
|
3232
|
+
}
|
|
3233
|
+
function removeActive() {
|
|
3234
|
+
if (!activableElement) return;
|
|
3235
|
+
activableElement.removeClass('active-state');
|
|
3236
|
+
activableElement = null;
|
|
3237
|
+
}
|
|
3238
|
+
function findRippleElement(el) {
|
|
3239
|
+
var rippleElements = params.touchRippleElements;
|
|
3240
|
+
var $el = $(el);
|
|
3241
|
+
if ($el.is(rippleElements)) {
|
|
3242
|
+
if ($el.hasClass('no-ripple')) {
|
|
3243
|
+
return false;
|
|
3244
|
+
}
|
|
3245
|
+
return $el;
|
|
3246
|
+
}
|
|
3247
|
+
if ($el.parents(rippleElements).length > 0) {
|
|
3248
|
+
var rippleParent = $el.parents(rippleElements).eq(0);
|
|
3249
|
+
if (rippleParent.hasClass('no-ripple')) {
|
|
3250
|
+
return false;
|
|
3251
|
+
}
|
|
3252
|
+
return rippleParent;
|
|
3253
|
+
}
|
|
3254
|
+
return false;
|
|
3255
|
+
}
|
|
3256
|
+
function createRipple($el, x, y) {
|
|
3257
|
+
if (!$el) return;
|
|
3258
|
+
rippleWave = app.touchRipple.create(app, $el, x, y);
|
|
3259
|
+
}
|
|
3260
|
+
function removeRipple() {
|
|
3261
|
+
if (!rippleWave) return;
|
|
3262
|
+
rippleWave.remove();
|
|
3263
|
+
rippleWave = undefined;
|
|
3264
|
+
rippleTarget = undefined;
|
|
3265
|
+
}
|
|
3266
|
+
function rippleTouchStart(el) {
|
|
3267
|
+
rippleTarget = findRippleElement(el);
|
|
3268
|
+
if (!rippleTarget || rippleTarget.length === 0) {
|
|
3269
|
+
rippleTarget = undefined;
|
|
3270
|
+
return;
|
|
3271
|
+
}
|
|
3272
|
+
var inScrollable = isInsideScrollableView(rippleTarget);
|
|
3273
|
+
if (!inScrollable) {
|
|
3274
|
+
removeRipple();
|
|
3275
|
+
createRipple(rippleTarget, touchStartX, touchStartY);
|
|
3276
|
+
} else {
|
|
3277
|
+
clearTimeout(rippleTimeout);
|
|
3278
|
+
rippleTimeout = setTimeout(function () {
|
|
3279
|
+
removeRipple();
|
|
3280
|
+
createRipple(rippleTarget, touchStartX, touchStartY);
|
|
3281
|
+
}, 80);
|
|
3282
|
+
}
|
|
3283
|
+
}
|
|
3284
|
+
function rippleTouchMove() {
|
|
3285
|
+
clearTimeout(rippleTimeout);
|
|
3286
|
+
removeRipple();
|
|
3287
|
+
}
|
|
3288
|
+
function rippleTouchEnd() {
|
|
3289
|
+
if (!rippleWave && rippleTarget && !isMoved) {
|
|
3290
|
+
clearTimeout(rippleTimeout);
|
|
3291
|
+
createRipple(rippleTarget, touchStartX, touchStartY);
|
|
3292
|
+
setTimeout(removeRipple, 0);
|
|
3293
|
+
} else {
|
|
3294
|
+
removeRipple();
|
|
3295
|
+
}
|
|
3296
|
+
}
|
|
3297
|
+
function handleMouseDown(e) {
|
|
3298
|
+
var $activableEl = findActivableElement(e.target);
|
|
3299
|
+
if ($activableEl) {
|
|
3300
|
+
$activableEl.addClass('active-state');
|
|
3301
|
+
if ('which' in e && e.which === 3) {
|
|
3302
|
+
setTimeout(function () {
|
|
3303
|
+
$('.active-state').removeClass('active-state');
|
|
3304
|
+
}, 0);
|
|
3305
|
+
}
|
|
3306
|
+
}
|
|
3307
|
+
if (useRipple) {
|
|
3308
|
+
touchStartX = e.pageX;
|
|
3309
|
+
touchStartY = e.pageY;
|
|
3310
|
+
rippleTouchStart(e.target, e.pageX, e.pageY);
|
|
3311
|
+
}
|
|
3312
|
+
}
|
|
3313
|
+
function handleMouseMove() {
|
|
3314
|
+
if (!params.activeStateOnMouseMove) {
|
|
3315
|
+
$('.active-state').removeClass('active-state');
|
|
3316
|
+
}
|
|
3317
|
+
if (useRipple) {
|
|
3318
|
+
rippleTouchMove();
|
|
3319
|
+
}
|
|
3320
|
+
}
|
|
3321
|
+
function handleMouseUp() {
|
|
3322
|
+
$('.active-state').removeClass('active-state');
|
|
3323
|
+
if (useRipple) {
|
|
3324
|
+
rippleTouchEnd();
|
|
3325
|
+
}
|
|
3326
|
+
}
|
|
3327
|
+
function handleTouchCancel() {
|
|
3328
|
+
targetElement = null;
|
|
3329
|
+
clearTimeout(activeTimeout);
|
|
3330
|
+
clearTimeout(tapHoldTimeout);
|
|
3331
|
+
if (params.activeState) {
|
|
3332
|
+
removeActive();
|
|
3333
|
+
}
|
|
3334
|
+
if (useRipple) {
|
|
3335
|
+
rippleTouchEnd();
|
|
3336
|
+
}
|
|
3337
|
+
}
|
|
3338
|
+
var isScrolling;
|
|
3339
|
+
var isSegmentedStrong = false;
|
|
3340
|
+
var segmentedStrongEl = null;
|
|
3341
|
+
var touchMoveActivableIos = '.dialog-button, .actions-button';
|
|
3342
|
+
var isTouchMoveActivable = false;
|
|
3343
|
+
var touchmoveActivableEl = null;
|
|
3344
|
+
function handleTouchStart(e) {
|
|
3345
|
+
if (!e.isTrusted) return true;
|
|
3346
|
+
isMoved = false;
|
|
3347
|
+
tapHoldFired = false;
|
|
3348
|
+
preventClick = false;
|
|
3349
|
+
isScrolling = undefined;
|
|
3350
|
+
if (e.targetTouches.length > 1) {
|
|
3351
|
+
if (activableElement) removeActive();
|
|
3352
|
+
return true;
|
|
3353
|
+
}
|
|
3354
|
+
if (e.touches.length > 1 && activableElement) {
|
|
3355
|
+
removeActive();
|
|
3356
|
+
}
|
|
3357
|
+
if (params.tapHold) {
|
|
3358
|
+
if (tapHoldTimeout) clearTimeout(tapHoldTimeout);
|
|
3359
|
+
tapHoldTimeout = setTimeout(function () {
|
|
3360
|
+
if (e && e.touches && e.touches.length > 1) return;
|
|
3361
|
+
tapHoldFired = true;
|
|
3362
|
+
e.preventDefault();
|
|
3363
|
+
preventClick = true;
|
|
3364
|
+
$(e.target).trigger('taphold', e);
|
|
3365
|
+
app.emit('taphold', e);
|
|
3366
|
+
}, params.tapHoldDelay);
|
|
3367
|
+
}
|
|
3368
|
+
targetElement = e.target;
|
|
3369
|
+
touchStartX = e.targetTouches[0].pageX;
|
|
3370
|
+
touchStartY = e.targetTouches[0].pageY;
|
|
3371
|
+
isSegmentedStrong = e.target.closest('.segmented-strong .button-active, .segmented-strong .tab-link-active');
|
|
3372
|
+
isTouchMoveActivable = app.theme === 'ios' && e.target.closest(touchMoveActivableIos);
|
|
3373
|
+
if (isSegmentedStrong) {
|
|
3374
|
+
segmentedStrongEl = isSegmentedStrong.closest('.segmented-strong');
|
|
3375
|
+
}
|
|
3376
|
+
if (params.activeState) {
|
|
3377
|
+
activableElement = findActivableElement(targetElement);
|
|
3378
|
+
if (activableElement && !isInsideScrollableView(activableElement)) {
|
|
3379
|
+
addActive();
|
|
3380
|
+
} else if (activableElement) {
|
|
3381
|
+
activeTimeout = setTimeout(addActive, 80);
|
|
3382
|
+
}
|
|
3383
|
+
}
|
|
3384
|
+
if (useRipple) {
|
|
3385
|
+
rippleTouchStart(targetElement);
|
|
3386
|
+
}
|
|
3387
|
+
return true;
|
|
3388
|
+
}
|
|
3389
|
+
function handleTouchMove(e) {
|
|
3390
|
+
if (!e.isTrusted) return;
|
|
3391
|
+
var touch;
|
|
3392
|
+
var distance;
|
|
3393
|
+
var shouldRemoveActive = true;
|
|
3394
|
+
if (e.type === 'touchmove') {
|
|
3395
|
+
touch = e.targetTouches[0];
|
|
3396
|
+
distance = params.touchClicksDistanceThreshold;
|
|
3397
|
+
}
|
|
3398
|
+
var touchCurrentX = e.targetTouches[0].pageX;
|
|
3399
|
+
var touchCurrentY = e.targetTouches[0].pageY;
|
|
3400
|
+
if (typeof isScrolling === 'undefined') {
|
|
3401
|
+
isScrolling = !!(isScrolling || Math.abs(touchCurrentY - touchStartY) > Math.abs(touchCurrentX - touchStartX));
|
|
3402
|
+
}
|
|
3403
|
+
if (isTouchMoveActivable || !isScrolling && isSegmentedStrong && segmentedStrongEl) {
|
|
3404
|
+
if (e.cancelable) e.preventDefault();
|
|
3405
|
+
}
|
|
3406
|
+
if (!isScrolling && isSegmentedStrong && segmentedStrongEl) {
|
|
3407
|
+
var elementFromPoint = document.elementFromPoint(e.targetTouches[0].clientX, e.targetTouches[0].clientY);
|
|
3408
|
+
var buttonEl = elementFromPoint.closest('.segmented-strong .button:not(.button-active):not(.tab-link-active)');
|
|
3409
|
+
if (buttonEl && segmentedStrongEl.contains(buttonEl)) {
|
|
3410
|
+
$(buttonEl).trigger('click', 'f7Segmented');
|
|
3411
|
+
targetElement = buttonEl;
|
|
3412
|
+
}
|
|
3413
|
+
}
|
|
3414
|
+
if (distance && touch) {
|
|
3415
|
+
var _touch = touch,
|
|
3416
|
+
pageX = _touch.pageX,
|
|
3417
|
+
pageY = _touch.pageY;
|
|
3418
|
+
if (Math.abs(pageX - touchStartX) > distance || Math.abs(pageY - touchStartY) > distance) {
|
|
3419
|
+
isMoved = true;
|
|
3420
|
+
}
|
|
3421
|
+
} else {
|
|
3422
|
+
isMoved = true;
|
|
3423
|
+
}
|
|
3424
|
+
if (isMoved) {
|
|
3425
|
+
preventClick = true;
|
|
3426
|
+
if (isTouchMoveActivable) {
|
|
3427
|
+
var _elementFromPoint = document.elementFromPoint(e.targetTouches[0].clientX, e.targetTouches[0].clientY);
|
|
3428
|
+
touchmoveActivableEl = _elementFromPoint.closest(touchMoveActivableIos);
|
|
3429
|
+
if (touchmoveActivableEl && activableElement && activableElement[0] === touchmoveActivableEl) {
|
|
3430
|
+
shouldRemoveActive = false;
|
|
3431
|
+
} else if (touchmoveActivableEl) {
|
|
3432
|
+
setTimeout(function () {
|
|
3433
|
+
activableElement = findActivableElement(touchmoveActivableEl);
|
|
3434
|
+
addActive();
|
|
3435
|
+
});
|
|
3436
|
+
}
|
|
3437
|
+
}
|
|
3438
|
+
if (params.tapHold) {
|
|
3439
|
+
clearTimeout(tapHoldTimeout);
|
|
3440
|
+
}
|
|
3441
|
+
if (params.activeState && shouldRemoveActive) {
|
|
3442
|
+
clearTimeout(activeTimeout);
|
|
3443
|
+
removeActive();
|
|
3444
|
+
}
|
|
3445
|
+
if (useRipple) {
|
|
3446
|
+
rippleTouchMove();
|
|
3447
|
+
}
|
|
3448
|
+
}
|
|
3449
|
+
}
|
|
3450
|
+
function handleTouchEnd(e) {
|
|
3451
|
+
if (!e.isTrusted) return true;
|
|
3452
|
+
isScrolling = undefined;
|
|
3453
|
+
isSegmentedStrong = false;
|
|
3454
|
+
segmentedStrongEl = null;
|
|
3455
|
+
isTouchMoveActivable = false;
|
|
3456
|
+
clearTimeout(activeTimeout);
|
|
3457
|
+
clearTimeout(tapHoldTimeout);
|
|
3458
|
+
if (touchmoveActivableEl) {
|
|
3459
|
+
$(touchmoveActivableEl).trigger('click', 'f7TouchMoveActivable');
|
|
3460
|
+
touchmoveActivableEl = null;
|
|
3461
|
+
}
|
|
3462
|
+
if (document.activeElement === e.target) {
|
|
3463
|
+
if (params.activeState) removeActive();
|
|
3464
|
+
if (useRipple) {
|
|
3465
|
+
rippleTouchEnd();
|
|
3466
|
+
}
|
|
3467
|
+
return true;
|
|
3468
|
+
}
|
|
3469
|
+
if (params.activeState) {
|
|
3470
|
+
addActive();
|
|
3471
|
+
setTimeout(removeActive, 0);
|
|
3472
|
+
}
|
|
3473
|
+
if (useRipple) {
|
|
3474
|
+
rippleTouchEnd();
|
|
3475
|
+
}
|
|
3476
|
+
if (params.tapHoldPreventClicks && tapHoldFired || preventClick) {
|
|
3477
|
+
if (e.cancelable) e.preventDefault();
|
|
3478
|
+
preventClick = true;
|
|
3479
|
+
return false;
|
|
3480
|
+
}
|
|
3481
|
+
return true;
|
|
3482
|
+
}
|
|
3483
|
+
function handleClick(e) {
|
|
3484
|
+
var isOverswipe = e && e.detail && e.detail === 'f7Overswipe';
|
|
3485
|
+
var isSegmented = e && e.detail && e.detail === 'f7Segmented';
|
|
3486
|
+
var isTouchMoveActivable = e && e.detail && e.detail === 'f7TouchMoveActivable';
|
|
3487
|
+
var localPreventClick = preventClick;
|
|
3488
|
+
if (targetElement && e.target !== targetElement) {
|
|
3489
|
+
if (isOverswipe || isSegmented || isTouchMoveActivable) {
|
|
3490
|
+
localPreventClick = false;
|
|
3491
|
+
} else {
|
|
3492
|
+
localPreventClick = true;
|
|
3493
|
+
}
|
|
3494
|
+
} else if (isTouchMoveActivable) {
|
|
3495
|
+
localPreventClick = false;
|
|
3496
|
+
}
|
|
3497
|
+
if (params.tapHold && params.tapHoldPreventClicks && tapHoldFired) {
|
|
3498
|
+
localPreventClick = true;
|
|
3499
|
+
}
|
|
3500
|
+
if (localPreventClick) {
|
|
3501
|
+
e.stopImmediatePropagation();
|
|
3502
|
+
e.stopPropagation();
|
|
3503
|
+
e.preventDefault();
|
|
3504
|
+
}
|
|
3505
|
+
if (params.tapHold) {
|
|
3506
|
+
tapHoldTimeout = setTimeout(function () {
|
|
3507
|
+
tapHoldFired = false;
|
|
3508
|
+
}, device$1.ios || device$1.androidChrome ? 100 : 400);
|
|
3509
|
+
}
|
|
3510
|
+
preventClick = false;
|
|
3511
|
+
targetElement = null;
|
|
3512
|
+
return !localPreventClick;
|
|
3513
|
+
}
|
|
3514
|
+
function emitAppTouchEvent(name, e) {
|
|
3515
|
+
app.emit({
|
|
3516
|
+
events: name,
|
|
3517
|
+
data: [e]
|
|
3518
|
+
});
|
|
3519
|
+
}
|
|
3520
|
+
function appTouchStartActive(e) {
|
|
3521
|
+
emitAppTouchEvent('touchstart touchstart:active', e);
|
|
3522
|
+
}
|
|
3523
|
+
function appTouchMoveActive(e) {
|
|
3524
|
+
emitAppTouchEvent('touchmove touchmove:active', e);
|
|
3525
|
+
}
|
|
3526
|
+
function appTouchEndActive(e) {
|
|
3527
|
+
emitAppTouchEvent('touchend touchend:active', e);
|
|
3528
|
+
}
|
|
3529
|
+
function appTouchStartPassive(e) {
|
|
3530
|
+
emitAppTouchEvent('touchstart:passive', e);
|
|
3531
|
+
}
|
|
3532
|
+
function appTouchMovePassive(e) {
|
|
3533
|
+
emitAppTouchEvent('touchmove:passive', e);
|
|
3534
|
+
}
|
|
3535
|
+
function appTouchEndPassive(e) {
|
|
3536
|
+
emitAppTouchEvent('touchend:passive', e);
|
|
3537
|
+
}
|
|
3538
|
+
var passiveListener = support$1.passiveListener ? {
|
|
3539
|
+
passive: true
|
|
3540
|
+
} : false;
|
|
3541
|
+
var passiveListenerCapture = support$1.passiveListener ? {
|
|
3542
|
+
passive: true,
|
|
3543
|
+
capture: true
|
|
3544
|
+
} : true;
|
|
3545
|
+
var activeListener = support$1.passiveListener ? {
|
|
3546
|
+
passive: false
|
|
3547
|
+
} : false;
|
|
3548
|
+
var activeListenerCapture = support$1.passiveListener ? {
|
|
3549
|
+
passive: false,
|
|
3550
|
+
capture: true
|
|
3551
|
+
} : true;
|
|
3552
|
+
if (support$1.passiveListener) {
|
|
3553
|
+
document.addEventListener(app.touchEvents.start, appTouchStartActive, activeListenerCapture);
|
|
3554
|
+
document.addEventListener(app.touchEvents.move, appTouchMoveActive, activeListener);
|
|
3555
|
+
document.addEventListener(app.touchEvents.end, appTouchEndActive, activeListener);
|
|
3556
|
+
document.addEventListener(app.touchEvents.start, appTouchStartPassive, passiveListenerCapture);
|
|
3557
|
+
document.addEventListener(app.touchEvents.move, appTouchMovePassive, passiveListener);
|
|
3558
|
+
document.addEventListener(app.touchEvents.end, appTouchEndPassive, passiveListener);
|
|
3559
|
+
} else {
|
|
3560
|
+
document.addEventListener(app.touchEvents.start, function (e) {
|
|
3561
|
+
appTouchStartActive(e);
|
|
3562
|
+
appTouchStartPassive(e);
|
|
3563
|
+
}, true);
|
|
3564
|
+
document.addEventListener(app.touchEvents.move, function (e) {
|
|
3565
|
+
appTouchMoveActive(e);
|
|
3566
|
+
appTouchMovePassive(e);
|
|
3567
|
+
}, false);
|
|
3568
|
+
document.addEventListener(app.touchEvents.end, function (e) {
|
|
3569
|
+
appTouchEndActive(e);
|
|
3570
|
+
appTouchEndPassive(e);
|
|
3571
|
+
}, false);
|
|
3572
|
+
}
|
|
3573
|
+
if (support$1.touch) {
|
|
3574
|
+
app.on('click', handleClick);
|
|
3575
|
+
app.on('touchstart', handleTouchStart);
|
|
3576
|
+
app.on('touchmove', handleTouchMove);
|
|
3577
|
+
app.on('touchend', handleTouchEnd);
|
|
3578
|
+
document.addEventListener('touchcancel', handleTouchCancel, {
|
|
3579
|
+
passive: true
|
|
3580
|
+
});
|
|
3581
|
+
} else if (params.activeState) {
|
|
3582
|
+
app.on('touchstart', handleMouseDown);
|
|
3583
|
+
app.on('touchmove', handleMouseMove);
|
|
3584
|
+
app.on('touchend', handleMouseUp);
|
|
3585
|
+
document.addEventListener('pointercancel', handleMouseUp, {
|
|
3586
|
+
passive: true
|
|
3587
|
+
});
|
|
3588
|
+
}
|
|
3589
|
+
document.addEventListener('contextmenu', function (e) {
|
|
3590
|
+
if (params.disableContextMenu && (device$1.ios || device$1.android || device$1.cordova || window.Capacitor && window.Capacitor.isNative)) {
|
|
3591
|
+
e.preventDefault();
|
|
3592
|
+
}
|
|
3593
|
+
if (useRipple) {
|
|
3594
|
+
if (activableElement) removeActive();
|
|
3595
|
+
rippleTouchEnd();
|
|
3596
|
+
}
|
|
3597
|
+
});
|
|
3598
|
+
}
|
|
3599
|
+
var Touch = {
|
|
3600
|
+
name: 'touch',
|
|
3601
|
+
params: {
|
|
3602
|
+
touch: {
|
|
3603
|
+
touchClicksDistanceThreshold: 5,
|
|
3604
|
+
disableContextMenu: false,
|
|
3605
|
+
tapHold: false,
|
|
3606
|
+
tapHoldDelay: 750,
|
|
3607
|
+
tapHoldPreventClicks: true,
|
|
3608
|
+
activeState: true,
|
|
3609
|
+
activeStateElements: 'a, button, label, span, .actions-button, .stepper-button, .stepper-button-plus, .stepper-button-minus, .card-expandable, .link, .item-link, .accordion-item-toggle',
|
|
3610
|
+
activeStateOnMouseMove: false,
|
|
3611
|
+
mdTouchRipple: true,
|
|
3612
|
+
iosTouchRipple: false,
|
|
3613
|
+
touchRippleElements: '.ripple, .link, .item-link, .list label.item-content, .list-button, .links-list a, .button, button, .input-clear-button, .dialog-button, .tab-link, .item-radio, .item-checkbox, .actions-button, .searchbar-disable-button, .fab a, .checkbox, .radio, .data-table .sortable-cell:not(.input-cell), .notification-close-button, .stepper-button, .stepper-button-minus, .stepper-button-plus, .list.accordion-list .accordion-item-toggle',
|
|
3614
|
+
touchRippleInsetElements: '.ripple-inset, .icon-only, .searchbar-disable-button, .input-clear-button, .notification-close-button, .md .navbar .link.back'
|
|
3615
|
+
}
|
|
3616
|
+
},
|
|
3617
|
+
create: function create() {
|
|
3618
|
+
var app = this;
|
|
3619
|
+
extend$1(app, {
|
|
3620
|
+
touchEvents: {
|
|
3621
|
+
start: support$1.touch ? 'touchstart' : support$1.pointerEvents ? 'pointerdown' : 'mousedown',
|
|
3622
|
+
move: support$1.touch ? 'touchmove' : support$1.pointerEvents ? 'pointermove' : 'mousemove',
|
|
3623
|
+
end: support$1.touch ? 'touchend' : support$1.pointerEvents ? 'pointerup' : 'mouseup'
|
|
3624
|
+
}
|
|
3625
|
+
});
|
|
3626
|
+
},
|
|
3627
|
+
on: {
|
|
3628
|
+
init: initTouch
|
|
3629
|
+
}
|
|
3630
|
+
};
|
|
3631
|
+
|
|
2209
3632
|
var SW = {
|
|
2210
3633
|
registrations: [],
|
|
2211
3634
|
register: function register(path, scope) {
|
|
@@ -2426,7 +3849,7 @@
|
|
|
2426
3849
|
var app = this;
|
|
2427
3850
|
if (!app.colorsStyleEl) {
|
|
2428
3851
|
app.colorsStyleEl = document.createElement('style');
|
|
2429
|
-
document.head.
|
|
3852
|
+
document.head.prepend(app.colorsStyleEl);
|
|
2430
3853
|
}
|
|
2431
3854
|
app.colorsStyleEl.textContent = colorThemeCSSStyles(app.colors);
|
|
2432
3855
|
};
|
|
@@ -2496,8 +3919,8 @@
|
|
|
2496
3919
|
var app = this;
|
|
2497
3920
|
var html = document.querySelector('html');
|
|
2498
3921
|
if (app.mq.dark && app.mq.light) {
|
|
2499
|
-
app.mq.dark.
|
|
2500
|
-
app.mq.light.
|
|
3922
|
+
app.mq.dark.addEventListener('change', app.colorSchemeListener);
|
|
3923
|
+
app.mq.light.addEventListener('change', app.colorSchemeListener);
|
|
2501
3924
|
}
|
|
2502
3925
|
if (app.mq.dark && app.mq.dark.matches) {
|
|
2503
3926
|
html.classList.add('dark');
|
|
@@ -2512,8 +3935,8 @@
|
|
|
2512
3935
|
_proto.disableAutoDarkTheme = function disableAutoDarkTheme() {
|
|
2513
3936
|
if (!window.matchMedia) return;
|
|
2514
3937
|
var app = this;
|
|
2515
|
-
if (app.mq.dark) app.mq.dark.
|
|
2516
|
-
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);
|
|
2517
3940
|
};
|
|
2518
3941
|
_proto.setDarkMode = function setDarkMode(mode) {
|
|
2519
3942
|
var app = this;
|
|
@@ -2675,7 +4098,7 @@
|
|
|
2675
4098
|
App.support = support;
|
|
2676
4099
|
App.device = device;
|
|
2677
4100
|
App.utils = Utils;
|
|
2678
|
-
App.use([Resize, Click, SW$1]);
|
|
4101
|
+
App.use([Resize, Click, Touch, SW$1]);
|
|
2679
4102
|
|
|
2680
4103
|
var _opts = {
|
|
2681
4104
|
normal: 'nor',
|