@teamturing/react-kit 2.4.0 → 2.5.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 (229) hide show
  1. package/dist/core/Dialog/index.d.ts +16 -0
  2. package/dist/core/DialogHandler/index.d.ts +13 -0
  3. package/dist/core/Grid/index.d.ts +2 -2
  4. package/dist/core/MotionView/index.d.ts +3 -0
  5. package/dist/core/Stack/index.d.ts +2 -2
  6. package/dist/hook/useDialogHandler.d.ts +6 -0
  7. package/dist/index.d.ts +4 -0
  8. package/dist/index.js +9762 -323
  9. package/dist/utils/index.d.ts +1 -0
  10. package/dist/utils/isFunction.d.ts +1 -0
  11. package/esm/core/Dialog/index.js +188 -0
  12. package/esm/core/DialogHandler/index.js +33 -0
  13. package/esm/core/MotionView/index.js +6 -0
  14. package/esm/hook/useDialogHandler.js +14 -0
  15. package/esm/index.js +3 -0
  16. package/esm/node_modules/framer-motion/dist/es/animation/animators/instant.js +40 -0
  17. package/esm/node_modules/framer-motion/dist/es/animation/animators/js/driver-frameloop.js +16 -0
  18. package/esm/node_modules/framer-motion/dist/es/animation/animators/js/index.js +303 -0
  19. package/esm/node_modules/framer-motion/dist/es/animation/animators/waapi/create-accelerated-animation.js +199 -0
  20. package/esm/node_modules/framer-motion/dist/es/animation/animators/waapi/easing.js +31 -0
  21. package/esm/node_modules/framer-motion/dist/es/animation/animators/waapi/index.js +23 -0
  22. package/esm/node_modules/framer-motion/dist/es/animation/animators/waapi/utils/get-final-keyframe.js +8 -0
  23. package/esm/node_modules/framer-motion/dist/es/animation/generators/inertia.js +87 -0
  24. package/esm/node_modules/framer-motion/dist/es/animation/generators/keyframes.js +51 -0
  25. package/esm/node_modules/framer-motion/dist/es/animation/generators/spring/find.js +89 -0
  26. package/esm/node_modules/framer-motion/dist/es/animation/generators/spring/index.js +129 -0
  27. package/esm/node_modules/framer-motion/dist/es/animation/generators/utils/calc-duration.js +17 -0
  28. package/esm/node_modules/framer-motion/dist/es/animation/generators/utils/velocity.js +9 -0
  29. package/esm/node_modules/framer-motion/dist/es/animation/interfaces/motion-value.js +101 -0
  30. package/esm/node_modules/framer-motion/dist/es/animation/interfaces/single-value.js +11 -0
  31. package/esm/node_modules/framer-motion/dist/es/animation/interfaces/visual-element-target.js +71 -0
  32. package/esm/node_modules/framer-motion/dist/es/animation/interfaces/visual-element-variant.js +63 -0
  33. package/esm/node_modules/framer-motion/dist/es/animation/interfaces/visual-element.js +24 -0
  34. package/esm/node_modules/framer-motion/dist/es/animation/optimized-appear/data-id.js +6 -0
  35. package/esm/node_modules/framer-motion/dist/es/animation/utils/default-transitions.js +40 -0
  36. package/esm/node_modules/framer-motion/dist/es/animation/utils/is-animatable.js +30 -0
  37. package/esm/node_modules/framer-motion/dist/es/animation/utils/is-animation-controls.js +5 -0
  38. package/esm/node_modules/framer-motion/dist/es/animation/utils/is-keyframes-target.js +5 -0
  39. package/esm/node_modules/framer-motion/dist/es/animation/utils/is-none.js +12 -0
  40. package/esm/node_modules/framer-motion/dist/es/animation/utils/keyframes.js +45 -0
  41. package/esm/node_modules/framer-motion/dist/es/animation/utils/transitions.js +13 -0
  42. package/esm/node_modules/framer-motion/dist/es/components/AnimatePresence/PopChild.js +71 -0
  43. package/esm/node_modules/framer-motion/dist/es/components/AnimatePresence/PresenceChild.js +56 -0
  44. package/esm/node_modules/framer-motion/dist/es/components/AnimatePresence/index.js +158 -0
  45. package/esm/node_modules/framer-motion/dist/es/components/AnimatePresence/use-presence.js +40 -0
  46. package/esm/node_modules/framer-motion/dist/es/context/LayoutGroupContext.js +5 -0
  47. package/esm/node_modules/framer-motion/dist/es/context/LazyContext.js +5 -0
  48. package/esm/node_modules/framer-motion/dist/es/context/MotionConfigContext.js +12 -0
  49. package/esm/node_modules/framer-motion/dist/es/context/MotionContext/create.js +13 -0
  50. package/esm/node_modules/framer-motion/dist/es/context/MotionContext/index.js +5 -0
  51. package/esm/node_modules/framer-motion/dist/es/context/MotionContext/utils.js +17 -0
  52. package/esm/node_modules/framer-motion/dist/es/context/PresenceContext.js +8 -0
  53. package/esm/node_modules/framer-motion/dist/es/context/SwitchLayoutGroupContext.js +8 -0
  54. package/esm/node_modules/framer-motion/dist/es/debug/record.js +7 -0
  55. package/esm/node_modules/framer-motion/dist/es/easing/anticipate.js +5 -0
  56. package/esm/node_modules/framer-motion/dist/es/easing/back.js +9 -0
  57. package/esm/node_modules/framer-motion/dist/es/easing/circ.js +8 -0
  58. package/esm/node_modules/framer-motion/dist/es/easing/cubic-bezier.js +51 -0
  59. package/esm/node_modules/framer-motion/dist/es/easing/ease.js +7 -0
  60. package/esm/node_modules/framer-motion/dist/es/easing/modifiers/mirror.js +5 -0
  61. package/esm/node_modules/framer-motion/dist/es/easing/modifiers/reverse.js +5 -0
  62. package/esm/node_modules/framer-motion/dist/es/easing/utils/is-bezier-definition.js +3 -0
  63. package/esm/node_modules/framer-motion/dist/es/easing/utils/is-easing-array.js +5 -0
  64. package/esm/node_modules/framer-motion/dist/es/easing/utils/map.js +37 -0
  65. package/esm/node_modules/framer-motion/dist/es/events/add-dom-event.js +6 -0
  66. package/esm/node_modules/framer-motion/dist/es/events/add-pointer-event.js +8 -0
  67. package/esm/node_modules/framer-motion/dist/es/events/event-info.js +15 -0
  68. package/esm/node_modules/framer-motion/dist/es/events/utils/is-primary-pointer.js +18 -0
  69. package/esm/node_modules/framer-motion/dist/es/frameloop/batcher.js +60 -0
  70. package/esm/node_modules/framer-motion/dist/es/frameloop/frame.js +6 -0
  71. package/esm/node_modules/framer-motion/dist/es/frameloop/render-step.js +104 -0
  72. package/esm/node_modules/framer-motion/dist/es/gestures/drag/VisualElementDragControls.js +457 -0
  73. package/esm/node_modules/framer-motion/dist/es/gestures/drag/index.js +27 -0
  74. package/esm/node_modules/framer-motion/dist/es/gestures/drag/utils/constraints.js +125 -0
  75. package/esm/node_modules/framer-motion/dist/es/gestures/drag/utils/lock.js +53 -0
  76. package/esm/node_modules/framer-motion/dist/es/gestures/focus.js +41 -0
  77. package/esm/node_modules/framer-motion/dist/es/gestures/hover.js +32 -0
  78. package/esm/node_modules/framer-motion/dist/es/gestures/pan/PanSession.js +148 -0
  79. package/esm/node_modules/framer-motion/dist/es/gestures/pan/index.js +46 -0
  80. package/esm/node_modules/framer-motion/dist/es/gestures/press.js +120 -0
  81. package/esm/node_modules/framer-motion/dist/es/gestures/utils/is-node-or-child.js +20 -0
  82. package/esm/node_modules/framer-motion/dist/es/motion/features/Feature.js +9 -0
  83. package/esm/node_modules/framer-motion/dist/es/motion/features/animation/exit.js +31 -0
  84. package/esm/node_modules/framer-motion/dist/es/motion/features/animation/index.js +38 -0
  85. package/esm/node_modules/framer-motion/dist/es/motion/features/animations.js +13 -0
  86. package/esm/node_modules/framer-motion/dist/es/motion/features/definitions.js +28 -0
  87. package/esm/node_modules/framer-motion/dist/es/motion/features/drag.js +17 -0
  88. package/esm/node_modules/framer-motion/dist/es/motion/features/gestures.js +21 -0
  89. package/esm/node_modules/framer-motion/dist/es/motion/features/layout/MeasureLayout.js +131 -0
  90. package/esm/node_modules/framer-motion/dist/es/motion/features/layout.js +11 -0
  91. package/esm/node_modules/framer-motion/dist/es/motion/features/load-features.js +12 -0
  92. package/esm/node_modules/framer-motion/dist/es/motion/features/viewport/index.js +72 -0
  93. package/esm/node_modules/framer-motion/dist/es/motion/features/viewport/observers.js +49 -0
  94. package/esm/node_modules/framer-motion/dist/es/motion/index.js +79 -0
  95. package/esm/node_modules/framer-motion/dist/es/motion/utils/is-forced-motion-value.js +11 -0
  96. package/esm/node_modules/framer-motion/dist/es/motion/utils/symbol.js +3 -0
  97. package/esm/node_modules/framer-motion/dist/es/motion/utils/use-motion-ref.js +33 -0
  98. package/esm/node_modules/framer-motion/dist/es/motion/utils/use-visual-element.js +75 -0
  99. package/esm/node_modules/framer-motion/dist/es/motion/utils/use-visual-state.js +81 -0
  100. package/esm/node_modules/framer-motion/dist/es/motion/utils/valid-prop.js +59 -0
  101. package/esm/node_modules/framer-motion/dist/es/projection/animation/mix-values.js +93 -0
  102. package/esm/node_modules/framer-motion/dist/es/projection/geometry/conversion.js +33 -0
  103. package/esm/node_modules/framer-motion/dist/es/projection/geometry/copy.js +20 -0
  104. package/esm/node_modules/framer-motion/dist/es/projection/geometry/delta-apply.js +122 -0
  105. package/esm/node_modules/framer-motion/dist/es/projection/geometry/delta-calc.js +41 -0
  106. package/esm/node_modules/framer-motion/dist/es/projection/geometry/delta-remove.js +54 -0
  107. package/esm/node_modules/framer-motion/dist/es/projection/geometry/models.js +17 -0
  108. package/esm/node_modules/framer-motion/dist/es/projection/geometry/utils.js +25 -0
  109. package/esm/node_modules/framer-motion/dist/es/projection/node/DocumentProjectionNode.js +13 -0
  110. package/esm/node_modules/framer-motion/dist/es/projection/node/HTMLProjectionNode.js +27 -0
  111. package/esm/node_modules/framer-motion/dist/es/projection/node/create-projection-node.js +1494 -0
  112. package/esm/node_modules/framer-motion/dist/es/projection/node/state.js +19 -0
  113. package/esm/node_modules/framer-motion/dist/es/projection/shared/stack.js +112 -0
  114. package/esm/node_modules/framer-motion/dist/es/projection/styles/scale-border-radius.js +41 -0
  115. package/esm/node_modules/framer-motion/dist/es/projection/styles/scale-box-shadow.js +35 -0
  116. package/esm/node_modules/framer-motion/dist/es/projection/styles/scale-correction.js +6 -0
  117. package/esm/node_modules/framer-motion/dist/es/projection/styles/transform.js +42 -0
  118. package/esm/node_modules/framer-motion/dist/es/projection/utils/each-axis.js +5 -0
  119. package/esm/node_modules/framer-motion/dist/es/projection/utils/has-transform.js +24 -0
  120. package/esm/node_modules/framer-motion/dist/es/projection/utils/measure.js +17 -0
  121. package/esm/node_modules/framer-motion/dist/es/render/VisualElement.js +507 -0
  122. package/esm/node_modules/framer-motion/dist/es/render/dom/DOMVisualElement.js +48 -0
  123. package/esm/node_modules/framer-motion/dist/es/render/dom/create-visual-element.js +11 -0
  124. package/esm/node_modules/framer-motion/dist/es/render/dom/motion-proxy.js +47 -0
  125. package/esm/node_modules/framer-motion/dist/es/render/dom/motion.js +23 -0
  126. package/esm/node_modules/framer-motion/dist/es/render/dom/use-render.js +35 -0
  127. package/esm/node_modules/framer-motion/dist/es/render/dom/utils/camel-to-dash.js +6 -0
  128. package/esm/node_modules/framer-motion/dist/es/render/dom/utils/create-config.js +19 -0
  129. package/esm/node_modules/framer-motion/dist/es/render/dom/utils/css-variables-conversion.js +89 -0
  130. package/esm/node_modules/framer-motion/dist/es/render/dom/utils/filter-props.js +57 -0
  131. package/esm/node_modules/framer-motion/dist/es/render/dom/utils/is-css-variable.js +6 -0
  132. package/esm/node_modules/framer-motion/dist/es/render/dom/utils/is-svg-component.js +30 -0
  133. package/esm/node_modules/framer-motion/dist/es/render/dom/utils/is-svg-element.js +5 -0
  134. package/esm/node_modules/framer-motion/dist/es/render/dom/utils/parse-dom-variant.js +15 -0
  135. package/esm/node_modules/framer-motion/dist/es/render/dom/utils/unit-conversion.js +230 -0
  136. package/esm/node_modules/framer-motion/dist/es/render/dom/value-types/animatable-none.js +15 -0
  137. package/esm/node_modules/framer-motion/dist/es/render/dom/value-types/defaults.js +30 -0
  138. package/esm/node_modules/framer-motion/dist/es/render/dom/value-types/dimensions.js +15 -0
  139. package/esm/node_modules/framer-motion/dist/es/render/dom/value-types/find.js +15 -0
  140. package/esm/node_modules/framer-motion/dist/es/render/dom/value-types/get-as-type.js +10 -0
  141. package/esm/node_modules/framer-motion/dist/es/render/dom/value-types/number.js +72 -0
  142. package/esm/node_modules/framer-motion/dist/es/render/dom/value-types/test.js +6 -0
  143. package/esm/node_modules/framer-motion/dist/es/render/dom/value-types/type-auto.js +9 -0
  144. package/esm/node_modules/framer-motion/dist/es/render/dom/value-types/type-int.js +8 -0
  145. package/esm/node_modules/framer-motion/dist/es/render/html/HTMLVisualElement.js +55 -0
  146. package/esm/node_modules/framer-motion/dist/es/render/html/config-motion.js +12 -0
  147. package/esm/node_modules/framer-motion/dist/es/render/html/use-props.js +57 -0
  148. package/esm/node_modules/framer-motion/dist/es/render/html/utils/build-styles.js +74 -0
  149. package/esm/node_modules/framer-motion/dist/es/render/html/utils/build-transform.js +45 -0
  150. package/esm/node_modules/framer-motion/dist/es/render/html/utils/create-render-state.js +8 -0
  151. package/esm/node_modules/framer-motion/dist/es/render/html/utils/render.js +9 -0
  152. package/esm/node_modules/framer-motion/dist/es/render/html/utils/scrape-motion-values.js +17 -0
  153. package/esm/node_modules/framer-motion/dist/es/render/html/utils/transform.js +28 -0
  154. package/esm/node_modules/framer-motion/dist/es/render/store.js +3 -0
  155. package/esm/node_modules/framer-motion/dist/es/render/svg/SVGVisualElement.js +46 -0
  156. package/esm/node_modules/framer-motion/dist/es/render/svg/config-motion.js +40 -0
  157. package/esm/node_modules/framer-motion/dist/es/render/svg/lowercase-elements.js +33 -0
  158. package/esm/node_modules/framer-motion/dist/es/render/svg/use-props.js +24 -0
  159. package/esm/node_modules/framer-motion/dist/es/render/svg/utils/build-attrs.js +52 -0
  160. package/esm/node_modules/framer-motion/dist/es/render/svg/utils/camel-case-attrs.js +30 -0
  161. package/esm/node_modules/framer-motion/dist/es/render/svg/utils/create-render-state.js +8 -0
  162. package/esm/node_modules/framer-motion/dist/es/render/svg/utils/is-svg-tag.js +3 -0
  163. package/esm/node_modules/framer-motion/dist/es/render/svg/utils/path.js +32 -0
  164. package/esm/node_modules/framer-motion/dist/es/render/svg/utils/render.js +12 -0
  165. package/esm/node_modules/framer-motion/dist/es/render/svg/utils/scrape-motion-values.js +18 -0
  166. package/esm/node_modules/framer-motion/dist/es/render/svg/utils/transform-origin.js +18 -0
  167. package/esm/node_modules/framer-motion/dist/es/render/utils/animation-state.js +319 -0
  168. package/esm/node_modules/framer-motion/dist/es/render/utils/compare-by-depth.js +3 -0
  169. package/esm/node_modules/framer-motion/dist/es/render/utils/flat-tree.js +24 -0
  170. package/esm/node_modules/framer-motion/dist/es/render/utils/is-controlling-variants.js +13 -0
  171. package/esm/node_modules/framer-motion/dist/es/render/utils/is-variant-label.js +8 -0
  172. package/esm/node_modules/framer-motion/dist/es/render/utils/motion-values.js +63 -0
  173. package/esm/node_modules/framer-motion/dist/es/render/utils/resolve-dynamic-variants.js +24 -0
  174. package/esm/node_modules/framer-motion/dist/es/render/utils/resolve-variants.js +26 -0
  175. package/esm/node_modules/framer-motion/dist/es/render/utils/setters.js +101 -0
  176. package/esm/node_modules/framer-motion/dist/es/render/utils/variant-props.js +12 -0
  177. package/esm/node_modules/framer-motion/dist/es/utils/array.js +11 -0
  178. package/esm/node_modules/framer-motion/dist/es/utils/clamp.js +3 -0
  179. package/esm/node_modules/framer-motion/dist/es/utils/delay.js +19 -0
  180. package/esm/node_modules/framer-motion/dist/es/utils/distance.js +9 -0
  181. package/esm/node_modules/framer-motion/dist/es/utils/errors.js +18 -0
  182. package/esm/node_modules/framer-motion/dist/es/utils/hsla-to-rgba.js +42 -0
  183. package/esm/node_modules/framer-motion/dist/es/utils/interpolate.js +92 -0
  184. package/esm/node_modules/framer-motion/dist/es/utils/is-browser.js +3 -0
  185. package/esm/node_modules/framer-motion/dist/es/utils/is-numerical-string.js +6 -0
  186. package/esm/node_modules/framer-motion/dist/es/utils/is-ref-object.js +6 -0
  187. package/esm/node_modules/framer-motion/dist/es/utils/is-zero-value-string.js +6 -0
  188. package/esm/node_modules/framer-motion/dist/es/utils/memo.js +10 -0
  189. package/esm/node_modules/framer-motion/dist/es/utils/mix-color.js +40 -0
  190. package/esm/node_modules/framer-motion/dist/es/utils/mix-complex.js +64 -0
  191. package/esm/node_modules/framer-motion/dist/es/utils/mix.js +24 -0
  192. package/esm/node_modules/framer-motion/dist/es/utils/noop.js +3 -0
  193. package/esm/node_modules/framer-motion/dist/es/utils/offsets/default.js +9 -0
  194. package/esm/node_modules/framer-motion/dist/es/utils/offsets/fill.js +12 -0
  195. package/esm/node_modules/framer-motion/dist/es/utils/offsets/time.js +5 -0
  196. package/esm/node_modules/framer-motion/dist/es/utils/pipe.js +11 -0
  197. package/esm/node_modules/framer-motion/dist/es/utils/progress.js +18 -0
  198. package/esm/node_modules/framer-motion/dist/es/utils/reduced-motion/index.js +19 -0
  199. package/esm/node_modules/framer-motion/dist/es/utils/reduced-motion/state.js +5 -0
  200. package/esm/node_modules/framer-motion/dist/es/utils/resolve-value.js +11 -0
  201. package/esm/node_modules/framer-motion/dist/es/utils/shallow-compare.js +14 -0
  202. package/esm/node_modules/framer-motion/dist/es/utils/subscription-manager.js +40 -0
  203. package/esm/node_modules/framer-motion/dist/es/utils/time-conversion.js +10 -0
  204. package/esm/node_modules/framer-motion/dist/es/utils/use-constant.js +18 -0
  205. package/esm/node_modules/framer-motion/dist/es/utils/use-force-update.js +19 -0
  206. package/esm/node_modules/framer-motion/dist/es/utils/use-instant-transition-state.js +5 -0
  207. package/esm/node_modules/framer-motion/dist/es/utils/use-is-mounted.js +15 -0
  208. package/esm/node_modules/framer-motion/dist/es/utils/use-isomorphic-effect.js +6 -0
  209. package/esm/node_modules/framer-motion/dist/es/utils/use-unmount-effect.js +7 -0
  210. package/esm/node_modules/framer-motion/dist/es/utils/velocity-per-second.js +11 -0
  211. package/esm/node_modules/framer-motion/dist/es/utils/warn-once.js +11 -0
  212. package/esm/node_modules/framer-motion/dist/es/value/index.js +331 -0
  213. package/esm/node_modules/framer-motion/dist/es/value/types/color/hex.js +40 -0
  214. package/esm/node_modules/framer-motion/dist/es/value/types/color/hsla.js +22 -0
  215. package/esm/node_modules/framer-motion/dist/es/value/types/color/index.js +28 -0
  216. package/esm/node_modules/framer-motion/dist/es/value/types/color/rgba.js +25 -0
  217. package/esm/node_modules/framer-motion/dist/es/value/types/color/utils.js +23 -0
  218. package/esm/node_modules/framer-motion/dist/es/value/types/complex/filter.js +30 -0
  219. package/esm/node_modules/framer-motion/dist/es/value/types/complex/index.js +92 -0
  220. package/esm/node_modules/framer-motion/dist/es/value/types/numbers/index.js +17 -0
  221. package/esm/node_modules/framer-motion/dist/es/value/types/numbers/units.js +19 -0
  222. package/esm/node_modules/framer-motion/dist/es/value/types/utils.js +15 -0
  223. package/esm/node_modules/framer-motion/dist/es/value/use-will-change/is.js +7 -0
  224. package/esm/node_modules/framer-motion/dist/es/value/utils/is-motion-value.js +3 -0
  225. package/esm/node_modules/framer-motion/dist/es/value/utils/resolve-motion-value.js +16 -0
  226. package/esm/packages/icons/esm/Close.js +17 -0
  227. package/esm/packages/token-studio/esm/token/elevation/index.js +5 -1
  228. package/esm/utils/isFunction.js +3 -0
  229. package/package.json +3 -3
@@ -0,0 +1,101 @@
1
+ import { warning } from '../../utils/errors.js';
2
+ import { secondsToMilliseconds } from '../../utils/time-conversion.js';
3
+ import { instantAnimationState } from '../../utils/use-instant-transition-state.js';
4
+ import { createAcceleratedAnimation } from '../animators/waapi/create-accelerated-animation.js';
5
+ import { createInstantAnimation } from '../animators/instant.js';
6
+ import { getDefaultTransition } from '../utils/default-transitions.js';
7
+ import { isAnimatable } from '../utils/is-animatable.js';
8
+ import { getKeyframes } from '../utils/keyframes.js';
9
+ import { getValueTransition, isTransitionDefined } from '../utils/transitions.js';
10
+ import { animateValue } from '../animators/js/index.js';
11
+
12
+ const animateMotionValue = (valueName, value, target, transition = {}) => {
13
+ return (onComplete) => {
14
+ const valueTransition = getValueTransition(transition, valueName) || {};
15
+ /**
16
+ * Most transition values are currently completely overwritten by value-specific
17
+ * transitions. In the future it'd be nicer to blend these transitions. But for now
18
+ * delay actually does inherit from the root transition if not value-specific.
19
+ */
20
+ const delay = valueTransition.delay || transition.delay || 0;
21
+ /**
22
+ * Elapsed isn't a public transition option but can be passed through from
23
+ * optimized appear effects in milliseconds.
24
+ */
25
+ let { elapsed = 0 } = transition;
26
+ elapsed = elapsed - secondsToMilliseconds(delay);
27
+ const keyframes = getKeyframes(value, valueName, target, valueTransition);
28
+ /**
29
+ * Check if we're able to animate between the start and end keyframes,
30
+ * and throw a warning if we're attempting to animate between one that's
31
+ * animatable and another that isn't.
32
+ */
33
+ const originKeyframe = keyframes[0];
34
+ const targetKeyframe = keyframes[keyframes.length - 1];
35
+ const isOriginAnimatable = isAnimatable(valueName, originKeyframe);
36
+ const isTargetAnimatable = isAnimatable(valueName, targetKeyframe);
37
+ warning(isOriginAnimatable === isTargetAnimatable, `You are trying to animate ${valueName} from "${originKeyframe}" to "${targetKeyframe}". ${originKeyframe} is not an animatable value - to enable this animation set ${originKeyframe} to a value animatable to ${targetKeyframe} via the \`style\` property.`);
38
+ let options = {
39
+ keyframes,
40
+ velocity: value.getVelocity(),
41
+ ease: "easeOut",
42
+ ...valueTransition,
43
+ delay: -elapsed,
44
+ onUpdate: (v) => {
45
+ value.set(v);
46
+ valueTransition.onUpdate && valueTransition.onUpdate(v);
47
+ },
48
+ onComplete: () => {
49
+ onComplete();
50
+ valueTransition.onComplete && valueTransition.onComplete();
51
+ },
52
+ };
53
+ /**
54
+ * If there's no transition defined for this value, we can generate
55
+ * unqiue transition settings for this value.
56
+ */
57
+ if (!isTransitionDefined(valueTransition)) {
58
+ options = {
59
+ ...options,
60
+ ...getDefaultTransition(valueName, options),
61
+ };
62
+ }
63
+ /**
64
+ * Both WAAPI and our internal animation functions use durations
65
+ * as defined by milliseconds, while our external API defines them
66
+ * as seconds.
67
+ */
68
+ if (options.duration) {
69
+ options.duration = secondsToMilliseconds(options.duration);
70
+ }
71
+ if (options.repeatDelay) {
72
+ options.repeatDelay = secondsToMilliseconds(options.repeatDelay);
73
+ }
74
+ if (!isOriginAnimatable ||
75
+ !isTargetAnimatable ||
76
+ instantAnimationState.current ||
77
+ valueTransition.type === false) {
78
+ /**
79
+ * If we can't animate this value, or the global instant animation flag is set,
80
+ * or this is simply defined as an instant transition, return an instant transition.
81
+ */
82
+ return createInstantAnimation(options);
83
+ }
84
+ /**
85
+ * Animate via WAAPI if possible.
86
+ */
87
+ if (value.owner &&
88
+ value.owner.current instanceof HTMLElement &&
89
+ !value.owner.getProps().onUpdate) {
90
+ const acceleratedAnimation = createAcceleratedAnimation(value, valueName, options);
91
+ if (acceleratedAnimation)
92
+ return acceleratedAnimation;
93
+ }
94
+ /**
95
+ * If we didn't create an accelerated animation, create a JS animation
96
+ */
97
+ return animateValue(options);
98
+ };
99
+ };
100
+
101
+ export { animateMotionValue };
@@ -0,0 +1,11 @@
1
+ import { animateMotionValue } from './motion-value.js';
2
+ import { motionValue } from '../../value/index.js';
3
+ import { isMotionValue } from '../../value/utils/is-motion-value.js';
4
+
5
+ function animateSingleValue(value, keyframes, options) {
6
+ const motionValue$1 = isMotionValue(value) ? value : motionValue(value);
7
+ motionValue$1.start(animateMotionValue("", motionValue$1, keyframes, options));
8
+ return motionValue$1.animation;
9
+ }
10
+
11
+ export { animateSingleValue };
@@ -0,0 +1,71 @@
1
+ import { transformProps } from '../../render/html/utils/transform.js';
2
+ import { optimizedAppearDataAttribute } from '../optimized-appear/data-id.js';
3
+ import { animateMotionValue } from './motion-value.js';
4
+ import { isWillChangeMotionValue } from '../../value/use-will-change/is.js';
5
+ import { setTarget } from '../../render/utils/setters.js';
6
+ import { frame } from '../../frameloop/frame.js';
7
+
8
+ /**
9
+ * Decide whether we should block this animation. Previously, we achieved this
10
+ * just by checking whether the key was listed in protectedKeys, but this
11
+ * posed problems if an animation was triggered by afterChildren and protectedKeys
12
+ * had been set to true in the meantime.
13
+ */
14
+ function shouldBlockAnimation({ protectedKeys, needsAnimating }, key) {
15
+ const shouldBlock = protectedKeys.hasOwnProperty(key) && needsAnimating[key] !== true;
16
+ needsAnimating[key] = false;
17
+ return shouldBlock;
18
+ }
19
+ function animateTarget(visualElement, definition, { delay = 0, transitionOverride, type } = {}) {
20
+ let { transition = visualElement.getDefaultTransition(), transitionEnd, ...target } = visualElement.makeTargetAnimatable(definition);
21
+ const willChange = visualElement.getValue("willChange");
22
+ if (transitionOverride)
23
+ transition = transitionOverride;
24
+ const animations = [];
25
+ const animationTypeState = type &&
26
+ visualElement.animationState &&
27
+ visualElement.animationState.getState()[type];
28
+ for (const key in target) {
29
+ const value = visualElement.getValue(key);
30
+ const valueTarget = target[key];
31
+ if (!value ||
32
+ valueTarget === undefined ||
33
+ (animationTypeState &&
34
+ shouldBlockAnimation(animationTypeState, key))) {
35
+ continue;
36
+ }
37
+ const valueTransition = {
38
+ delay,
39
+ elapsed: 0,
40
+ ...transition,
41
+ };
42
+ /**
43
+ * If this is the first time a value is being animated, check
44
+ * to see if we're handling off from an existing animation.
45
+ */
46
+ if (window.HandoffAppearAnimations && !value.hasAnimated) {
47
+ const appearId = visualElement.getProps()[optimizedAppearDataAttribute];
48
+ if (appearId) {
49
+ valueTransition.elapsed = window.HandoffAppearAnimations(appearId, key, value, frame);
50
+ valueTransition.syncStart = true;
51
+ }
52
+ }
53
+ value.start(animateMotionValue(key, value, valueTarget, visualElement.shouldReduceMotion && transformProps.has(key)
54
+ ? { type: false }
55
+ : valueTransition));
56
+ const animation = value.animation;
57
+ if (isWillChangeMotionValue(willChange)) {
58
+ willChange.add(key);
59
+ animation.then(() => willChange.remove(key));
60
+ }
61
+ animations.push(animation);
62
+ }
63
+ if (transitionEnd) {
64
+ Promise.all(animations).then(() => {
65
+ transitionEnd && setTarget(visualElement, transitionEnd);
66
+ });
67
+ }
68
+ return animations;
69
+ }
70
+
71
+ export { animateTarget };
@@ -0,0 +1,63 @@
1
+ import { resolveVariant } from '../../render/utils/resolve-dynamic-variants.js';
2
+ import { animateTarget } from './visual-element-target.js';
3
+
4
+ function animateVariant(visualElement, variant, options = {}) {
5
+ const resolved = resolveVariant(visualElement, variant, options.custom);
6
+ let { transition = visualElement.getDefaultTransition() || {} } = resolved || {};
7
+ if (options.transitionOverride) {
8
+ transition = options.transitionOverride;
9
+ }
10
+ /**
11
+ * If we have a variant, create a callback that runs it as an animation.
12
+ * Otherwise, we resolve a Promise immediately for a composable no-op.
13
+ */
14
+ const getAnimation = resolved
15
+ ? () => Promise.all(animateTarget(visualElement, resolved, options))
16
+ : () => Promise.resolve();
17
+ /**
18
+ * If we have children, create a callback that runs all their animations.
19
+ * Otherwise, we resolve a Promise immediately for a composable no-op.
20
+ */
21
+ const getChildAnimations = visualElement.variantChildren && visualElement.variantChildren.size
22
+ ? (forwardDelay = 0) => {
23
+ const { delayChildren = 0, staggerChildren, staggerDirection, } = transition;
24
+ return animateChildren(visualElement, variant, delayChildren + forwardDelay, staggerChildren, staggerDirection, options);
25
+ }
26
+ : () => Promise.resolve();
27
+ /**
28
+ * If the transition explicitly defines a "when" option, we need to resolve either
29
+ * this animation or all children animations before playing the other.
30
+ */
31
+ const { when } = transition;
32
+ if (when) {
33
+ const [first, last] = when === "beforeChildren"
34
+ ? [getAnimation, getChildAnimations]
35
+ : [getChildAnimations, getAnimation];
36
+ return first().then(() => last());
37
+ }
38
+ else {
39
+ return Promise.all([getAnimation(), getChildAnimations(options.delay)]);
40
+ }
41
+ }
42
+ function animateChildren(visualElement, variant, delayChildren = 0, staggerChildren = 0, staggerDirection = 1, options) {
43
+ const animations = [];
44
+ const maxStaggerDuration = (visualElement.variantChildren.size - 1) * staggerChildren;
45
+ const generateStaggerDuration = staggerDirection === 1
46
+ ? (i = 0) => i * staggerChildren
47
+ : (i = 0) => maxStaggerDuration - i * staggerChildren;
48
+ Array.from(visualElement.variantChildren)
49
+ .sort(sortByTreeOrder)
50
+ .forEach((child, i) => {
51
+ child.notify("AnimationStart", variant);
52
+ animations.push(animateVariant(child, variant, {
53
+ ...options,
54
+ delay: delayChildren + generateStaggerDuration(i),
55
+ }).then(() => child.notify("AnimationComplete", variant)));
56
+ });
57
+ return Promise.all(animations);
58
+ }
59
+ function sortByTreeOrder(a, b) {
60
+ return a.sortNodePosition(b);
61
+ }
62
+
63
+ export { animateVariant, sortByTreeOrder };
@@ -0,0 +1,24 @@
1
+ import { resolveVariant } from '../../render/utils/resolve-dynamic-variants.js';
2
+ import { animateTarget } from './visual-element-target.js';
3
+ import { animateVariant } from './visual-element-variant.js';
4
+
5
+ function animateVisualElement(visualElement, definition, options = {}) {
6
+ visualElement.notify("AnimationStart", definition);
7
+ let animation;
8
+ if (Array.isArray(definition)) {
9
+ const animations = definition.map((variant) => animateVariant(visualElement, variant, options));
10
+ animation = Promise.all(animations);
11
+ }
12
+ else if (typeof definition === "string") {
13
+ animation = animateVariant(visualElement, definition, options);
14
+ }
15
+ else {
16
+ const resolvedDefinition = typeof definition === "function"
17
+ ? resolveVariant(visualElement, definition, options.custom)
18
+ : definition;
19
+ animation = Promise.all(animateTarget(visualElement, resolvedDefinition, options));
20
+ }
21
+ return animation.then(() => visualElement.notify("AnimationComplete", definition));
22
+ }
23
+
24
+ export { animateVisualElement };
@@ -0,0 +1,6 @@
1
+ import { camelToDash } from '../../render/dom/utils/camel-to-dash.js';
2
+
3
+ const optimizedAppearDataId = "framerAppearId";
4
+ const optimizedAppearDataAttribute = "data-" + camelToDash(optimizedAppearDataId);
5
+
6
+ export { optimizedAppearDataAttribute, optimizedAppearDataId };
@@ -0,0 +1,40 @@
1
+ import { transformProps } from '../../render/html/utils/transform.js';
2
+
3
+ const underDampedSpring = {
4
+ type: "spring",
5
+ stiffness: 500,
6
+ damping: 25,
7
+ restSpeed: 10,
8
+ };
9
+ const criticallyDampedSpring = (target) => ({
10
+ type: "spring",
11
+ stiffness: 550,
12
+ damping: target === 0 ? 2 * Math.sqrt(550) : 30,
13
+ restSpeed: 10,
14
+ });
15
+ const keyframesTransition = {
16
+ type: "keyframes",
17
+ duration: 0.8,
18
+ };
19
+ /**
20
+ * Default easing curve is a slightly shallower version of
21
+ * the default browser easing curve.
22
+ */
23
+ const ease = {
24
+ type: "keyframes",
25
+ ease: [0.25, 0.1, 0.35, 1],
26
+ duration: 0.3,
27
+ };
28
+ const getDefaultTransition = (valueKey, { keyframes }) => {
29
+ if (keyframes.length > 2) {
30
+ return keyframesTransition;
31
+ }
32
+ else if (transformProps.has(valueKey)) {
33
+ return valueKey.startsWith("scale")
34
+ ? criticallyDampedSpring(keyframes[1])
35
+ : underDampedSpring;
36
+ }
37
+ return ease;
38
+ };
39
+
40
+ export { getDefaultTransition };
@@ -0,0 +1,30 @@
1
+ import { complex } from '../../value/types/complex/index.js';
2
+
3
+ /**
4
+ * Check if a value is animatable. Examples:
5
+ *
6
+ * ✅: 100, "100px", "#fff"
7
+ * ❌: "block", "url(2.jpg)"
8
+ * @param value
9
+ *
10
+ * @internal
11
+ */
12
+ const isAnimatable = (key, value) => {
13
+ // If the list of keys tat might be non-animatable grows, replace with Set
14
+ if (key === "zIndex")
15
+ return false;
16
+ // If it's a number or a keyframes array, we can animate it. We might at some point
17
+ // need to do a deep isAnimatable check of keyframes, or let Popmotion handle this,
18
+ // but for now lets leave it like this for performance reasons
19
+ if (typeof value === "number" || Array.isArray(value))
20
+ return true;
21
+ if (typeof value === "string" && // It's animatable if we have a string
22
+ (complex.test(value) || value === "0") && // And it contains numbers and/or colors
23
+ !value.startsWith("url(") // Unless it starts with "url("
24
+ ) {
25
+ return true;
26
+ }
27
+ return false;
28
+ };
29
+
30
+ export { isAnimatable };
@@ -0,0 +1,5 @@
1
+ function isAnimationControls(v) {
2
+ return typeof v === "object" && typeof v.start === "function";
3
+ }
4
+
5
+ export { isAnimationControls };
@@ -0,0 +1,5 @@
1
+ const isKeyframesTarget = (v) => {
2
+ return Array.isArray(v);
3
+ };
4
+
5
+ export { isKeyframesTarget };
@@ -0,0 +1,12 @@
1
+ import { isZeroValueString } from '../../utils/is-zero-value-string.js';
2
+
3
+ function isNone(value) {
4
+ if (typeof value === "number") {
5
+ return value === 0;
6
+ }
7
+ else if (value !== null) {
8
+ return value === "none" || value === "0" || isZeroValueString(value);
9
+ }
10
+ }
11
+
12
+ export { isNone };
@@ -0,0 +1,45 @@
1
+ import { getAnimatableNone } from '../../render/dom/value-types/animatable-none.js';
2
+ import { isAnimatable } from './is-animatable.js';
3
+ import { isNone } from './is-none.js';
4
+
5
+ function getKeyframes(value, valueName, target, transition) {
6
+ const isTargetAnimatable = isAnimatable(valueName, target);
7
+ let keyframes;
8
+ if (Array.isArray(target)) {
9
+ keyframes = [...target];
10
+ }
11
+ else {
12
+ keyframes = [null, target];
13
+ }
14
+ const defaultOrigin = transition.from !== undefined ? transition.from : value.get();
15
+ let animatableTemplateValue = undefined;
16
+ const noneKeyframeIndexes = [];
17
+ for (let i = 0; i < keyframes.length; i++) {
18
+ /**
19
+ * Fill null/wildcard keyframes
20
+ */
21
+ if (keyframes[i] === null) {
22
+ keyframes[i] = i === 0 ? defaultOrigin : keyframes[i - 1];
23
+ }
24
+ if (isNone(keyframes[i])) {
25
+ noneKeyframeIndexes.push(i);
26
+ }
27
+ // TODO: Clean this conditional, it works for now
28
+ if (typeof keyframes[i] === "string" &&
29
+ keyframes[i] !== "none" &&
30
+ keyframes[i] !== "0") {
31
+ animatableTemplateValue = keyframes[i];
32
+ }
33
+ }
34
+ if (isTargetAnimatable &&
35
+ noneKeyframeIndexes.length &&
36
+ animatableTemplateValue) {
37
+ for (let i = 0; i < noneKeyframeIndexes.length; i++) {
38
+ const index = noneKeyframeIndexes[i];
39
+ keyframes[index] = getAnimatableNone(valueName, animatableTemplateValue);
40
+ }
41
+ }
42
+ return keyframes;
43
+ }
44
+
45
+ export { getKeyframes };
@@ -0,0 +1,13 @@
1
+ /**
2
+ * Decide whether a transition is defined on a given Transition.
3
+ * This filters out orchestration options and returns true
4
+ * if any options are left.
5
+ */
6
+ function isTransitionDefined({ when, delay: _delay, delayChildren, staggerChildren, staggerDirection, repeat, repeatType, repeatDelay, from, elapsed, ...transition }) {
7
+ return !!Object.keys(transition).length;
8
+ }
9
+ function getValueTransition(transition, key) {
10
+ return transition[key] || transition["default"] || transition;
11
+ }
12
+
13
+ export { getValueTransition, isTransitionDefined };
@@ -0,0 +1,71 @@
1
+ import * as React from 'react';
2
+ import { useId, useRef, useInsertionEffect } from 'react';
3
+
4
+ /**
5
+ * Measurement functionality has to be within a separate component
6
+ * to leverage snapshot lifecycle.
7
+ */
8
+ class PopChildMeasure extends React.Component {
9
+ getSnapshotBeforeUpdate(prevProps) {
10
+ const element = this.props.childRef.current;
11
+ if (element && prevProps.isPresent && !this.props.isPresent) {
12
+ const size = this.props.sizeRef.current;
13
+ size.height = element.offsetHeight || 0;
14
+ size.width = element.offsetWidth || 0;
15
+ size.top = element.offsetTop;
16
+ size.left = element.offsetLeft;
17
+ }
18
+ return null;
19
+ }
20
+ /**
21
+ * Required with getSnapshotBeforeUpdate to stop React complaining.
22
+ */
23
+ componentDidUpdate() { }
24
+ render() {
25
+ return this.props.children;
26
+ }
27
+ }
28
+ function PopChild({ children, isPresent }) {
29
+ const id = useId();
30
+ const ref = useRef(null);
31
+ const size = useRef({
32
+ width: 0,
33
+ height: 0,
34
+ top: 0,
35
+ left: 0,
36
+ });
37
+ /**
38
+ * We create and inject a style block so we can apply this explicit
39
+ * sizing in a non-destructive manner by just deleting the style block.
40
+ *
41
+ * We can't apply size via render as the measurement happens
42
+ * in getSnapshotBeforeUpdate (post-render), likewise if we apply the
43
+ * styles directly on the DOM node, we might be overwriting
44
+ * styles set via the style prop.
45
+ */
46
+ useInsertionEffect(() => {
47
+ const { width, height, top, left } = size.current;
48
+ if (isPresent || !ref.current || !width || !height)
49
+ return;
50
+ ref.current.dataset.motionPopId = id;
51
+ const style = document.createElement("style");
52
+ document.head.appendChild(style);
53
+ if (style.sheet) {
54
+ style.sheet.insertRule(`
55
+ [data-motion-pop-id="${id}"] {
56
+ position: absolute !important;
57
+ width: ${width}px !important;
58
+ height: ${height}px !important;
59
+ top: ${top}px !important;
60
+ left: ${left}px !important;
61
+ }
62
+ `);
63
+ }
64
+ return () => {
65
+ document.head.removeChild(style);
66
+ };
67
+ }, [isPresent]);
68
+ return (React.createElement(PopChildMeasure, { isPresent: isPresent, childRef: ref, sizeRef: size }, React.cloneElement(children, { ref })));
69
+ }
70
+
71
+ export { PopChild };
@@ -0,0 +1,56 @@
1
+ import * as React from 'react';
2
+ import { useId, useMemo } from 'react';
3
+ import { PresenceContext } from '../../context/PresenceContext.js';
4
+ import { useConstant } from '../../utils/use-constant.js';
5
+ import { PopChild } from './PopChild.js';
6
+
7
+ const PresenceChild = ({ children, initial, isPresent, onExitComplete, custom, presenceAffectsLayout, mode, }) => {
8
+ const presenceChildren = useConstant(newChildrenMap);
9
+ const id = useId();
10
+ const context = useMemo(() => ({
11
+ id,
12
+ initial,
13
+ isPresent,
14
+ custom,
15
+ onExitComplete: (childId) => {
16
+ presenceChildren.set(childId, true);
17
+ for (const isComplete of presenceChildren.values()) {
18
+ if (!isComplete)
19
+ return; // can stop searching when any is incomplete
20
+ }
21
+ onExitComplete && onExitComplete();
22
+ },
23
+ register: (childId) => {
24
+ presenceChildren.set(childId, false);
25
+ return () => presenceChildren.delete(childId);
26
+ },
27
+ }),
28
+ /**
29
+ * If the presence of a child affects the layout of the components around it,
30
+ * we want to make a new context value to ensure they get re-rendered
31
+ * so they can detect that layout change.
32
+ */
33
+ presenceAffectsLayout ? undefined : [isPresent]);
34
+ useMemo(() => {
35
+ presenceChildren.forEach((_, key) => presenceChildren.set(key, false));
36
+ }, [isPresent]);
37
+ /**
38
+ * If there's no `motion` components to fire exit animations, we want to remove this
39
+ * component immediately.
40
+ */
41
+ React.useEffect(() => {
42
+ !isPresent &&
43
+ !presenceChildren.size &&
44
+ onExitComplete &&
45
+ onExitComplete();
46
+ }, [isPresent]);
47
+ if (mode === "popLayout") {
48
+ children = React.createElement(PopChild, { isPresent: isPresent }, children);
49
+ }
50
+ return (React.createElement(PresenceContext.Provider, { value: context }, children));
51
+ };
52
+ function newChildrenMap() {
53
+ return new Map();
54
+ }
55
+
56
+ export { PresenceChild };