framer-motion 7.0.1 → 7.0.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/dist/cjs/index.js +2 -2
- package/dist/es/render/utils/motion-values.mjs +1 -1
- package/dist/es/value/index.mjs +1 -1
- package/dist/framer-motion.dev.js +104 -281
- package/dist/framer-motion.js +1 -1
- package/dist/projection.dev.js +115 -292
- package/dist/size-rollup-dom-animation.js +1 -1
- package/dist/size-rollup-dom-max.js +1 -1
- package/dist/size-webpack-dom-animation.js +1 -1
- package/dist/size-webpack-dom-max.js +1 -1
- package/dist/size-webpack-m.js +1 -1
- package/package.json +7 -9
package/dist/projection.dev.js
CHANGED
|
@@ -206,7 +206,7 @@
|
|
|
206
206
|
};
|
|
207
207
|
}
|
|
208
208
|
|
|
209
|
-
const clamp$
|
|
209
|
+
const clamp$1 = (min, max, v) => Math.min(Math.max(v, min), max);
|
|
210
210
|
|
|
211
211
|
const safeMin = 0.001;
|
|
212
212
|
const minDuration = 0.01;
|
|
@@ -218,8 +218,8 @@
|
|
|
218
218
|
let derivative;
|
|
219
219
|
warning(duration <= maxDuration * 1000, "Spring duration must be 10 seconds or less");
|
|
220
220
|
let dampingRatio = 1 - bounce;
|
|
221
|
-
dampingRatio = clamp$
|
|
222
|
-
duration = clamp$
|
|
221
|
+
dampingRatio = clamp$1(minDamping, maxDamping, dampingRatio);
|
|
222
|
+
duration = clamp$1(minDuration, maxDuration, duration / 1000);
|
|
223
223
|
if (dampingRatio < 1) {
|
|
224
224
|
envelope = (undampedFreq) => {
|
|
225
225
|
const exponentialDecay = undampedFreq * dampingRatio;
|
|
@@ -405,39 +405,43 @@
|
|
|
405
405
|
|
|
406
406
|
const mix = (from, to, progress) => -progress * from + progress * to + from;
|
|
407
407
|
|
|
408
|
-
const clamp
|
|
409
|
-
const sanitize
|
|
410
|
-
const floatRegex
|
|
411
|
-
const colorRegex
|
|
412
|
-
const singleColorRegex
|
|
413
|
-
function isString
|
|
408
|
+
const clamp = (min, max) => (v) => Math.max(Math.min(v, max), min);
|
|
409
|
+
const sanitize = (v) => (v % 1 ? Number(v.toFixed(5)) : v);
|
|
410
|
+
const floatRegex = /(-)?([\d]*\.?[\d])+/g;
|
|
411
|
+
const colorRegex = /(#[0-9a-f]{6}|#[0-9a-f]{3}|#(?:[0-9a-f]{2}){2,4}|(rgb|hsl)a?\((-?[\d\.]+%?[,\s]+){2}(-?[\d\.]+%?)\s*[\,\/]?\s*[\d\.]*%?\))/gi;
|
|
412
|
+
const singleColorRegex = /^(#[0-9a-f]{3}|#(?:[0-9a-f]{2}){2,4}|(rgb|hsl)a?\((-?[\d\.]+%?[,\s]+){2}(-?[\d\.]+%?)\s*[\,\/]?\s*[\d\.]*%?\))$/i;
|
|
413
|
+
function isString(v) {
|
|
414
414
|
return typeof v === 'string';
|
|
415
415
|
}
|
|
416
416
|
|
|
417
|
-
const number
|
|
417
|
+
const number = {
|
|
418
418
|
test: (v) => typeof v === 'number',
|
|
419
419
|
parse: parseFloat,
|
|
420
420
|
transform: (v) => v,
|
|
421
421
|
};
|
|
422
|
-
const alpha
|
|
423
|
-
Object.assign(Object.assign({}, number
|
|
422
|
+
const alpha = Object.assign(Object.assign({}, number), { transform: clamp(0, 1) });
|
|
423
|
+
const scale = Object.assign(Object.assign({}, number), { default: 1 });
|
|
424
424
|
|
|
425
|
-
const createUnitType
|
|
426
|
-
test: (v) => isString
|
|
425
|
+
const createUnitType = (unit) => ({
|
|
426
|
+
test: (v) => isString(v) && v.endsWith(unit) && v.split(' ').length === 1,
|
|
427
427
|
parse: parseFloat,
|
|
428
428
|
transform: (v) => `${v}${unit}`,
|
|
429
429
|
});
|
|
430
|
-
const
|
|
431
|
-
|
|
430
|
+
const degrees = createUnitType('deg');
|
|
431
|
+
const percent = createUnitType('%');
|
|
432
|
+
const px = createUnitType('px');
|
|
433
|
+
const vh = createUnitType('vh');
|
|
434
|
+
const vw = createUnitType('vw');
|
|
435
|
+
const progressPercentage = Object.assign(Object.assign({}, percent), { parse: (v) => percent.parse(v) / 100, transform: (v) => percent.transform(v * 100) });
|
|
432
436
|
|
|
433
|
-
const isColorString
|
|
434
|
-
return Boolean((isString
|
|
437
|
+
const isColorString = (type, testProp) => (v) => {
|
|
438
|
+
return Boolean((isString(v) && singleColorRegex.test(v) && v.startsWith(type)) ||
|
|
435
439
|
(testProp && Object.prototype.hasOwnProperty.call(v, testProp)));
|
|
436
440
|
};
|
|
437
|
-
const splitColor
|
|
438
|
-
if (!isString
|
|
441
|
+
const splitColor = (aName, bName, cName) => (v) => {
|
|
442
|
+
if (!isString(v))
|
|
439
443
|
return v;
|
|
440
|
-
const [a, b, c, alpha] = v.match(floatRegex
|
|
444
|
+
const [a, b, c, alpha] = v.match(floatRegex);
|
|
441
445
|
return {
|
|
442
446
|
[aName]: parseFloat(a),
|
|
443
447
|
[bName]: parseFloat(b),
|
|
@@ -446,39 +450,39 @@
|
|
|
446
450
|
};
|
|
447
451
|
};
|
|
448
452
|
|
|
449
|
-
const hsla
|
|
450
|
-
test: isColorString
|
|
451
|
-
parse: splitColor
|
|
452
|
-
transform: ({ hue, saturation, lightness, alpha: alpha$1
|
|
453
|
+
const hsla = {
|
|
454
|
+
test: isColorString('hsl', 'hue'),
|
|
455
|
+
parse: splitColor('hue', 'saturation', 'lightness'),
|
|
456
|
+
transform: ({ hue, saturation, lightness, alpha: alpha$1 = 1 }) => {
|
|
453
457
|
return ('hsla(' +
|
|
454
458
|
Math.round(hue) +
|
|
455
459
|
', ' +
|
|
456
|
-
percent
|
|
460
|
+
percent.transform(sanitize(saturation)) +
|
|
457
461
|
', ' +
|
|
458
|
-
percent
|
|
462
|
+
percent.transform(sanitize(lightness)) +
|
|
459
463
|
', ' +
|
|
460
|
-
sanitize
|
|
464
|
+
sanitize(alpha.transform(alpha$1)) +
|
|
461
465
|
')');
|
|
462
466
|
},
|
|
463
467
|
};
|
|
464
468
|
|
|
465
|
-
const clampRgbUnit
|
|
466
|
-
const rgbUnit
|
|
467
|
-
const rgba
|
|
468
|
-
test: isColorString
|
|
469
|
-
parse: splitColor
|
|
470
|
-
transform: ({ red, green, blue, alpha: alpha$1
|
|
471
|
-
rgbUnit
|
|
469
|
+
const clampRgbUnit = clamp(0, 255);
|
|
470
|
+
const rgbUnit = Object.assign(Object.assign({}, number), { transform: (v) => Math.round(clampRgbUnit(v)) });
|
|
471
|
+
const rgba = {
|
|
472
|
+
test: isColorString('rgb', 'red'),
|
|
473
|
+
parse: splitColor('red', 'green', 'blue'),
|
|
474
|
+
transform: ({ red, green, blue, alpha: alpha$1 = 1 }) => 'rgba(' +
|
|
475
|
+
rgbUnit.transform(red) +
|
|
472
476
|
', ' +
|
|
473
|
-
rgbUnit
|
|
477
|
+
rgbUnit.transform(green) +
|
|
474
478
|
', ' +
|
|
475
|
-
rgbUnit
|
|
479
|
+
rgbUnit.transform(blue) +
|
|
476
480
|
', ' +
|
|
477
|
-
sanitize
|
|
481
|
+
sanitize(alpha.transform(alpha$1)) +
|
|
478
482
|
')',
|
|
479
483
|
};
|
|
480
484
|
|
|
481
|
-
function parseHex
|
|
485
|
+
function parseHex(v) {
|
|
482
486
|
let r = '';
|
|
483
487
|
let g = '';
|
|
484
488
|
let b = '';
|
|
@@ -506,81 +510,101 @@
|
|
|
506
510
|
alpha: a ? parseInt(a, 16) / 255 : 1,
|
|
507
511
|
};
|
|
508
512
|
}
|
|
509
|
-
const hex
|
|
510
|
-
test: isColorString
|
|
511
|
-
parse: parseHex
|
|
512
|
-
transform: rgba
|
|
513
|
+
const hex = {
|
|
514
|
+
test: isColorString('#'),
|
|
515
|
+
parse: parseHex,
|
|
516
|
+
transform: rgba.transform,
|
|
513
517
|
};
|
|
514
518
|
|
|
515
|
-
const color
|
|
516
|
-
test: (v) => rgba
|
|
519
|
+
const color = {
|
|
520
|
+
test: (v) => rgba.test(v) || hex.test(v) || hsla.test(v),
|
|
517
521
|
parse: (v) => {
|
|
518
|
-
if (rgba
|
|
519
|
-
return rgba
|
|
522
|
+
if (rgba.test(v)) {
|
|
523
|
+
return rgba.parse(v);
|
|
520
524
|
}
|
|
521
|
-
else if (hsla
|
|
522
|
-
return hsla
|
|
525
|
+
else if (hsla.test(v)) {
|
|
526
|
+
return hsla.parse(v);
|
|
523
527
|
}
|
|
524
528
|
else {
|
|
525
|
-
return hex
|
|
529
|
+
return hex.parse(v);
|
|
526
530
|
}
|
|
527
531
|
},
|
|
528
532
|
transform: (v) => {
|
|
529
|
-
return isString
|
|
533
|
+
return isString(v)
|
|
530
534
|
? v
|
|
531
535
|
: v.hasOwnProperty('red')
|
|
532
|
-
? rgba
|
|
533
|
-
: hsla
|
|
536
|
+
? rgba.transform(v)
|
|
537
|
+
: hsla.transform(v);
|
|
534
538
|
},
|
|
535
539
|
};
|
|
536
540
|
|
|
537
|
-
const colorToken
|
|
538
|
-
const numberToken
|
|
539
|
-
function test
|
|
541
|
+
const colorToken = '${c}';
|
|
542
|
+
const numberToken = '${n}';
|
|
543
|
+
function test(v) {
|
|
540
544
|
var _a, _b, _c, _d;
|
|
541
545
|
return (isNaN(v) &&
|
|
542
|
-
isString
|
|
543
|
-
((_b = (_a = v.match(floatRegex
|
|
546
|
+
isString(v) &&
|
|
547
|
+
((_b = (_a = v.match(floatRegex)) === null || _a === void 0 ? void 0 : _a.length) !== null && _b !== void 0 ? _b : 0) + ((_d = (_c = v.match(colorRegex)) === null || _c === void 0 ? void 0 : _c.length) !== null && _d !== void 0 ? _d : 0) > 0);
|
|
544
548
|
}
|
|
545
|
-
function analyse$
|
|
549
|
+
function analyse$1(v) {
|
|
546
550
|
if (typeof v === 'number')
|
|
547
551
|
v = `${v}`;
|
|
548
552
|
const values = [];
|
|
549
553
|
let numColors = 0;
|
|
550
|
-
const colors = v.match(colorRegex
|
|
554
|
+
const colors = v.match(colorRegex);
|
|
551
555
|
if (colors) {
|
|
552
556
|
numColors = colors.length;
|
|
553
|
-
v = v.replace(colorRegex
|
|
554
|
-
values.push(...colors.map(color
|
|
557
|
+
v = v.replace(colorRegex, colorToken);
|
|
558
|
+
values.push(...colors.map(color.parse));
|
|
555
559
|
}
|
|
556
|
-
const numbers = v.match(floatRegex
|
|
560
|
+
const numbers = v.match(floatRegex);
|
|
557
561
|
if (numbers) {
|
|
558
|
-
v = v.replace(floatRegex
|
|
559
|
-
values.push(...numbers.map(number
|
|
562
|
+
v = v.replace(floatRegex, numberToken);
|
|
563
|
+
values.push(...numbers.map(number.parse));
|
|
560
564
|
}
|
|
561
565
|
return { values, numColors, tokenised: v };
|
|
562
566
|
}
|
|
563
|
-
function parse
|
|
564
|
-
return analyse$
|
|
567
|
+
function parse(v) {
|
|
568
|
+
return analyse$1(v).values;
|
|
565
569
|
}
|
|
566
|
-
function createTransformer
|
|
567
|
-
const { values, numColors, tokenised } = analyse$
|
|
570
|
+
function createTransformer(v) {
|
|
571
|
+
const { values, numColors, tokenised } = analyse$1(v);
|
|
568
572
|
const numValues = values.length;
|
|
569
573
|
return (v) => {
|
|
570
574
|
let output = tokenised;
|
|
571
575
|
for (let i = 0; i < numValues; i++) {
|
|
572
|
-
output = output.replace(i < numColors ? colorToken
|
|
576
|
+
output = output.replace(i < numColors ? colorToken : numberToken, i < numColors ? color.transform(v[i]) : sanitize(v[i]));
|
|
573
577
|
}
|
|
574
578
|
return output;
|
|
575
579
|
};
|
|
576
580
|
}
|
|
577
|
-
const convertNumbersToZero
|
|
578
|
-
function getAnimatableNone$
|
|
579
|
-
const parsed = parse
|
|
580
|
-
const transformer = createTransformer
|
|
581
|
-
return transformer(parsed.map(convertNumbersToZero
|
|
581
|
+
const convertNumbersToZero = (v) => typeof v === 'number' ? 0 : v;
|
|
582
|
+
function getAnimatableNone$1(v) {
|
|
583
|
+
const parsed = parse(v);
|
|
584
|
+
const transformer = createTransformer(v);
|
|
585
|
+
return transformer(parsed.map(convertNumbersToZero));
|
|
586
|
+
}
|
|
587
|
+
const complex = { test, parse, createTransformer, getAnimatableNone: getAnimatableNone$1 };
|
|
588
|
+
|
|
589
|
+
const maxDefaults = new Set(['brightness', 'contrast', 'saturate', 'opacity']);
|
|
590
|
+
function applyDefaultFilter(v) {
|
|
591
|
+
let [name, value] = v.slice(0, -1).split('(');
|
|
592
|
+
if (name === 'drop-shadow')
|
|
593
|
+
return v;
|
|
594
|
+
const [number] = value.match(floatRegex) || [];
|
|
595
|
+
if (!number)
|
|
596
|
+
return v;
|
|
597
|
+
const unit = value.replace(number, '');
|
|
598
|
+
let defaultValue = maxDefaults.has(name) ? 1 : 0;
|
|
599
|
+
if (number !== value)
|
|
600
|
+
defaultValue *= 100;
|
|
601
|
+
return name + '(' + defaultValue + unit + ')';
|
|
582
602
|
}
|
|
583
|
-
const
|
|
603
|
+
const functionRegex = /([a-z-]*)\(.*?\)/g;
|
|
604
|
+
const filter = Object.assign(Object.assign({}, complex), { getAnimatableNone: (v) => {
|
|
605
|
+
const functions = v.match(functionRegex);
|
|
606
|
+
return functions ? functions.map(applyDefaultFilter).join(' ') : v;
|
|
607
|
+
} });
|
|
584
608
|
|
|
585
609
|
function hueToRgb(p, q, t) {
|
|
586
610
|
if (t < 0)
|
|
@@ -627,7 +651,7 @@
|
|
|
627
651
|
const toExpo = to * to;
|
|
628
652
|
return Math.sqrt(Math.max(0, v * (toExpo - fromExpo) + fromExpo));
|
|
629
653
|
};
|
|
630
|
-
const colorTypes = [hex
|
|
654
|
+
const colorTypes = [hex, rgba, hsla];
|
|
631
655
|
const getColorType = (v) => colorTypes.find((type) => type.test(v));
|
|
632
656
|
const notAnimatable = (color) => `'${color}' is not an animatable color. Use the equivalent color code instead.`;
|
|
633
657
|
const mixColor = (from, to) => {
|
|
@@ -637,13 +661,13 @@
|
|
|
637
661
|
invariant(!!toColorType, notAnimatable(to));
|
|
638
662
|
let fromColor = fromColorType.parse(from);
|
|
639
663
|
let toColor = toColorType.parse(to);
|
|
640
|
-
if (fromColorType === hsla
|
|
664
|
+
if (fromColorType === hsla) {
|
|
641
665
|
fromColor = hslaToRgba(fromColor);
|
|
642
|
-
fromColorType = rgba
|
|
666
|
+
fromColorType = rgba;
|
|
643
667
|
}
|
|
644
|
-
if (toColorType === hsla
|
|
668
|
+
if (toColorType === hsla) {
|
|
645
669
|
toColor = hslaToRgba(toColor);
|
|
646
|
-
toColorType = rgba
|
|
670
|
+
toColorType = rgba;
|
|
647
671
|
}
|
|
648
672
|
const blended = Object.assign({}, fromColor);
|
|
649
673
|
return (v) => {
|
|
@@ -666,7 +690,7 @@
|
|
|
666
690
|
if (isNum(origin)) {
|
|
667
691
|
return (v) => mix(origin, target, v);
|
|
668
692
|
}
|
|
669
|
-
else if (color
|
|
693
|
+
else if (color.test(origin)) {
|
|
670
694
|
return mixColor(origin, target);
|
|
671
695
|
}
|
|
672
696
|
else {
|
|
@@ -699,8 +723,8 @@
|
|
|
699
723
|
return output;
|
|
700
724
|
};
|
|
701
725
|
};
|
|
702
|
-
function analyse
|
|
703
|
-
const parsed = complex
|
|
726
|
+
function analyse(value) {
|
|
727
|
+
const parsed = complex.parse(value);
|
|
704
728
|
const numValues = parsed.length;
|
|
705
729
|
let numNumbers = 0;
|
|
706
730
|
let numRGB = 0;
|
|
@@ -721,9 +745,9 @@
|
|
|
721
745
|
return { parsed, numNumbers, numRGB, numHSL };
|
|
722
746
|
}
|
|
723
747
|
const mixComplex = (origin, target) => {
|
|
724
|
-
const template = complex
|
|
725
|
-
const originStats = analyse
|
|
726
|
-
const targetStats = analyse
|
|
748
|
+
const template = complex.createTransformer(target);
|
|
749
|
+
const originStats = analyse(origin);
|
|
750
|
+
const targetStats = analyse(target);
|
|
727
751
|
const canInterpolate = originStats.numHSL === targetStats.numHSL &&
|
|
728
752
|
originStats.numRGB === targetStats.numRGB &&
|
|
729
753
|
originStats.numNumbers >= targetStats.numNumbers;
|
|
@@ -742,7 +766,7 @@
|
|
|
742
766
|
return mixNumber;
|
|
743
767
|
}
|
|
744
768
|
else if (typeof v === 'string') {
|
|
745
|
-
if (color
|
|
769
|
+
if (color.test(v)) {
|
|
746
770
|
return mixColor;
|
|
747
771
|
}
|
|
748
772
|
else {
|
|
@@ -814,7 +838,7 @@
|
|
|
814
838
|
? fastInterpolate(input, mixers)
|
|
815
839
|
: slowInterpolate(input, mixers);
|
|
816
840
|
return isClamp
|
|
817
|
-
? (v) => interpolator(clamp$
|
|
841
|
+
? (v) => interpolator(clamp$1(input[0], input[inputLength - 1], v))
|
|
818
842
|
: interpolator;
|
|
819
843
|
}
|
|
820
844
|
|
|
@@ -1257,7 +1281,7 @@
|
|
|
1257
1281
|
* This will be replaced by the build step with the latest version number.
|
|
1258
1282
|
* When MotionValues are provided to motion components, warn if versions are mixed.
|
|
1259
1283
|
*/
|
|
1260
|
-
this.version = "7.0.
|
|
1284
|
+
this.version = "7.0.2";
|
|
1261
1285
|
/**
|
|
1262
1286
|
* Duration, in milliseconds, since last updating frame.
|
|
1263
1287
|
*
|
|
@@ -1586,207 +1610,6 @@
|
|
|
1586
1610
|
return Array.isArray(ease) && typeof ease[0] !== "number";
|
|
1587
1611
|
};
|
|
1588
1612
|
|
|
1589
|
-
const clamp = (min, max) => (v) => Math.max(Math.min(v, max), min);
|
|
1590
|
-
const sanitize = (v) => (v % 1 ? Number(v.toFixed(5)) : v);
|
|
1591
|
-
const floatRegex = /(-)?([\d]*\.?[\d])+/g;
|
|
1592
|
-
const colorRegex = /(#[0-9a-f]{6}|#[0-9a-f]{3}|#(?:[0-9a-f]{2}){2,4}|(rgb|hsl)a?\((-?[\d\.]+%?[,\s]+){2,3}\s*\/*\s*[\d\.]+%?\))/gi;
|
|
1593
|
-
const singleColorRegex = /^(#[0-9a-f]{3}|#(?:[0-9a-f]{2}){2,4}|(rgb|hsl)a?\((-?[\d\.]+%?[,\s]+){2,3}\s*\/*\s*[\d\.]+%?\))$/i;
|
|
1594
|
-
function isString(v) {
|
|
1595
|
-
return typeof v === 'string';
|
|
1596
|
-
}
|
|
1597
|
-
|
|
1598
|
-
const number = {
|
|
1599
|
-
test: (v) => typeof v === 'number',
|
|
1600
|
-
parse: parseFloat,
|
|
1601
|
-
transform: (v) => v,
|
|
1602
|
-
};
|
|
1603
|
-
const alpha = Object.assign(Object.assign({}, number), { transform: clamp(0, 1) });
|
|
1604
|
-
const scale = Object.assign(Object.assign({}, number), { default: 1 });
|
|
1605
|
-
|
|
1606
|
-
const createUnitType = (unit) => ({
|
|
1607
|
-
test: (v) => isString(v) && v.endsWith(unit) && v.split(' ').length === 1,
|
|
1608
|
-
parse: parseFloat,
|
|
1609
|
-
transform: (v) => `${v}${unit}`,
|
|
1610
|
-
});
|
|
1611
|
-
const degrees = createUnitType('deg');
|
|
1612
|
-
const percent = createUnitType('%');
|
|
1613
|
-
const px = createUnitType('px');
|
|
1614
|
-
const vh = createUnitType('vh');
|
|
1615
|
-
const vw = createUnitType('vw');
|
|
1616
|
-
const progressPercentage = Object.assign(Object.assign({}, percent), { parse: (v) => percent.parse(v) / 100, transform: (v) => percent.transform(v * 100) });
|
|
1617
|
-
|
|
1618
|
-
const isColorString = (type, testProp) => (v) => {
|
|
1619
|
-
return Boolean((isString(v) && singleColorRegex.test(v) && v.startsWith(type)) ||
|
|
1620
|
-
(testProp && Object.prototype.hasOwnProperty.call(v, testProp)));
|
|
1621
|
-
};
|
|
1622
|
-
const splitColor = (aName, bName, cName) => (v) => {
|
|
1623
|
-
if (!isString(v))
|
|
1624
|
-
return v;
|
|
1625
|
-
const [a, b, c, alpha] = v.match(floatRegex);
|
|
1626
|
-
return {
|
|
1627
|
-
[aName]: parseFloat(a),
|
|
1628
|
-
[bName]: parseFloat(b),
|
|
1629
|
-
[cName]: parseFloat(c),
|
|
1630
|
-
alpha: alpha !== undefined ? parseFloat(alpha) : 1,
|
|
1631
|
-
};
|
|
1632
|
-
};
|
|
1633
|
-
|
|
1634
|
-
const hsla = {
|
|
1635
|
-
test: isColorString('hsl', 'hue'),
|
|
1636
|
-
parse: splitColor('hue', 'saturation', 'lightness'),
|
|
1637
|
-
transform: ({ hue, saturation, lightness, alpha: alpha$1 = 1 }) => {
|
|
1638
|
-
return ('hsla(' +
|
|
1639
|
-
Math.round(hue) +
|
|
1640
|
-
', ' +
|
|
1641
|
-
percent.transform(sanitize(saturation)) +
|
|
1642
|
-
', ' +
|
|
1643
|
-
percent.transform(sanitize(lightness)) +
|
|
1644
|
-
', ' +
|
|
1645
|
-
sanitize(alpha.transform(alpha$1)) +
|
|
1646
|
-
')');
|
|
1647
|
-
},
|
|
1648
|
-
};
|
|
1649
|
-
|
|
1650
|
-
const clampRgbUnit = clamp(0, 255);
|
|
1651
|
-
const rgbUnit = Object.assign(Object.assign({}, number), { transform: (v) => Math.round(clampRgbUnit(v)) });
|
|
1652
|
-
const rgba = {
|
|
1653
|
-
test: isColorString('rgb', 'red'),
|
|
1654
|
-
parse: splitColor('red', 'green', 'blue'),
|
|
1655
|
-
transform: ({ red, green, blue, alpha: alpha$1 = 1 }) => 'rgba(' +
|
|
1656
|
-
rgbUnit.transform(red) +
|
|
1657
|
-
', ' +
|
|
1658
|
-
rgbUnit.transform(green) +
|
|
1659
|
-
', ' +
|
|
1660
|
-
rgbUnit.transform(blue) +
|
|
1661
|
-
', ' +
|
|
1662
|
-
sanitize(alpha.transform(alpha$1)) +
|
|
1663
|
-
')',
|
|
1664
|
-
};
|
|
1665
|
-
|
|
1666
|
-
function parseHex(v) {
|
|
1667
|
-
let r = '';
|
|
1668
|
-
let g = '';
|
|
1669
|
-
let b = '';
|
|
1670
|
-
let a = '';
|
|
1671
|
-
if (v.length > 5) {
|
|
1672
|
-
r = v.substr(1, 2);
|
|
1673
|
-
g = v.substr(3, 2);
|
|
1674
|
-
b = v.substr(5, 2);
|
|
1675
|
-
a = v.substr(7, 2);
|
|
1676
|
-
}
|
|
1677
|
-
else {
|
|
1678
|
-
r = v.substr(1, 1);
|
|
1679
|
-
g = v.substr(2, 1);
|
|
1680
|
-
b = v.substr(3, 1);
|
|
1681
|
-
a = v.substr(4, 1);
|
|
1682
|
-
r += r;
|
|
1683
|
-
g += g;
|
|
1684
|
-
b += b;
|
|
1685
|
-
a += a;
|
|
1686
|
-
}
|
|
1687
|
-
return {
|
|
1688
|
-
red: parseInt(r, 16),
|
|
1689
|
-
green: parseInt(g, 16),
|
|
1690
|
-
blue: parseInt(b, 16),
|
|
1691
|
-
alpha: a ? parseInt(a, 16) / 255 : 1,
|
|
1692
|
-
};
|
|
1693
|
-
}
|
|
1694
|
-
const hex = {
|
|
1695
|
-
test: isColorString('#'),
|
|
1696
|
-
parse: parseHex,
|
|
1697
|
-
transform: rgba.transform,
|
|
1698
|
-
};
|
|
1699
|
-
|
|
1700
|
-
const color = {
|
|
1701
|
-
test: (v) => rgba.test(v) || hex.test(v) || hsla.test(v),
|
|
1702
|
-
parse: (v) => {
|
|
1703
|
-
if (rgba.test(v)) {
|
|
1704
|
-
return rgba.parse(v);
|
|
1705
|
-
}
|
|
1706
|
-
else if (hsla.test(v)) {
|
|
1707
|
-
return hsla.parse(v);
|
|
1708
|
-
}
|
|
1709
|
-
else {
|
|
1710
|
-
return hex.parse(v);
|
|
1711
|
-
}
|
|
1712
|
-
},
|
|
1713
|
-
transform: (v) => {
|
|
1714
|
-
return isString(v)
|
|
1715
|
-
? v
|
|
1716
|
-
: v.hasOwnProperty('red')
|
|
1717
|
-
? rgba.transform(v)
|
|
1718
|
-
: hsla.transform(v);
|
|
1719
|
-
},
|
|
1720
|
-
};
|
|
1721
|
-
|
|
1722
|
-
const colorToken = '${c}';
|
|
1723
|
-
const numberToken = '${n}';
|
|
1724
|
-
function test(v) {
|
|
1725
|
-
var _a, _b, _c, _d;
|
|
1726
|
-
return (isNaN(v) &&
|
|
1727
|
-
isString(v) &&
|
|
1728
|
-
((_b = (_a = v.match(floatRegex)) === null || _a === void 0 ? void 0 : _a.length) !== null && _b !== void 0 ? _b : 0) + ((_d = (_c = v.match(colorRegex)) === null || _c === void 0 ? void 0 : _c.length) !== null && _d !== void 0 ? _d : 0) > 0);
|
|
1729
|
-
}
|
|
1730
|
-
function analyse(v) {
|
|
1731
|
-
if (typeof v === 'number')
|
|
1732
|
-
v = `${v}`;
|
|
1733
|
-
const values = [];
|
|
1734
|
-
let numColors = 0;
|
|
1735
|
-
const colors = v.match(colorRegex);
|
|
1736
|
-
if (colors) {
|
|
1737
|
-
numColors = colors.length;
|
|
1738
|
-
v = v.replace(colorRegex, colorToken);
|
|
1739
|
-
values.push(...colors.map(color.parse));
|
|
1740
|
-
}
|
|
1741
|
-
const numbers = v.match(floatRegex);
|
|
1742
|
-
if (numbers) {
|
|
1743
|
-
v = v.replace(floatRegex, numberToken);
|
|
1744
|
-
values.push(...numbers.map(number.parse));
|
|
1745
|
-
}
|
|
1746
|
-
return { values, numColors, tokenised: v };
|
|
1747
|
-
}
|
|
1748
|
-
function parse(v) {
|
|
1749
|
-
return analyse(v).values;
|
|
1750
|
-
}
|
|
1751
|
-
function createTransformer(v) {
|
|
1752
|
-
const { values, numColors, tokenised } = analyse(v);
|
|
1753
|
-
const numValues = values.length;
|
|
1754
|
-
return (v) => {
|
|
1755
|
-
let output = tokenised;
|
|
1756
|
-
for (let i = 0; i < numValues; i++) {
|
|
1757
|
-
output = output.replace(i < numColors ? colorToken : numberToken, i < numColors ? color.transform(v[i]) : sanitize(v[i]));
|
|
1758
|
-
}
|
|
1759
|
-
return output;
|
|
1760
|
-
};
|
|
1761
|
-
}
|
|
1762
|
-
const convertNumbersToZero = (v) => typeof v === 'number' ? 0 : v;
|
|
1763
|
-
function getAnimatableNone$1(v) {
|
|
1764
|
-
const parsed = parse(v);
|
|
1765
|
-
const transformer = createTransformer(v);
|
|
1766
|
-
return transformer(parsed.map(convertNumbersToZero));
|
|
1767
|
-
}
|
|
1768
|
-
const complex = { test, parse, createTransformer, getAnimatableNone: getAnimatableNone$1 };
|
|
1769
|
-
|
|
1770
|
-
const maxDefaults = new Set(['brightness', 'contrast', 'saturate', 'opacity']);
|
|
1771
|
-
function applyDefaultFilter(v) {
|
|
1772
|
-
let [name, value] = v.slice(0, -1).split('(');
|
|
1773
|
-
if (name === 'drop-shadow')
|
|
1774
|
-
return v;
|
|
1775
|
-
const [number] = value.match(floatRegex) || [];
|
|
1776
|
-
if (!number)
|
|
1777
|
-
return v;
|
|
1778
|
-
const unit = value.replace(number, '');
|
|
1779
|
-
let defaultValue = maxDefaults.has(name) ? 1 : 0;
|
|
1780
|
-
if (number !== value)
|
|
1781
|
-
defaultValue *= 100;
|
|
1782
|
-
return name + '(' + defaultValue + unit + ')';
|
|
1783
|
-
}
|
|
1784
|
-
const functionRegex = /([a-z-]*)\(.*?\)/g;
|
|
1785
|
-
const filter = Object.assign(Object.assign({}, complex), { getAnimatableNone: (v) => {
|
|
1786
|
-
const functions = v.match(functionRegex);
|
|
1787
|
-
return functions ? functions.map(applyDefaultFilter).join(' ') : v;
|
|
1788
|
-
} });
|
|
1789
|
-
|
|
1790
1613
|
/**
|
|
1791
1614
|
* Check if a value is animatable. Examples:
|
|
1792
1615
|
*
|
|
@@ -4515,7 +4338,7 @@
|
|
|
4515
4338
|
* and warn against mismatches.
|
|
4516
4339
|
*/
|
|
4517
4340
|
{
|
|
4518
|
-
warnOnce(nextValue.version === "7.0.
|
|
4341
|
+
warnOnce(nextValue.version === "7.0.2", "Attempting to mix Framer Motion versions ".concat(nextValue.version, " with 7.0.2 may not work as expected."));
|
|
4519
4342
|
}
|
|
4520
4343
|
}
|
|
4521
4344
|
else if (isMotionValue(prevValue)) {
|