framer-motion 12.7.3 → 12.7.5-alpha.0

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.
Files changed (155) hide show
  1. package/README.md +1 -1
  2. package/dist/cjs/client.js +1 -1
  3. package/dist/cjs/{create-DwAwaNot.js → create-C7kXmWbI.js} +99 -2828
  4. package/dist/cjs/dom-mini.js +82 -66
  5. package/dist/cjs/dom.js +264 -3000
  6. package/dist/cjs/index.js +163 -218
  7. package/dist/cjs/m.js +13 -170
  8. package/dist/cjs/mini.js +77 -9
  9. package/dist/dom-mini.js +1 -1
  10. package/dist/dom.d.ts +5 -94
  11. package/dist/dom.js +1 -1
  12. package/dist/es/animation/animate/sequence.mjs +1 -1
  13. package/dist/es/animation/animators/waapi/animate-elements.mjs +78 -10
  14. package/dist/es/animation/interfaces/motion-value.mjs +11 -30
  15. package/dist/es/animation/interfaces/visual-element-target.mjs +1 -2
  16. package/dist/es/animation/optimized-appear/store-id.mjs +1 -1
  17. package/dist/es/animation/sequence/create.mjs +2 -5
  18. package/dist/es/animation/sequence/utils/edit.mjs +2 -3
  19. package/dist/es/animation/utils/default-transitions.mjs +1 -1
  20. package/dist/es/animation/utils/stagger.mjs +1 -1
  21. package/dist/es/components/AnimatePresence/PresenceChild.mjs +26 -23
  22. package/dist/es/components/Reorder/utils/check-reorder.mjs +1 -1
  23. package/dist/es/dom.mjs +2 -18
  24. package/dist/es/gestures/drag/VisualElementDragControls.mjs +1 -3
  25. package/dist/es/gestures/drag/utils/constraints.mjs +2 -3
  26. package/dist/es/gestures/focus.mjs +1 -1
  27. package/dist/es/gestures/pan/PanSession.mjs +1 -2
  28. package/dist/es/index.mjs +3 -24
  29. package/dist/es/motion/utils/is-forced-motion-value.mjs +1 -1
  30. package/dist/es/projection/animation/mix-values.mjs +2 -4
  31. package/dist/es/projection/geometry/delta-apply.mjs +1 -1
  32. package/dist/es/projection/geometry/delta-calc.mjs +1 -1
  33. package/dist/es/projection/geometry/delta-remove.mjs +1 -2
  34. package/dist/es/projection/node/create-projection-node.mjs +3 -7
  35. package/dist/es/projection/styles/scale-border-radius.mjs +1 -1
  36. package/dist/es/projection/styles/scale-box-shadow.mjs +1 -2
  37. package/dist/es/projection/styles/scale-correction.mjs +1 -1
  38. package/dist/es/projection.mjs +1 -3
  39. package/dist/es/render/VisualElement.mjs +2 -9
  40. package/dist/es/render/dom/DOMVisualElement.mjs +1 -1
  41. package/dist/es/render/dom/scroll/attach-animation.mjs +17 -0
  42. package/dist/es/render/dom/scroll/attach-function.mjs +23 -0
  43. package/dist/es/render/dom/scroll/index.mjs +6 -82
  44. package/dist/es/render/dom/scroll/offsets/index.mjs +2 -3
  45. package/dist/es/render/dom/scroll/utils/get-timeline.mjs +29 -0
  46. package/dist/es/render/html/HTMLVisualElement.mjs +1 -3
  47. package/dist/es/render/html/utils/build-styles.mjs +1 -4
  48. package/dist/es/render/html/utils/build-transform.mjs +1 -3
  49. package/dist/es/render/svg/SVGVisualElement.mjs +1 -3
  50. package/dist/es/render/svg/config-motion.mjs +1 -2
  51. package/dist/es/render/svg/utils/path.mjs +1 -1
  52. package/dist/es/render/svg/utils/scrape-motion-values.mjs +1 -1
  53. package/dist/es/render/svg/utils/transform-origin.mjs +1 -1
  54. package/dist/es/render/utils/motion-values.mjs +1 -1
  55. package/dist/es/utils/delay.mjs +1 -1
  56. package/dist/es/utils/transform.mjs +1 -1
  57. package/dist/es/utils/use-cycle.mjs +1 -1
  58. package/dist/es/utils/use-instant-transition.mjs +4 -4
  59. package/dist/es/value/use-spring.mjs +2 -3
  60. package/dist/es/value/use-will-change/get-will-change-name.mjs +1 -2
  61. package/dist/framer-motion.dev.js +3881 -3419
  62. package/dist/framer-motion.js +1 -1
  63. package/dist/m.d.ts +3 -50
  64. package/dist/mini.js +1 -1
  65. package/dist/size-rollup-animate.js +1 -1
  66. package/dist/size-rollup-dom-animation-assets.js +1 -1
  67. package/dist/size-rollup-dom-animation.js +1 -1
  68. package/dist/size-rollup-dom-max-assets.js +1 -1
  69. package/dist/size-rollup-dom-max.js +1 -1
  70. package/dist/size-rollup-m.js +1 -1
  71. package/dist/size-rollup-motion.js +1 -1
  72. package/dist/size-rollup-scroll.js +1 -1
  73. package/dist/size-rollup-waapi-animate.js +1 -1
  74. package/dist/types/client.d.ts +4 -3
  75. package/dist/types/index.d.ts +56 -351
  76. package/dist/{types.d-B50aGbjN.d.ts → types.d-B1Voffvi.d.ts} +3 -138
  77. package/package.json +9 -9
  78. package/dist/es/animation/animators/AcceleratedAnimation.mjs +0 -319
  79. package/dist/es/animation/animators/BaseAnimation.mjs +0 -120
  80. package/dist/es/animation/animators/MainThreadAnimation.mjs +0 -394
  81. package/dist/es/animation/animators/drivers/driver-frameloop.mjs +0 -16
  82. package/dist/es/animation/animators/utils/accelerated-values.mjs +0 -14
  83. package/dist/es/animation/animators/utils/can-animate.mjs +0 -42
  84. package/dist/es/animation/animators/waapi/utils/supports-waapi.mjs +0 -5
  85. package/dist/es/animation/generators/inertia.mjs +0 -87
  86. package/dist/es/animation/generators/keyframes.mjs +0 -51
  87. package/dist/es/animation/generators/spring/defaults.mjs +0 -27
  88. package/dist/es/animation/generators/spring/find.mjs +0 -85
  89. package/dist/es/animation/generators/spring/index.mjs +0 -174
  90. package/dist/es/animation/generators/utils/velocity.mjs +0 -9
  91. package/dist/es/animation/utils/is-animatable.mjs +0 -30
  92. package/dist/es/animation/utils/is-none.mjs +0 -15
  93. package/dist/es/easing/anticipate.mjs +0 -5
  94. package/dist/es/easing/back.mjs +0 -9
  95. package/dist/es/easing/circ.mjs +0 -8
  96. package/dist/es/easing/cubic-bezier.mjs +0 -51
  97. package/dist/es/easing/ease.mjs +0 -7
  98. package/dist/es/easing/modifiers/mirror.mjs +0 -5
  99. package/dist/es/easing/modifiers/reverse.mjs +0 -5
  100. package/dist/es/easing/steps.mjs +0 -15
  101. package/dist/es/easing/utils/get-easing-for-segment.mjs +0 -8
  102. package/dist/es/easing/utils/is-easing-array.mjs +0 -5
  103. package/dist/es/easing/utils/map.mjs +0 -37
  104. package/dist/es/render/dom/DOMKeyframesResolver.mjs +0 -130
  105. package/dist/es/render/dom/scroll/observe.mjs +0 -18
  106. package/dist/es/render/dom/utils/css-variables-conversion.mjs +0 -42
  107. package/dist/es/render/dom/utils/is-css-variable.mjs +0 -15
  108. package/dist/es/render/dom/utils/unit-conversion.mjs +0 -36
  109. package/dist/es/render/dom/value-types/animatable-none.mjs +0 -15
  110. package/dist/es/render/dom/value-types/defaults.mjs +0 -30
  111. package/dist/es/render/dom/value-types/dimensions.mjs +0 -15
  112. package/dist/es/render/dom/value-types/find.mjs +0 -15
  113. package/dist/es/render/dom/value-types/get-as-type.mjs +0 -10
  114. package/dist/es/render/dom/value-types/number-browser.mjs +0 -41
  115. package/dist/es/render/dom/value-types/number.mjs +0 -18
  116. package/dist/es/render/dom/value-types/test.mjs +0 -6
  117. package/dist/es/render/dom/value-types/transform.mjs +0 -31
  118. package/dist/es/render/dom/value-types/type-auto.mjs +0 -9
  119. package/dist/es/render/dom/value-types/type-int.mjs +0 -8
  120. package/dist/es/render/html/utils/keys-position.mjs +0 -13
  121. package/dist/es/render/html/utils/keys-transform.mjs +0 -28
  122. package/dist/es/render/html/utils/make-none-animatable.mjs +0 -30
  123. package/dist/es/render/html/utils/parse-transform.mjs +0 -83
  124. package/dist/es/render/utils/KeyframesResolver.mjs +0 -163
  125. package/dist/es/utils/clamp.mjs +0 -9
  126. package/dist/es/utils/hsla-to-rgba.mjs +0 -42
  127. package/dist/es/utils/interpolate.mjs +0 -76
  128. package/dist/es/utils/is-numerical-string.mjs +0 -6
  129. package/dist/es/utils/is-zero-value-string.mjs +0 -6
  130. package/dist/es/utils/mix/color.mjs +0 -47
  131. package/dist/es/utils/mix/complex.mjs +0 -93
  132. package/dist/es/utils/mix/immediate.mjs +0 -5
  133. package/dist/es/utils/mix/index.mjs +0 -14
  134. package/dist/es/utils/mix/number.mjs +0 -26
  135. package/dist/es/utils/mix/visibility.mjs +0 -16
  136. package/dist/es/utils/offsets/default.mjs +0 -9
  137. package/dist/es/utils/offsets/fill.mjs +0 -12
  138. package/dist/es/utils/offsets/time.mjs +0 -5
  139. package/dist/es/utils/pipe.mjs +0 -11
  140. package/dist/es/utils/use-instant-transition-state.mjs +0 -5
  141. package/dist/es/utils/wrap.mjs +0 -6
  142. package/dist/es/value/types/color/hex.mjs +0 -40
  143. package/dist/es/value/types/color/hsla.mjs +0 -22
  144. package/dist/es/value/types/color/index.mjs +0 -27
  145. package/dist/es/value/types/color/rgba.mjs +0 -25
  146. package/dist/es/value/types/color/utils.mjs +0 -29
  147. package/dist/es/value/types/complex/filter.mjs +0 -30
  148. package/dist/es/value/types/complex/index.mjs +0 -91
  149. package/dist/es/value/types/numbers/index.mjs +0 -17
  150. package/dist/es/value/types/numbers/units.mjs +0 -17
  151. package/dist/es/value/types/utils/color-regex.mjs +0 -3
  152. package/dist/es/value/types/utils/float-regex.mjs +0 -3
  153. package/dist/es/value/types/utils/is-nullish.mjs +0 -5
  154. package/dist/es/value/types/utils/sanitize.mjs +0 -5
  155. package/dist/es/value/types/utils/single-color-regex.mjs +0 -3
@@ -1,42 +0,0 @@
1
- // Adapted from https://gist.github.com/mjackson/5311256
2
- function hueToRgb(p, q, t) {
3
- if (t < 0)
4
- t += 1;
5
- if (t > 1)
6
- t -= 1;
7
- if (t < 1 / 6)
8
- return p + (q - p) * 6 * t;
9
- if (t < 1 / 2)
10
- return q;
11
- if (t < 2 / 3)
12
- return p + (q - p) * (2 / 3 - t) * 6;
13
- return p;
14
- }
15
- function hslaToRgba({ hue, saturation, lightness, alpha }) {
16
- hue /= 360;
17
- saturation /= 100;
18
- lightness /= 100;
19
- let red = 0;
20
- let green = 0;
21
- let blue = 0;
22
- if (!saturation) {
23
- red = green = blue = lightness;
24
- }
25
- else {
26
- const q = lightness < 0.5
27
- ? lightness * (1 + saturation)
28
- : lightness + saturation - lightness * saturation;
29
- const p = 2 * lightness - q;
30
- red = hueToRgb(p, q, hue + 1 / 3);
31
- green = hueToRgb(p, q, hue);
32
- blue = hueToRgb(p, q, hue - 1 / 3);
33
- }
34
- return {
35
- red: Math.round(red * 255),
36
- green: Math.round(green * 255),
37
- blue: Math.round(blue * 255),
38
- alpha,
39
- };
40
- }
41
-
42
- export { hslaToRgba };
@@ -1,76 +0,0 @@
1
- import { invariant, noop, progress } from 'motion-utils';
2
- import { clamp } from './clamp.mjs';
3
- import { mix } from './mix/index.mjs';
4
- import { pipe } from './pipe.mjs';
5
-
6
- function createMixers(output, ease, customMixer) {
7
- const mixers = [];
8
- const mixerFactory = customMixer || mix;
9
- const numMixers = output.length - 1;
10
- for (let i = 0; i < numMixers; i++) {
11
- let mixer = mixerFactory(output[i], output[i + 1]);
12
- if (ease) {
13
- const easingFunction = Array.isArray(ease) ? ease[i] || noop : ease;
14
- mixer = pipe(easingFunction, mixer);
15
- }
16
- mixers.push(mixer);
17
- }
18
- return mixers;
19
- }
20
- /**
21
- * Create a function that maps from a numerical input array to a generic output array.
22
- *
23
- * Accepts:
24
- * - Numbers
25
- * - Colors (hex, hsl, hsla, rgb, rgba)
26
- * - Complex (combinations of one or more numbers or strings)
27
- *
28
- * ```jsx
29
- * const mixColor = interpolate([0, 1], ['#fff', '#000'])
30
- *
31
- * mixColor(0.5) // 'rgba(128, 128, 128, 1)'
32
- * ```
33
- *
34
- * TODO Revist this approach once we've moved to data models for values,
35
- * probably not needed to pregenerate mixer functions.
36
- *
37
- * @public
38
- */
39
- function interpolate(input, output, { clamp: isClamp = true, ease, mixer } = {}) {
40
- const inputLength = input.length;
41
- invariant(inputLength === output.length, "Both input and output ranges must be the same length");
42
- /**
43
- * If we're only provided a single input, we can just make a function
44
- * that returns the output.
45
- */
46
- if (inputLength === 1)
47
- return () => output[0];
48
- if (inputLength === 2 && output[0] === output[1])
49
- return () => output[1];
50
- const isZeroDeltaRange = input[0] === input[1];
51
- // If input runs highest -> lowest, reverse both arrays
52
- if (input[0] > input[inputLength - 1]) {
53
- input = [...input].reverse();
54
- output = [...output].reverse();
55
- }
56
- const mixers = createMixers(output, ease, mixer);
57
- const numMixers = mixers.length;
58
- const interpolator = (v) => {
59
- if (isZeroDeltaRange && v < input[0])
60
- return output[0];
61
- let i = 0;
62
- if (numMixers > 1) {
63
- for (; i < input.length - 2; i++) {
64
- if (v < input[i + 1])
65
- break;
66
- }
67
- }
68
- const progressInRange = progress(input[i], input[i + 1], v);
69
- return mixers[i](progressInRange);
70
- };
71
- return isClamp
72
- ? (v) => interpolator(clamp(input[0], input[inputLength - 1], v))
73
- : interpolator;
74
- }
75
-
76
- export { interpolate };
@@ -1,6 +0,0 @@
1
- /**
2
- * Check if value is a numerical string, ie a string that is purely a number eg "100" or "-100.1"
3
- */
4
- const isNumericalString = (v) => /^-?(?:\d+(?:\.\d+)?|\.\d+)$/u.test(v);
5
-
6
- export { isNumericalString };
@@ -1,6 +0,0 @@
1
- /**
2
- * Check if the value is a zero value string like "0px" or "0%"
3
- */
4
- const isZeroValueString = (v) => /^0[^.\s]+$/u.test(v);
5
-
6
- export { isZeroValueString };
@@ -1,47 +0,0 @@
1
- import { mixNumber } from './number.mjs';
2
- import { warning } from 'motion-utils';
3
- import { hslaToRgba } from '../hsla-to-rgba.mjs';
4
- import { hex } from '../../value/types/color/hex.mjs';
5
- import { rgba } from '../../value/types/color/rgba.mjs';
6
- import { hsla } from '../../value/types/color/hsla.mjs';
7
- import { mixImmediate } from './immediate.mjs';
8
-
9
- // Linear color space blending
10
- // Explained https://www.youtube.com/watch?v=LKnqECcg6Gw
11
- // Demonstrated http://codepen.io/osublake/pen/xGVVaN
12
- const mixLinearColor = (from, to, v) => {
13
- const fromExpo = from * from;
14
- const expo = v * (to * to - fromExpo) + fromExpo;
15
- return expo < 0 ? 0 : Math.sqrt(expo);
16
- };
17
- const colorTypes = [hex, rgba, hsla];
18
- const getColorType = (v) => colorTypes.find((type) => type.test(v));
19
- function asRGBA(color) {
20
- const type = getColorType(color);
21
- warning(Boolean(type), `'${color}' is not an animatable color. Use the equivalent color code instead.`);
22
- if (!Boolean(type))
23
- return false;
24
- let model = type.parse(color);
25
- if (type === hsla) {
26
- // TODO Remove this cast - needed since Motion's stricter typing
27
- model = hslaToRgba(model);
28
- }
29
- return model;
30
- }
31
- const mixColor = (from, to) => {
32
- const fromRGBA = asRGBA(from);
33
- const toRGBA = asRGBA(to);
34
- if (!fromRGBA || !toRGBA) {
35
- return mixImmediate(from, to);
36
- }
37
- const blended = { ...fromRGBA };
38
- return (v) => {
39
- blended.red = mixLinearColor(fromRGBA.red, toRGBA.red, v);
40
- blended.green = mixLinearColor(fromRGBA.green, toRGBA.green, v);
41
- blended.blue = mixLinearColor(fromRGBA.blue, toRGBA.blue, v);
42
- blended.alpha = mixNumber(fromRGBA.alpha, toRGBA.alpha, v);
43
- return rgba.transform(blended);
44
- };
45
- };
46
-
47
- export { mixColor, mixLinearColor };
@@ -1,93 +0,0 @@
1
- import { mixNumber as mixNumber$1 } from './number.mjs';
2
- import { mixColor } from './color.mjs';
3
- import { pipe } from '../pipe.mjs';
4
- import { warning } from 'motion-utils';
5
- import { color } from '../../value/types/color/index.mjs';
6
- import { complex, analyseComplexValue } from '../../value/types/complex/index.mjs';
7
- import { isCSSVariableToken } from '../../render/dom/utils/is-css-variable.mjs';
8
- import { invisibleValues, mixVisibility } from './visibility.mjs';
9
- import { mixImmediate } from './immediate.mjs';
10
-
11
- function mixNumber(a, b) {
12
- return (p) => mixNumber$1(a, b, p);
13
- }
14
- function getMixer(a) {
15
- if (typeof a === "number") {
16
- return mixNumber;
17
- }
18
- else if (typeof a === "string") {
19
- return isCSSVariableToken(a)
20
- ? mixImmediate
21
- : color.test(a)
22
- ? mixColor
23
- : mixComplex;
24
- }
25
- else if (Array.isArray(a)) {
26
- return mixArray;
27
- }
28
- else if (typeof a === "object") {
29
- return color.test(a) ? mixColor : mixObject;
30
- }
31
- return mixImmediate;
32
- }
33
- function mixArray(a, b) {
34
- const output = [...a];
35
- const numValues = output.length;
36
- const blendValue = a.map((v, i) => getMixer(v)(v, b[i]));
37
- return (p) => {
38
- for (let i = 0; i < numValues; i++) {
39
- output[i] = blendValue[i](p);
40
- }
41
- return output;
42
- };
43
- }
44
- function mixObject(a, b) {
45
- const output = { ...a, ...b };
46
- const blendValue = {};
47
- for (const key in output) {
48
- if (a[key] !== undefined && b[key] !== undefined) {
49
- blendValue[key] = getMixer(a[key])(a[key], b[key]);
50
- }
51
- }
52
- return (v) => {
53
- for (const key in blendValue) {
54
- output[key] = blendValue[key](v);
55
- }
56
- return output;
57
- };
58
- }
59
- function matchOrder(origin, target) {
60
- const orderedOrigin = [];
61
- const pointers = { color: 0, var: 0, number: 0 };
62
- for (let i = 0; i < target.values.length; i++) {
63
- const type = target.types[i];
64
- const originIndex = origin.indexes[type][pointers[type]];
65
- const originValue = origin.values[originIndex] ?? 0;
66
- orderedOrigin[i] = originValue;
67
- pointers[type]++;
68
- }
69
- return orderedOrigin;
70
- }
71
- const mixComplex = (origin, target) => {
72
- const template = complex.createTransformer(target);
73
- const originStats = analyseComplexValue(origin);
74
- const targetStats = analyseComplexValue(target);
75
- const canInterpolate = originStats.indexes.var.length === targetStats.indexes.var.length &&
76
- originStats.indexes.color.length === targetStats.indexes.color.length &&
77
- originStats.indexes.number.length >= targetStats.indexes.number.length;
78
- if (canInterpolate) {
79
- if ((invisibleValues.has(origin) &&
80
- !targetStats.values.length) ||
81
- (invisibleValues.has(target) &&
82
- !originStats.values.length)) {
83
- return mixVisibility(origin, target);
84
- }
85
- return pipe(mixArray(matchOrder(originStats, targetStats), targetStats.values), template);
86
- }
87
- else {
88
- warning(true, `Complex values '${origin}' and '${target}' too different to mix. Ensure all colors are of the same type, and that each contains the same quantity of number and color values. Falling back to instant transition.`);
89
- return mixImmediate(origin, target);
90
- }
91
- };
92
-
93
- export { getMixer, mixArray, mixComplex, mixObject };
@@ -1,5 +0,0 @@
1
- function mixImmediate(a, b) {
2
- return (p) => (p > 0 ? b : a);
3
- }
4
-
5
- export { mixImmediate };
@@ -1,14 +0,0 @@
1
- import { getMixer } from './complex.mjs';
2
- import { mixNumber } from './number.mjs';
3
-
4
- function mix(from, to, p) {
5
- if (typeof from === "number" &&
6
- typeof to === "number" &&
7
- typeof p === "number") {
8
- return mixNumber(from, to, p);
9
- }
10
- const mixer = getMixer(from);
11
- return mixer(from, to);
12
- }
13
-
14
- export { mix };
@@ -1,26 +0,0 @@
1
- /*
2
- Value in range from progress
3
-
4
- Given a lower limit and an upper limit, we return the value within
5
- that range as expressed by progress (usually a number from 0 to 1)
6
-
7
- So progress = 0.5 would change
8
-
9
- from -------- to
10
-
11
- to
12
-
13
- from ---- to
14
-
15
- E.g. from = 10, to = 20, progress = 0.5 => 15
16
-
17
- @param [number]: Lower limit of range
18
- @param [number]: Upper limit of range
19
- @param [number]: The progress between lower and upper limits expressed 0-1
20
- @return [number]: Value as calculated from progress within range (not limited within range)
21
- */
22
- const mixNumber = (from, to, progress) => {
23
- return from + (to - from) * progress;
24
- };
25
-
26
- export { mixNumber };
@@ -1,16 +0,0 @@
1
- const invisibleValues = new Set(["none", "hidden"]);
2
- /**
3
- * Returns a function that, when provided a progress value between 0 and 1,
4
- * will return the "none" or "hidden" string only when the progress is that of
5
- * the origin or target.
6
- */
7
- function mixVisibility(origin, target) {
8
- if (invisibleValues.has(origin)) {
9
- return (p) => (p <= 0 ? origin : target);
10
- }
11
- else {
12
- return (p) => (p >= 1 ? target : origin);
13
- }
14
- }
15
-
16
- export { invisibleValues, mixVisibility };
@@ -1,9 +0,0 @@
1
- import { fillOffset } from './fill.mjs';
2
-
3
- function defaultOffset(arr) {
4
- const offset = [0];
5
- fillOffset(offset, arr.length - 1);
6
- return offset;
7
- }
8
-
9
- export { defaultOffset };
@@ -1,12 +0,0 @@
1
- import { progress } from 'motion-utils';
2
- import { mixNumber } from '../mix/number.mjs';
3
-
4
- function fillOffset(offset, remaining) {
5
- const min = offset[offset.length - 1];
6
- for (let i = 1; i <= remaining; i++) {
7
- const offsetProgress = progress(0, remaining, i);
8
- offset.push(mixNumber(min, 1, offsetProgress));
9
- }
10
- }
11
-
12
- export { fillOffset };
@@ -1,5 +0,0 @@
1
- function convertOffsetToTimes(offset, duration) {
2
- return offset.map((o) => o * duration);
3
- }
4
-
5
- export { convertOffsetToTimes };
@@ -1,11 +0,0 @@
1
- /**
2
- * Pipe
3
- * Compose other transformers to run linearily
4
- * pipe(min(20), max(40))
5
- * @param {...functions} transformers
6
- * @return {function}
7
- */
8
- const combineFunctions = (a, b) => (v) => b(a(v));
9
- const pipe = (...transformers) => transformers.reduce(combineFunctions);
10
-
11
- export { pipe };
@@ -1,5 +0,0 @@
1
- const instantAnimationState = {
2
- current: false,
3
- };
4
-
5
- export { instantAnimationState };
@@ -1,6 +0,0 @@
1
- const wrap = (min, max, v) => {
2
- const rangeSize = max - min;
3
- return ((((v - min) % rangeSize) + rangeSize) % rangeSize) + min;
4
- };
5
-
6
- export { wrap };
@@ -1,40 +0,0 @@
1
- import { rgba } from './rgba.mjs';
2
- import { isColorString } from './utils.mjs';
3
-
4
- function parseHex(v) {
5
- let r = "";
6
- let g = "";
7
- let b = "";
8
- let a = "";
9
- // If we have 6 characters, ie #FF0000
10
- if (v.length > 5) {
11
- r = v.substring(1, 3);
12
- g = v.substring(3, 5);
13
- b = v.substring(5, 7);
14
- a = v.substring(7, 9);
15
- // Or we have 3 characters, ie #F00
16
- }
17
- else {
18
- r = v.substring(1, 2);
19
- g = v.substring(2, 3);
20
- b = v.substring(3, 4);
21
- a = v.substring(4, 5);
22
- r += r;
23
- g += g;
24
- b += b;
25
- a += a;
26
- }
27
- return {
28
- red: parseInt(r, 16),
29
- green: parseInt(g, 16),
30
- blue: parseInt(b, 16),
31
- alpha: a ? parseInt(a, 16) / 255 : 1,
32
- };
33
- }
34
- const hex = {
35
- test: /*@__PURE__*/ isColorString("#"),
36
- parse: parseHex,
37
- transform: rgba.transform,
38
- };
39
-
40
- export { hex };
@@ -1,22 +0,0 @@
1
- import { alpha } from '../numbers/index.mjs';
2
- import { percent } from '../numbers/units.mjs';
3
- import { sanitize } from '../utils/sanitize.mjs';
4
- import { isColorString, splitColor } from './utils.mjs';
5
-
6
- const hsla = {
7
- test: /*@__PURE__*/ isColorString("hsl", "hue"),
8
- parse: /*@__PURE__*/ splitColor("hue", "saturation", "lightness"),
9
- transform: ({ hue, saturation, lightness, alpha: alpha$1 = 1 }) => {
10
- return ("hsla(" +
11
- Math.round(hue) +
12
- ", " +
13
- percent.transform(sanitize(saturation)) +
14
- ", " +
15
- percent.transform(sanitize(lightness)) +
16
- ", " +
17
- sanitize(alpha.transform(alpha$1)) +
18
- ")");
19
- },
20
- };
21
-
22
- export { hsla };
@@ -1,27 +0,0 @@
1
- import { hex } from './hex.mjs';
2
- import { hsla } from './hsla.mjs';
3
- import { rgba } from './rgba.mjs';
4
-
5
- const color = {
6
- test: (v) => rgba.test(v) || hex.test(v) || hsla.test(v),
7
- parse: (v) => {
8
- if (rgba.test(v)) {
9
- return rgba.parse(v);
10
- }
11
- else if (hsla.test(v)) {
12
- return hsla.parse(v);
13
- }
14
- else {
15
- return hex.parse(v);
16
- }
17
- },
18
- transform: (v) => {
19
- return typeof v === "string"
20
- ? v
21
- : v.hasOwnProperty("red")
22
- ? rgba.transform(v)
23
- : hsla.transform(v);
24
- },
25
- };
26
-
27
- export { color };
@@ -1,25 +0,0 @@
1
- import { clamp } from '../../../utils/clamp.mjs';
2
- import { alpha, number } from '../numbers/index.mjs';
3
- import { sanitize } from '../utils/sanitize.mjs';
4
- import { isColorString, splitColor } from './utils.mjs';
5
-
6
- const clampRgbUnit = (v) => clamp(0, 255, v);
7
- const rgbUnit = {
8
- ...number,
9
- transform: (v) => Math.round(clampRgbUnit(v)),
10
- };
11
- const rgba = {
12
- test: /*@__PURE__*/ isColorString("rgb", "red"),
13
- parse: /*@__PURE__*/ splitColor("red", "green", "blue"),
14
- transform: ({ red, green, blue, alpha: alpha$1 = 1 }) => "rgba(" +
15
- rgbUnit.transform(red) +
16
- ", " +
17
- rgbUnit.transform(green) +
18
- ", " +
19
- rgbUnit.transform(blue) +
20
- ", " +
21
- sanitize(alpha.transform(alpha$1)) +
22
- ")",
23
- };
24
-
25
- export { rgbUnit, rgba };
@@ -1,29 +0,0 @@
1
- import { floatRegex } from '../utils/float-regex.mjs';
2
- import { isNullish } from '../utils/is-nullish.mjs';
3
- import { singleColorRegex } from '../utils/single-color-regex.mjs';
4
-
5
- /**
6
- * Returns true if the provided string is a color, ie rgba(0,0,0,0) or #000,
7
- * but false if a number or multiple colors
8
- */
9
- const isColorString = (type, testProp) => (v) => {
10
- return Boolean((typeof v === "string" &&
11
- singleColorRegex.test(v) &&
12
- v.startsWith(type)) ||
13
- (testProp &&
14
- !isNullish(v) &&
15
- Object.prototype.hasOwnProperty.call(v, testProp)));
16
- };
17
- const splitColor = (aName, bName, cName) => (v) => {
18
- if (typeof v !== "string")
19
- return v;
20
- const [a, b, c, alpha] = v.match(floatRegex);
21
- return {
22
- [aName]: parseFloat(a),
23
- [bName]: parseFloat(b),
24
- [cName]: parseFloat(c),
25
- alpha: alpha !== undefined ? parseFloat(alpha) : 1,
26
- };
27
- };
28
-
29
- export { isColorString, splitColor };
@@ -1,30 +0,0 @@
1
- import { complex } from './index.mjs';
2
- import { floatRegex } from '../utils/float-regex.mjs';
3
-
4
- /**
5
- * Properties that should default to 1 or 100%
6
- */
7
- const maxDefaults = new Set(["brightness", "contrast", "saturate", "opacity"]);
8
- function applyDefaultFilter(v) {
9
- const [name, value] = v.slice(0, -1).split("(");
10
- if (name === "drop-shadow")
11
- return v;
12
- const [number] = value.match(floatRegex) || [];
13
- if (!number)
14
- return v;
15
- const unit = value.replace(number, "");
16
- let defaultValue = maxDefaults.has(name) ? 1 : 0;
17
- if (number !== value)
18
- defaultValue *= 100;
19
- return name + "(" + defaultValue + unit + ")";
20
- }
21
- const functionRegex = /\b([a-z-]*)\(.*?\)/gu;
22
- const filter = {
23
- ...complex,
24
- getAnimatableNone: (v) => {
25
- const functions = v.match(functionRegex);
26
- return functions ? functions.map(applyDefaultFilter).join(" ") : v;
27
- },
28
- };
29
-
30
- export { filter };
@@ -1,91 +0,0 @@
1
- import { color } from '../color/index.mjs';
2
- import { colorRegex } from '../utils/color-regex.mjs';
3
- import { floatRegex } from '../utils/float-regex.mjs';
4
- import { sanitize } from '../utils/sanitize.mjs';
5
-
6
- function test(v) {
7
- return (isNaN(v) &&
8
- typeof v === "string" &&
9
- (v.match(floatRegex)?.length || 0) +
10
- (v.match(colorRegex)?.length || 0) >
11
- 0);
12
- }
13
- const NUMBER_TOKEN = "number";
14
- const COLOR_TOKEN = "color";
15
- const VAR_TOKEN = "var";
16
- const VAR_FUNCTION_TOKEN = "var(";
17
- const SPLIT_TOKEN = "${}";
18
- // this regex consists of the `singleCssVariableRegex|rgbHSLValueRegex|digitRegex`
19
- const complexRegex = /var\s*\(\s*--(?:[\w-]+\s*|[\w-]+\s*,(?:\s*[^)(\s]|\s*\((?:[^)(]|\([^)(]*\))*\))+\s*)\)|#[\da-f]{3,8}|(?:rgb|hsl)a?\((?:-?[\d.]+%?[,\s]+){2}-?[\d.]+%?\s*(?:[,/]\s*)?(?:\b\d+(?:\.\d+)?|\.\d+)?%?\)|-?(?:\d+(?:\.\d+)?|\.\d+)/giu;
20
- function analyseComplexValue(value) {
21
- const originalValue = value.toString();
22
- const values = [];
23
- const indexes = {
24
- color: [],
25
- number: [],
26
- var: [],
27
- };
28
- const types = [];
29
- let i = 0;
30
- const tokenised = originalValue.replace(complexRegex, (parsedValue) => {
31
- if (color.test(parsedValue)) {
32
- indexes.color.push(i);
33
- types.push(COLOR_TOKEN);
34
- values.push(color.parse(parsedValue));
35
- }
36
- else if (parsedValue.startsWith(VAR_FUNCTION_TOKEN)) {
37
- indexes.var.push(i);
38
- types.push(VAR_TOKEN);
39
- values.push(parsedValue);
40
- }
41
- else {
42
- indexes.number.push(i);
43
- types.push(NUMBER_TOKEN);
44
- values.push(parseFloat(parsedValue));
45
- }
46
- ++i;
47
- return SPLIT_TOKEN;
48
- });
49
- const split = tokenised.split(SPLIT_TOKEN);
50
- return { values, split, indexes, types };
51
- }
52
- function parseComplexValue(v) {
53
- return analyseComplexValue(v).values;
54
- }
55
- function createTransformer(source) {
56
- const { split, types } = analyseComplexValue(source);
57
- const numSections = split.length;
58
- return (v) => {
59
- let output = "";
60
- for (let i = 0; i < numSections; i++) {
61
- output += split[i];
62
- if (v[i] !== undefined) {
63
- const type = types[i];
64
- if (type === NUMBER_TOKEN) {
65
- output += sanitize(v[i]);
66
- }
67
- else if (type === COLOR_TOKEN) {
68
- output += color.transform(v[i]);
69
- }
70
- else {
71
- output += v[i];
72
- }
73
- }
74
- }
75
- return output;
76
- };
77
- }
78
- const convertNumbersToZero = (v) => typeof v === "number" ? 0 : v;
79
- function getAnimatableNone(v) {
80
- const parsed = parseComplexValue(v);
81
- const transformer = createTransformer(v);
82
- return transformer(parsed.map(convertNumbersToZero));
83
- }
84
- const complex = {
85
- test,
86
- parse: parseComplexValue,
87
- createTransformer,
88
- getAnimatableNone,
89
- };
90
-
91
- export { analyseComplexValue, complex };