@teamturing/react-kit 2.3.1 → 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 (231) 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/enigma/EnigmaUI/index.d.ts +12 -2
  7. package/dist/hook/useDialogHandler.d.ts +6 -0
  8. package/dist/index.d.ts +4 -0
  9. package/dist/index.js +9769 -325
  10. package/dist/utils/index.d.ts +1 -0
  11. package/dist/utils/isFunction.d.ts +1 -0
  12. package/esm/core/Dialog/index.js +188 -0
  13. package/esm/core/DialogHandler/index.js +33 -0
  14. package/esm/core/MotionView/index.js +6 -0
  15. package/esm/enigma/EnigmaUI/index.js +6 -1
  16. package/esm/hook/useDialogHandler.js +14 -0
  17. package/esm/index.js +3 -0
  18. package/esm/node_modules/framer-motion/dist/es/animation/animators/instant.js +40 -0
  19. package/esm/node_modules/framer-motion/dist/es/animation/animators/js/driver-frameloop.js +16 -0
  20. package/esm/node_modules/framer-motion/dist/es/animation/animators/js/index.js +303 -0
  21. package/esm/node_modules/framer-motion/dist/es/animation/animators/waapi/create-accelerated-animation.js +199 -0
  22. package/esm/node_modules/framer-motion/dist/es/animation/animators/waapi/easing.js +31 -0
  23. package/esm/node_modules/framer-motion/dist/es/animation/animators/waapi/index.js +23 -0
  24. package/esm/node_modules/framer-motion/dist/es/animation/animators/waapi/utils/get-final-keyframe.js +8 -0
  25. package/esm/node_modules/framer-motion/dist/es/animation/generators/inertia.js +87 -0
  26. package/esm/node_modules/framer-motion/dist/es/animation/generators/keyframes.js +51 -0
  27. package/esm/node_modules/framer-motion/dist/es/animation/generators/spring/find.js +89 -0
  28. package/esm/node_modules/framer-motion/dist/es/animation/generators/spring/index.js +129 -0
  29. package/esm/node_modules/framer-motion/dist/es/animation/generators/utils/calc-duration.js +17 -0
  30. package/esm/node_modules/framer-motion/dist/es/animation/generators/utils/velocity.js +9 -0
  31. package/esm/node_modules/framer-motion/dist/es/animation/interfaces/motion-value.js +101 -0
  32. package/esm/node_modules/framer-motion/dist/es/animation/interfaces/single-value.js +11 -0
  33. package/esm/node_modules/framer-motion/dist/es/animation/interfaces/visual-element-target.js +71 -0
  34. package/esm/node_modules/framer-motion/dist/es/animation/interfaces/visual-element-variant.js +63 -0
  35. package/esm/node_modules/framer-motion/dist/es/animation/interfaces/visual-element.js +24 -0
  36. package/esm/node_modules/framer-motion/dist/es/animation/optimized-appear/data-id.js +6 -0
  37. package/esm/node_modules/framer-motion/dist/es/animation/utils/default-transitions.js +40 -0
  38. package/esm/node_modules/framer-motion/dist/es/animation/utils/is-animatable.js +30 -0
  39. package/esm/node_modules/framer-motion/dist/es/animation/utils/is-animation-controls.js +5 -0
  40. package/esm/node_modules/framer-motion/dist/es/animation/utils/is-keyframes-target.js +5 -0
  41. package/esm/node_modules/framer-motion/dist/es/animation/utils/is-none.js +12 -0
  42. package/esm/node_modules/framer-motion/dist/es/animation/utils/keyframes.js +45 -0
  43. package/esm/node_modules/framer-motion/dist/es/animation/utils/transitions.js +13 -0
  44. package/esm/node_modules/framer-motion/dist/es/components/AnimatePresence/PopChild.js +71 -0
  45. package/esm/node_modules/framer-motion/dist/es/components/AnimatePresence/PresenceChild.js +56 -0
  46. package/esm/node_modules/framer-motion/dist/es/components/AnimatePresence/index.js +158 -0
  47. package/esm/node_modules/framer-motion/dist/es/components/AnimatePresence/use-presence.js +40 -0
  48. package/esm/node_modules/framer-motion/dist/es/context/LayoutGroupContext.js +5 -0
  49. package/esm/node_modules/framer-motion/dist/es/context/LazyContext.js +5 -0
  50. package/esm/node_modules/framer-motion/dist/es/context/MotionConfigContext.js +12 -0
  51. package/esm/node_modules/framer-motion/dist/es/context/MotionContext/create.js +13 -0
  52. package/esm/node_modules/framer-motion/dist/es/context/MotionContext/index.js +5 -0
  53. package/esm/node_modules/framer-motion/dist/es/context/MotionContext/utils.js +17 -0
  54. package/esm/node_modules/framer-motion/dist/es/context/PresenceContext.js +8 -0
  55. package/esm/node_modules/framer-motion/dist/es/context/SwitchLayoutGroupContext.js +8 -0
  56. package/esm/node_modules/framer-motion/dist/es/debug/record.js +7 -0
  57. package/esm/node_modules/framer-motion/dist/es/easing/anticipate.js +5 -0
  58. package/esm/node_modules/framer-motion/dist/es/easing/back.js +9 -0
  59. package/esm/node_modules/framer-motion/dist/es/easing/circ.js +8 -0
  60. package/esm/node_modules/framer-motion/dist/es/easing/cubic-bezier.js +51 -0
  61. package/esm/node_modules/framer-motion/dist/es/easing/ease.js +7 -0
  62. package/esm/node_modules/framer-motion/dist/es/easing/modifiers/mirror.js +5 -0
  63. package/esm/node_modules/framer-motion/dist/es/easing/modifiers/reverse.js +5 -0
  64. package/esm/node_modules/framer-motion/dist/es/easing/utils/is-bezier-definition.js +3 -0
  65. package/esm/node_modules/framer-motion/dist/es/easing/utils/is-easing-array.js +5 -0
  66. package/esm/node_modules/framer-motion/dist/es/easing/utils/map.js +37 -0
  67. package/esm/node_modules/framer-motion/dist/es/events/add-dom-event.js +6 -0
  68. package/esm/node_modules/framer-motion/dist/es/events/add-pointer-event.js +8 -0
  69. package/esm/node_modules/framer-motion/dist/es/events/event-info.js +15 -0
  70. package/esm/node_modules/framer-motion/dist/es/events/utils/is-primary-pointer.js +18 -0
  71. package/esm/node_modules/framer-motion/dist/es/frameloop/batcher.js +60 -0
  72. package/esm/node_modules/framer-motion/dist/es/frameloop/frame.js +6 -0
  73. package/esm/node_modules/framer-motion/dist/es/frameloop/render-step.js +104 -0
  74. package/esm/node_modules/framer-motion/dist/es/gestures/drag/VisualElementDragControls.js +457 -0
  75. package/esm/node_modules/framer-motion/dist/es/gestures/drag/index.js +27 -0
  76. package/esm/node_modules/framer-motion/dist/es/gestures/drag/utils/constraints.js +125 -0
  77. package/esm/node_modules/framer-motion/dist/es/gestures/drag/utils/lock.js +53 -0
  78. package/esm/node_modules/framer-motion/dist/es/gestures/focus.js +41 -0
  79. package/esm/node_modules/framer-motion/dist/es/gestures/hover.js +32 -0
  80. package/esm/node_modules/framer-motion/dist/es/gestures/pan/PanSession.js +148 -0
  81. package/esm/node_modules/framer-motion/dist/es/gestures/pan/index.js +46 -0
  82. package/esm/node_modules/framer-motion/dist/es/gestures/press.js +120 -0
  83. package/esm/node_modules/framer-motion/dist/es/gestures/utils/is-node-or-child.js +20 -0
  84. package/esm/node_modules/framer-motion/dist/es/motion/features/Feature.js +9 -0
  85. package/esm/node_modules/framer-motion/dist/es/motion/features/animation/exit.js +31 -0
  86. package/esm/node_modules/framer-motion/dist/es/motion/features/animation/index.js +38 -0
  87. package/esm/node_modules/framer-motion/dist/es/motion/features/animations.js +13 -0
  88. package/esm/node_modules/framer-motion/dist/es/motion/features/definitions.js +28 -0
  89. package/esm/node_modules/framer-motion/dist/es/motion/features/drag.js +17 -0
  90. package/esm/node_modules/framer-motion/dist/es/motion/features/gestures.js +21 -0
  91. package/esm/node_modules/framer-motion/dist/es/motion/features/layout/MeasureLayout.js +131 -0
  92. package/esm/node_modules/framer-motion/dist/es/motion/features/layout.js +11 -0
  93. package/esm/node_modules/framer-motion/dist/es/motion/features/load-features.js +12 -0
  94. package/esm/node_modules/framer-motion/dist/es/motion/features/viewport/index.js +72 -0
  95. package/esm/node_modules/framer-motion/dist/es/motion/features/viewport/observers.js +49 -0
  96. package/esm/node_modules/framer-motion/dist/es/motion/index.js +79 -0
  97. package/esm/node_modules/framer-motion/dist/es/motion/utils/is-forced-motion-value.js +11 -0
  98. package/esm/node_modules/framer-motion/dist/es/motion/utils/symbol.js +3 -0
  99. package/esm/node_modules/framer-motion/dist/es/motion/utils/use-motion-ref.js +33 -0
  100. package/esm/node_modules/framer-motion/dist/es/motion/utils/use-visual-element.js +75 -0
  101. package/esm/node_modules/framer-motion/dist/es/motion/utils/use-visual-state.js +81 -0
  102. package/esm/node_modules/framer-motion/dist/es/motion/utils/valid-prop.js +59 -0
  103. package/esm/node_modules/framer-motion/dist/es/projection/animation/mix-values.js +93 -0
  104. package/esm/node_modules/framer-motion/dist/es/projection/geometry/conversion.js +33 -0
  105. package/esm/node_modules/framer-motion/dist/es/projection/geometry/copy.js +20 -0
  106. package/esm/node_modules/framer-motion/dist/es/projection/geometry/delta-apply.js +122 -0
  107. package/esm/node_modules/framer-motion/dist/es/projection/geometry/delta-calc.js +41 -0
  108. package/esm/node_modules/framer-motion/dist/es/projection/geometry/delta-remove.js +54 -0
  109. package/esm/node_modules/framer-motion/dist/es/projection/geometry/models.js +17 -0
  110. package/esm/node_modules/framer-motion/dist/es/projection/geometry/utils.js +25 -0
  111. package/esm/node_modules/framer-motion/dist/es/projection/node/DocumentProjectionNode.js +13 -0
  112. package/esm/node_modules/framer-motion/dist/es/projection/node/HTMLProjectionNode.js +27 -0
  113. package/esm/node_modules/framer-motion/dist/es/projection/node/create-projection-node.js +1494 -0
  114. package/esm/node_modules/framer-motion/dist/es/projection/node/state.js +19 -0
  115. package/esm/node_modules/framer-motion/dist/es/projection/shared/stack.js +112 -0
  116. package/esm/node_modules/framer-motion/dist/es/projection/styles/scale-border-radius.js +41 -0
  117. package/esm/node_modules/framer-motion/dist/es/projection/styles/scale-box-shadow.js +35 -0
  118. package/esm/node_modules/framer-motion/dist/es/projection/styles/scale-correction.js +6 -0
  119. package/esm/node_modules/framer-motion/dist/es/projection/styles/transform.js +42 -0
  120. package/esm/node_modules/framer-motion/dist/es/projection/utils/each-axis.js +5 -0
  121. package/esm/node_modules/framer-motion/dist/es/projection/utils/has-transform.js +24 -0
  122. package/esm/node_modules/framer-motion/dist/es/projection/utils/measure.js +17 -0
  123. package/esm/node_modules/framer-motion/dist/es/render/VisualElement.js +507 -0
  124. package/esm/node_modules/framer-motion/dist/es/render/dom/DOMVisualElement.js +48 -0
  125. package/esm/node_modules/framer-motion/dist/es/render/dom/create-visual-element.js +11 -0
  126. package/esm/node_modules/framer-motion/dist/es/render/dom/motion-proxy.js +47 -0
  127. package/esm/node_modules/framer-motion/dist/es/render/dom/motion.js +23 -0
  128. package/esm/node_modules/framer-motion/dist/es/render/dom/use-render.js +35 -0
  129. package/esm/node_modules/framer-motion/dist/es/render/dom/utils/camel-to-dash.js +6 -0
  130. package/esm/node_modules/framer-motion/dist/es/render/dom/utils/create-config.js +19 -0
  131. package/esm/node_modules/framer-motion/dist/es/render/dom/utils/css-variables-conversion.js +89 -0
  132. package/esm/node_modules/framer-motion/dist/es/render/dom/utils/filter-props.js +57 -0
  133. package/esm/node_modules/framer-motion/dist/es/render/dom/utils/is-css-variable.js +6 -0
  134. package/esm/node_modules/framer-motion/dist/es/render/dom/utils/is-svg-component.js +30 -0
  135. package/esm/node_modules/framer-motion/dist/es/render/dom/utils/is-svg-element.js +5 -0
  136. package/esm/node_modules/framer-motion/dist/es/render/dom/utils/parse-dom-variant.js +15 -0
  137. package/esm/node_modules/framer-motion/dist/es/render/dom/utils/unit-conversion.js +230 -0
  138. package/esm/node_modules/framer-motion/dist/es/render/dom/value-types/animatable-none.js +15 -0
  139. package/esm/node_modules/framer-motion/dist/es/render/dom/value-types/defaults.js +30 -0
  140. package/esm/node_modules/framer-motion/dist/es/render/dom/value-types/dimensions.js +15 -0
  141. package/esm/node_modules/framer-motion/dist/es/render/dom/value-types/find.js +15 -0
  142. package/esm/node_modules/framer-motion/dist/es/render/dom/value-types/get-as-type.js +10 -0
  143. package/esm/node_modules/framer-motion/dist/es/render/dom/value-types/number.js +72 -0
  144. package/esm/node_modules/framer-motion/dist/es/render/dom/value-types/test.js +6 -0
  145. package/esm/node_modules/framer-motion/dist/es/render/dom/value-types/type-auto.js +9 -0
  146. package/esm/node_modules/framer-motion/dist/es/render/dom/value-types/type-int.js +8 -0
  147. package/esm/node_modules/framer-motion/dist/es/render/html/HTMLVisualElement.js +55 -0
  148. package/esm/node_modules/framer-motion/dist/es/render/html/config-motion.js +12 -0
  149. package/esm/node_modules/framer-motion/dist/es/render/html/use-props.js +57 -0
  150. package/esm/node_modules/framer-motion/dist/es/render/html/utils/build-styles.js +74 -0
  151. package/esm/node_modules/framer-motion/dist/es/render/html/utils/build-transform.js +45 -0
  152. package/esm/node_modules/framer-motion/dist/es/render/html/utils/create-render-state.js +8 -0
  153. package/esm/node_modules/framer-motion/dist/es/render/html/utils/render.js +9 -0
  154. package/esm/node_modules/framer-motion/dist/es/render/html/utils/scrape-motion-values.js +17 -0
  155. package/esm/node_modules/framer-motion/dist/es/render/html/utils/transform.js +28 -0
  156. package/esm/node_modules/framer-motion/dist/es/render/store.js +3 -0
  157. package/esm/node_modules/framer-motion/dist/es/render/svg/SVGVisualElement.js +46 -0
  158. package/esm/node_modules/framer-motion/dist/es/render/svg/config-motion.js +40 -0
  159. package/esm/node_modules/framer-motion/dist/es/render/svg/lowercase-elements.js +33 -0
  160. package/esm/node_modules/framer-motion/dist/es/render/svg/use-props.js +24 -0
  161. package/esm/node_modules/framer-motion/dist/es/render/svg/utils/build-attrs.js +52 -0
  162. package/esm/node_modules/framer-motion/dist/es/render/svg/utils/camel-case-attrs.js +30 -0
  163. package/esm/node_modules/framer-motion/dist/es/render/svg/utils/create-render-state.js +8 -0
  164. package/esm/node_modules/framer-motion/dist/es/render/svg/utils/is-svg-tag.js +3 -0
  165. package/esm/node_modules/framer-motion/dist/es/render/svg/utils/path.js +32 -0
  166. package/esm/node_modules/framer-motion/dist/es/render/svg/utils/render.js +12 -0
  167. package/esm/node_modules/framer-motion/dist/es/render/svg/utils/scrape-motion-values.js +18 -0
  168. package/esm/node_modules/framer-motion/dist/es/render/svg/utils/transform-origin.js +18 -0
  169. package/esm/node_modules/framer-motion/dist/es/render/utils/animation-state.js +319 -0
  170. package/esm/node_modules/framer-motion/dist/es/render/utils/compare-by-depth.js +3 -0
  171. package/esm/node_modules/framer-motion/dist/es/render/utils/flat-tree.js +24 -0
  172. package/esm/node_modules/framer-motion/dist/es/render/utils/is-controlling-variants.js +13 -0
  173. package/esm/node_modules/framer-motion/dist/es/render/utils/is-variant-label.js +8 -0
  174. package/esm/node_modules/framer-motion/dist/es/render/utils/motion-values.js +63 -0
  175. package/esm/node_modules/framer-motion/dist/es/render/utils/resolve-dynamic-variants.js +24 -0
  176. package/esm/node_modules/framer-motion/dist/es/render/utils/resolve-variants.js +26 -0
  177. package/esm/node_modules/framer-motion/dist/es/render/utils/setters.js +101 -0
  178. package/esm/node_modules/framer-motion/dist/es/render/utils/variant-props.js +12 -0
  179. package/esm/node_modules/framer-motion/dist/es/utils/array.js +11 -0
  180. package/esm/node_modules/framer-motion/dist/es/utils/clamp.js +3 -0
  181. package/esm/node_modules/framer-motion/dist/es/utils/delay.js +19 -0
  182. package/esm/node_modules/framer-motion/dist/es/utils/distance.js +9 -0
  183. package/esm/node_modules/framer-motion/dist/es/utils/errors.js +18 -0
  184. package/esm/node_modules/framer-motion/dist/es/utils/hsla-to-rgba.js +42 -0
  185. package/esm/node_modules/framer-motion/dist/es/utils/interpolate.js +92 -0
  186. package/esm/node_modules/framer-motion/dist/es/utils/is-browser.js +3 -0
  187. package/esm/node_modules/framer-motion/dist/es/utils/is-numerical-string.js +6 -0
  188. package/esm/node_modules/framer-motion/dist/es/utils/is-ref-object.js +6 -0
  189. package/esm/node_modules/framer-motion/dist/es/utils/is-zero-value-string.js +6 -0
  190. package/esm/node_modules/framer-motion/dist/es/utils/memo.js +10 -0
  191. package/esm/node_modules/framer-motion/dist/es/utils/mix-color.js +40 -0
  192. package/esm/node_modules/framer-motion/dist/es/utils/mix-complex.js +64 -0
  193. package/esm/node_modules/framer-motion/dist/es/utils/mix.js +24 -0
  194. package/esm/node_modules/framer-motion/dist/es/utils/noop.js +3 -0
  195. package/esm/node_modules/framer-motion/dist/es/utils/offsets/default.js +9 -0
  196. package/esm/node_modules/framer-motion/dist/es/utils/offsets/fill.js +12 -0
  197. package/esm/node_modules/framer-motion/dist/es/utils/offsets/time.js +5 -0
  198. package/esm/node_modules/framer-motion/dist/es/utils/pipe.js +11 -0
  199. package/esm/node_modules/framer-motion/dist/es/utils/progress.js +18 -0
  200. package/esm/node_modules/framer-motion/dist/es/utils/reduced-motion/index.js +19 -0
  201. package/esm/node_modules/framer-motion/dist/es/utils/reduced-motion/state.js +5 -0
  202. package/esm/node_modules/framer-motion/dist/es/utils/resolve-value.js +11 -0
  203. package/esm/node_modules/framer-motion/dist/es/utils/shallow-compare.js +14 -0
  204. package/esm/node_modules/framer-motion/dist/es/utils/subscription-manager.js +40 -0
  205. package/esm/node_modules/framer-motion/dist/es/utils/time-conversion.js +10 -0
  206. package/esm/node_modules/framer-motion/dist/es/utils/use-constant.js +18 -0
  207. package/esm/node_modules/framer-motion/dist/es/utils/use-force-update.js +19 -0
  208. package/esm/node_modules/framer-motion/dist/es/utils/use-instant-transition-state.js +5 -0
  209. package/esm/node_modules/framer-motion/dist/es/utils/use-is-mounted.js +15 -0
  210. package/esm/node_modules/framer-motion/dist/es/utils/use-isomorphic-effect.js +6 -0
  211. package/esm/node_modules/framer-motion/dist/es/utils/use-unmount-effect.js +7 -0
  212. package/esm/node_modules/framer-motion/dist/es/utils/velocity-per-second.js +11 -0
  213. package/esm/node_modules/framer-motion/dist/es/utils/warn-once.js +11 -0
  214. package/esm/node_modules/framer-motion/dist/es/value/index.js +331 -0
  215. package/esm/node_modules/framer-motion/dist/es/value/types/color/hex.js +40 -0
  216. package/esm/node_modules/framer-motion/dist/es/value/types/color/hsla.js +22 -0
  217. package/esm/node_modules/framer-motion/dist/es/value/types/color/index.js +28 -0
  218. package/esm/node_modules/framer-motion/dist/es/value/types/color/rgba.js +25 -0
  219. package/esm/node_modules/framer-motion/dist/es/value/types/color/utils.js +23 -0
  220. package/esm/node_modules/framer-motion/dist/es/value/types/complex/filter.js +30 -0
  221. package/esm/node_modules/framer-motion/dist/es/value/types/complex/index.js +92 -0
  222. package/esm/node_modules/framer-motion/dist/es/value/types/numbers/index.js +17 -0
  223. package/esm/node_modules/framer-motion/dist/es/value/types/numbers/units.js +19 -0
  224. package/esm/node_modules/framer-motion/dist/es/value/types/utils.js +15 -0
  225. package/esm/node_modules/framer-motion/dist/es/value/use-will-change/is.js +7 -0
  226. package/esm/node_modules/framer-motion/dist/es/value/utils/is-motion-value.js +3 -0
  227. package/esm/node_modules/framer-motion/dist/es/value/utils/resolve-motion-value.js +16 -0
  228. package/esm/packages/icons/esm/Close.js +17 -0
  229. package/esm/packages/token-studio/esm/token/elevation/index.js +5 -1
  230. package/esm/utils/isFunction.js +3 -0
  231. package/package.json +3 -3
@@ -0,0 +1,55 @@
1
+ import { buildHTMLStyles } from './utils/build-styles.js';
2
+ import { isCSSVariableName } from '../dom/utils/is-css-variable.js';
3
+ import { transformProps } from './utils/transform.js';
4
+ import { scrapeMotionValuesFromProps } from './utils/scrape-motion-values.js';
5
+ import { renderHTML } from './utils/render.js';
6
+ import { getDefaultValueType } from '../dom/value-types/defaults.js';
7
+ import { measureViewportBox } from '../../projection/utils/measure.js';
8
+ import { DOMVisualElement } from '../dom/DOMVisualElement.js';
9
+ import { isMotionValue } from '../../value/utils/is-motion-value.js';
10
+
11
+ function getComputedStyle(element) {
12
+ return window.getComputedStyle(element);
13
+ }
14
+ class HTMLVisualElement extends DOMVisualElement {
15
+ readValueFromInstance(instance, key) {
16
+ if (transformProps.has(key)) {
17
+ const defaultType = getDefaultValueType(key);
18
+ return defaultType ? defaultType.default || 0 : 0;
19
+ }
20
+ else {
21
+ const computedStyle = getComputedStyle(instance);
22
+ const value = (isCSSVariableName(key)
23
+ ? computedStyle.getPropertyValue(key)
24
+ : computedStyle[key]) || 0;
25
+ return typeof value === "string" ? value.trim() : value;
26
+ }
27
+ }
28
+ measureInstanceViewportBox(instance, { transformPagePoint }) {
29
+ return measureViewportBox(instance, transformPagePoint);
30
+ }
31
+ build(renderState, latestValues, options, props) {
32
+ buildHTMLStyles(renderState, latestValues, options, props.transformTemplate);
33
+ }
34
+ scrapeMotionValuesFromProps(props, prevProps) {
35
+ return scrapeMotionValuesFromProps(props, prevProps);
36
+ }
37
+ handleChildMotionValue() {
38
+ if (this.childSubscription) {
39
+ this.childSubscription();
40
+ delete this.childSubscription;
41
+ }
42
+ const { children } = this.props;
43
+ if (isMotionValue(children)) {
44
+ this.childSubscription = children.on("change", (latest) => {
45
+ if (this.current)
46
+ this.current.textContent = `${latest}`;
47
+ });
48
+ }
49
+ }
50
+ renderInstance(instance, renderState, styleProp, projection) {
51
+ renderHTML(instance, renderState, styleProp, projection);
52
+ }
53
+ }
54
+
55
+ export { HTMLVisualElement, getComputedStyle };
@@ -0,0 +1,12 @@
1
+ import { makeUseVisualState } from '../../motion/utils/use-visual-state.js';
2
+ import { scrapeMotionValuesFromProps } from './utils/scrape-motion-values.js';
3
+ import { createHtmlRenderState } from './utils/create-render-state.js';
4
+
5
+ const htmlMotionConfig = {
6
+ useVisualState: makeUseVisualState({
7
+ scrapeMotionValuesFromProps,
8
+ createRenderState: createHtmlRenderState,
9
+ }),
10
+ };
11
+
12
+ export { htmlMotionConfig };
@@ -0,0 +1,57 @@
1
+ import { useMemo } from 'react';
2
+ import { isForcedMotionValue } from '../../motion/utils/is-forced-motion-value.js';
3
+ import { isMotionValue } from '../../value/utils/is-motion-value.js';
4
+ import { buildHTMLStyles } from './utils/build-styles.js';
5
+ import { createHtmlRenderState } from './utils/create-render-state.js';
6
+
7
+ function copyRawValuesOnly(target, source, props) {
8
+ for (const key in source) {
9
+ if (!isMotionValue(source[key]) && !isForcedMotionValue(key, props)) {
10
+ target[key] = source[key];
11
+ }
12
+ }
13
+ }
14
+ function useInitialMotionValues({ transformTemplate }, visualState, isStatic) {
15
+ return useMemo(() => {
16
+ const state = createHtmlRenderState();
17
+ buildHTMLStyles(state, visualState, { enableHardwareAcceleration: !isStatic }, transformTemplate);
18
+ return Object.assign({}, state.vars, state.style);
19
+ }, [visualState]);
20
+ }
21
+ function useStyle(props, visualState, isStatic) {
22
+ const styleProp = props.style || {};
23
+ const style = {};
24
+ /**
25
+ * Copy non-Motion Values straight into style
26
+ */
27
+ copyRawValuesOnly(style, styleProp, props);
28
+ Object.assign(style, useInitialMotionValues(props, visualState, isStatic));
29
+ return props.transformValues ? props.transformValues(style) : style;
30
+ }
31
+ function useHTMLProps(props, visualState, isStatic) {
32
+ // The `any` isn't ideal but it is the type of createElement props argument
33
+ const htmlProps = {};
34
+ const style = useStyle(props, visualState, isStatic);
35
+ if (props.drag && props.dragListener !== false) {
36
+ // Disable the ghost element when a user drags
37
+ htmlProps.draggable = false;
38
+ // Disable text selection
39
+ style.userSelect =
40
+ style.WebkitUserSelect =
41
+ style.WebkitTouchCallout =
42
+ "none";
43
+ // Disable scrolling on the draggable direction
44
+ style.touchAction =
45
+ props.drag === true
46
+ ? "none"
47
+ : `pan-${props.drag === "x" ? "y" : "x"}`;
48
+ }
49
+ if (props.tabIndex === undefined &&
50
+ (props.onTap || props.onTapStart || props.whileTap)) {
51
+ htmlProps.tabIndex = 0;
52
+ }
53
+ htmlProps.style = style;
54
+ return htmlProps;
55
+ }
56
+
57
+ export { copyRawValuesOnly, useHTMLProps };
@@ -0,0 +1,74 @@
1
+ import { buildTransform } from './build-transform.js';
2
+ import { isCSSVariableName } from '../../dom/utils/is-css-variable.js';
3
+ import { transformProps } from './transform.js';
4
+ import { getValueAsType } from '../../dom/value-types/get-as-type.js';
5
+ import { numberValueTypes } from '../../dom/value-types/number.js';
6
+
7
+ function buildHTMLStyles(state, latestValues, options, transformTemplate) {
8
+ const { style, vars, transform, transformOrigin } = state;
9
+ // Track whether we encounter any transform or transformOrigin values.
10
+ let hasTransform = false;
11
+ let hasTransformOrigin = false;
12
+ // Does the calculated transform essentially equal "none"?
13
+ let transformIsNone = true;
14
+ /**
15
+ * Loop over all our latest animated values and decide whether to handle them
16
+ * as a style or CSS variable.
17
+ *
18
+ * Transforms and transform origins are kept seperately for further processing.
19
+ */
20
+ for (const key in latestValues) {
21
+ const value = latestValues[key];
22
+ /**
23
+ * If this is a CSS variable we don't do any further processing.
24
+ */
25
+ if (isCSSVariableName(key)) {
26
+ vars[key] = value;
27
+ continue;
28
+ }
29
+ // Convert the value to its default value type, ie 0 -> "0px"
30
+ const valueType = numberValueTypes[key];
31
+ const valueAsType = getValueAsType(value, valueType);
32
+ if (transformProps.has(key)) {
33
+ // If this is a transform, flag to enable further transform processing
34
+ hasTransform = true;
35
+ transform[key] = valueAsType;
36
+ // If we already know we have a non-default transform, early return
37
+ if (!transformIsNone)
38
+ continue;
39
+ // Otherwise check to see if this is a default transform
40
+ if (value !== (valueType.default || 0))
41
+ transformIsNone = false;
42
+ }
43
+ else if (key.startsWith("origin")) {
44
+ // If this is a transform origin, flag and enable further transform-origin processing
45
+ hasTransformOrigin = true;
46
+ transformOrigin[key] = valueAsType;
47
+ }
48
+ else {
49
+ style[key] = valueAsType;
50
+ }
51
+ }
52
+ if (!latestValues.transform) {
53
+ if (hasTransform || transformTemplate) {
54
+ style.transform = buildTransform(state.transform, options, transformIsNone, transformTemplate);
55
+ }
56
+ else if (style.transform) {
57
+ /**
58
+ * If we have previously created a transform but currently don't have any,
59
+ * reset transform style to none.
60
+ */
61
+ style.transform = "none";
62
+ }
63
+ }
64
+ /**
65
+ * Build a transformOrigin style. Uses the same defaults as the browser for
66
+ * undefined origins.
67
+ */
68
+ if (hasTransformOrigin) {
69
+ const { originX = "50%", originY = "50%", originZ = 0, } = transformOrigin;
70
+ style.transformOrigin = `${originX} ${originY} ${originZ}`;
71
+ }
72
+ }
73
+
74
+ export { buildHTMLStyles };
@@ -0,0 +1,45 @@
1
+ import { transformPropOrder } from './transform.js';
2
+
3
+ const translateAlias = {
4
+ x: "translateX",
5
+ y: "translateY",
6
+ z: "translateZ",
7
+ transformPerspective: "perspective",
8
+ };
9
+ const numTransforms = transformPropOrder.length;
10
+ /**
11
+ * Build a CSS transform style from individual x/y/scale etc properties.
12
+ *
13
+ * This outputs with a default order of transforms/scales/rotations, this can be customised by
14
+ * providing a transformTemplate function.
15
+ */
16
+ function buildTransform(transform, { enableHardwareAcceleration = true, allowTransformNone = true, }, transformIsDefault, transformTemplate) {
17
+ // The transform string we're going to build into.
18
+ let transformString = "";
19
+ /**
20
+ * Loop over all possible transforms in order, adding the ones that
21
+ * are present to the transform string.
22
+ */
23
+ for (let i = 0; i < numTransforms; i++) {
24
+ const key = transformPropOrder[i];
25
+ if (transform[key] !== undefined) {
26
+ const transformName = translateAlias[key] || key;
27
+ transformString += `${transformName}(${transform[key]}) `;
28
+ }
29
+ }
30
+ if (enableHardwareAcceleration && !transform.z) {
31
+ transformString += "translateZ(0)";
32
+ }
33
+ transformString = transformString.trim();
34
+ // If we have a custom `transform` template, pass our transform values and
35
+ // generated transformString to that before returning
36
+ if (transformTemplate) {
37
+ transformString = transformTemplate(transform, transformIsDefault ? "" : transformString);
38
+ }
39
+ else if (allowTransformNone && transformIsDefault) {
40
+ transformString = "none";
41
+ }
42
+ return transformString;
43
+ }
44
+
45
+ export { buildTransform };
@@ -0,0 +1,8 @@
1
+ const createHtmlRenderState = () => ({
2
+ style: {},
3
+ transform: {},
4
+ transformOrigin: {},
5
+ vars: {},
6
+ });
7
+
8
+ export { createHtmlRenderState };
@@ -0,0 +1,9 @@
1
+ function renderHTML(element, { style, vars }, styleProp, projection) {
2
+ Object.assign(element.style, style, projection && projection.getProjectionStyles(styleProp));
3
+ // Loop over any CSS variables and assign those.
4
+ for (const key in vars) {
5
+ element.style.setProperty(key, vars[key]);
6
+ }
7
+ }
8
+
9
+ export { renderHTML };
@@ -0,0 +1,17 @@
1
+ import { isForcedMotionValue } from '../../../motion/utils/is-forced-motion-value.js';
2
+ import { isMotionValue } from '../../../value/utils/is-motion-value.js';
3
+
4
+ function scrapeMotionValuesFromProps(props, prevProps) {
5
+ const { style } = props;
6
+ const newValues = {};
7
+ for (const key in style) {
8
+ if (isMotionValue(style[key]) ||
9
+ (prevProps.style && isMotionValue(prevProps.style[key])) ||
10
+ isForcedMotionValue(key, props)) {
11
+ newValues[key] = style[key];
12
+ }
13
+ }
14
+ return newValues;
15
+ }
16
+
17
+ export { scrapeMotionValuesFromProps };
@@ -0,0 +1,28 @@
1
+ /**
2
+ * Generate a list of every possible transform key.
3
+ */
4
+ const transformPropOrder = [
5
+ "transformPerspective",
6
+ "x",
7
+ "y",
8
+ "z",
9
+ "translateX",
10
+ "translateY",
11
+ "translateZ",
12
+ "scale",
13
+ "scaleX",
14
+ "scaleY",
15
+ "rotate",
16
+ "rotateX",
17
+ "rotateY",
18
+ "rotateZ",
19
+ "skew",
20
+ "skewX",
21
+ "skewY",
22
+ ];
23
+ /**
24
+ * A quick lookup for transform props.
25
+ */
26
+ const transformProps = new Set(transformPropOrder);
27
+
28
+ export { transformPropOrder, transformProps };
@@ -0,0 +1,3 @@
1
+ const visualElementStore = new WeakMap();
2
+
3
+ export { visualElementStore };
@@ -0,0 +1,46 @@
1
+ import { scrapeMotionValuesFromProps } from './utils/scrape-motion-values.js';
2
+ import { DOMVisualElement } from '../dom/DOMVisualElement.js';
3
+ import { buildSVGAttrs } from './utils/build-attrs.js';
4
+ import { camelToDash } from '../dom/utils/camel-to-dash.js';
5
+ import { camelCaseAttributes } from './utils/camel-case-attrs.js';
6
+ import { transformProps } from '../html/utils/transform.js';
7
+ import { renderSVG } from './utils/render.js';
8
+ import { getDefaultValueType } from '../dom/value-types/defaults.js';
9
+ import { createBox } from '../../projection/geometry/models.js';
10
+ import { isSVGTag } from './utils/is-svg-tag.js';
11
+
12
+ class SVGVisualElement extends DOMVisualElement {
13
+ constructor() {
14
+ super(...arguments);
15
+ this.isSVGTag = false;
16
+ }
17
+ getBaseTargetFromProps(props, key) {
18
+ return props[key];
19
+ }
20
+ readValueFromInstance(instance, key) {
21
+ if (transformProps.has(key)) {
22
+ const defaultType = getDefaultValueType(key);
23
+ return defaultType ? defaultType.default || 0 : 0;
24
+ }
25
+ key = !camelCaseAttributes.has(key) ? camelToDash(key) : key;
26
+ return instance.getAttribute(key);
27
+ }
28
+ measureInstanceViewportBox() {
29
+ return createBox();
30
+ }
31
+ scrapeMotionValuesFromProps(props, prevProps) {
32
+ return scrapeMotionValuesFromProps(props, prevProps);
33
+ }
34
+ build(renderState, latestValues, options, props) {
35
+ buildSVGAttrs(renderState, latestValues, options, this.isSVGTag, props.transformTemplate);
36
+ }
37
+ renderInstance(instance, renderState, styleProp, projection) {
38
+ renderSVG(instance, renderState, styleProp, projection);
39
+ }
40
+ mount(instance) {
41
+ this.isSVGTag = isSVGTag(instance.tagName);
42
+ super.mount(instance);
43
+ }
44
+ }
45
+
46
+ export { SVGVisualElement };
@@ -0,0 +1,40 @@
1
+ import { renderSVG } from './utils/render.js';
2
+ import { scrapeMotionValuesFromProps } from './utils/scrape-motion-values.js';
3
+ import { makeUseVisualState } from '../../motion/utils/use-visual-state.js';
4
+ import { createSvgRenderState } from './utils/create-render-state.js';
5
+ import { buildSVGAttrs } from './utils/build-attrs.js';
6
+ import { isSVGTag } from './utils/is-svg-tag.js';
7
+ import { frame } from '../../frameloop/frame.js';
8
+
9
+ const svgMotionConfig = {
10
+ useVisualState: makeUseVisualState({
11
+ scrapeMotionValuesFromProps: scrapeMotionValuesFromProps,
12
+ createRenderState: createSvgRenderState,
13
+ onMount: (props, instance, { renderState, latestValues }) => {
14
+ frame.read(() => {
15
+ try {
16
+ renderState.dimensions =
17
+ typeof instance.getBBox ===
18
+ "function"
19
+ ? instance.getBBox()
20
+ : instance.getBoundingClientRect();
21
+ }
22
+ catch (e) {
23
+ // Most likely trying to measure an unrendered element under Firefox
24
+ renderState.dimensions = {
25
+ x: 0,
26
+ y: 0,
27
+ width: 0,
28
+ height: 0,
29
+ };
30
+ }
31
+ });
32
+ frame.render(() => {
33
+ buildSVGAttrs(renderState, latestValues, { enableHardwareAcceleration: false }, isSVGTag(instance.tagName), props.transformTemplate);
34
+ renderSVG(instance, renderState);
35
+ });
36
+ },
37
+ }),
38
+ };
39
+
40
+ export { svgMotionConfig };
@@ -0,0 +1,33 @@
1
+ /**
2
+ * We keep these listed seperately as we use the lowercase tag names as part
3
+ * of the runtime bundle to detect SVG components
4
+ */
5
+ const lowercaseSVGElements = [
6
+ "animate",
7
+ "circle",
8
+ "defs",
9
+ "desc",
10
+ "ellipse",
11
+ "g",
12
+ "image",
13
+ "line",
14
+ "filter",
15
+ "marker",
16
+ "mask",
17
+ "metadata",
18
+ "path",
19
+ "pattern",
20
+ "polygon",
21
+ "polyline",
22
+ "rect",
23
+ "stop",
24
+ "switch",
25
+ "symbol",
26
+ "svg",
27
+ "text",
28
+ "tspan",
29
+ "use",
30
+ "view",
31
+ ];
32
+
33
+ export { lowercaseSVGElements };
@@ -0,0 +1,24 @@
1
+ import { useMemo } from 'react';
2
+ import { copyRawValuesOnly } from '../html/use-props.js';
3
+ import { buildSVGAttrs } from './utils/build-attrs.js';
4
+ import { createSvgRenderState } from './utils/create-render-state.js';
5
+ import { isSVGTag } from './utils/is-svg-tag.js';
6
+
7
+ function useSVGProps(props, visualState, _isStatic, Component) {
8
+ const visualProps = useMemo(() => {
9
+ const state = createSvgRenderState();
10
+ buildSVGAttrs(state, visualState, { enableHardwareAcceleration: false }, isSVGTag(Component), props.transformTemplate);
11
+ return {
12
+ ...state.attrs,
13
+ style: { ...state.style },
14
+ };
15
+ }, [visualState]);
16
+ if (props.style) {
17
+ const rawStyles = {};
18
+ copyRawValuesOnly(rawStyles, props.style, props);
19
+ visualProps.style = { ...rawStyles, ...visualProps.style };
20
+ }
21
+ return visualProps;
22
+ }
23
+
24
+ export { useSVGProps };
@@ -0,0 +1,52 @@
1
+ import { buildHTMLStyles } from '../../html/utils/build-styles.js';
2
+ import { calcSVGTransformOrigin } from './transform-origin.js';
3
+ import { buildSVGPath } from './path.js';
4
+
5
+ /**
6
+ * Build SVG visual attrbutes, like cx and style.transform
7
+ */
8
+ function buildSVGAttrs(state, { attrX, attrY, attrScale, originX, originY, pathLength, pathSpacing = 1, pathOffset = 0,
9
+ // This is object creation, which we try to avoid per-frame.
10
+ ...latest }, options, isSVGTag, transformTemplate) {
11
+ buildHTMLStyles(state, latest, options, transformTemplate);
12
+ /**
13
+ * For svg tags we just want to make sure viewBox is animatable and treat all the styles
14
+ * as normal HTML tags.
15
+ */
16
+ if (isSVGTag) {
17
+ if (state.style.viewBox) {
18
+ state.attrs.viewBox = state.style.viewBox;
19
+ }
20
+ return;
21
+ }
22
+ state.attrs = state.style;
23
+ state.style = {};
24
+ const { attrs, style, dimensions } = state;
25
+ /**
26
+ * However, we apply transforms as CSS transforms. So if we detect a transform we take it from attrs
27
+ * and copy it into style.
28
+ */
29
+ if (attrs.transform) {
30
+ if (dimensions)
31
+ style.transform = attrs.transform;
32
+ delete attrs.transform;
33
+ }
34
+ // Parse transformOrigin
35
+ if (dimensions &&
36
+ (originX !== undefined || originY !== undefined || style.transform)) {
37
+ style.transformOrigin = calcSVGTransformOrigin(dimensions, originX !== undefined ? originX : 0.5, originY !== undefined ? originY : 0.5);
38
+ }
39
+ // Render attrX/attrY/attrScale as attributes
40
+ if (attrX !== undefined)
41
+ attrs.x = attrX;
42
+ if (attrY !== undefined)
43
+ attrs.y = attrY;
44
+ if (attrScale !== undefined)
45
+ attrs.scale = attrScale;
46
+ // Build SVG path if one has been defined
47
+ if (pathLength !== undefined) {
48
+ buildSVGPath(attrs, pathLength, pathSpacing, pathOffset, false);
49
+ }
50
+ }
51
+
52
+ export { buildSVGAttrs };
@@ -0,0 +1,30 @@
1
+ /**
2
+ * A set of attribute names that are always read/written as camel case.
3
+ */
4
+ const camelCaseAttributes = new Set([
5
+ "baseFrequency",
6
+ "diffuseConstant",
7
+ "kernelMatrix",
8
+ "kernelUnitLength",
9
+ "keySplines",
10
+ "keyTimes",
11
+ "limitingConeAngle",
12
+ "markerHeight",
13
+ "markerWidth",
14
+ "numOctaves",
15
+ "targetX",
16
+ "targetY",
17
+ "surfaceScale",
18
+ "specularConstant",
19
+ "specularExponent",
20
+ "stdDeviation",
21
+ "tableValues",
22
+ "viewBox",
23
+ "gradientTransform",
24
+ "pathLength",
25
+ "startOffset",
26
+ "textLength",
27
+ "lengthAdjust",
28
+ ]);
29
+
30
+ export { camelCaseAttributes };
@@ -0,0 +1,8 @@
1
+ import { createHtmlRenderState } from '../../html/utils/create-render-state.js';
2
+
3
+ const createSvgRenderState = () => ({
4
+ ...createHtmlRenderState(),
5
+ attrs: {},
6
+ });
7
+
8
+ export { createSvgRenderState };
@@ -0,0 +1,3 @@
1
+ const isSVGTag = (tag) => typeof tag === "string" && tag.toLowerCase() === "svg";
2
+
3
+ export { isSVGTag };
@@ -0,0 +1,32 @@
1
+ import { px } from '../../../value/types/numbers/units.js';
2
+
3
+ const dashKeys = {
4
+ offset: "stroke-dashoffset",
5
+ array: "stroke-dasharray",
6
+ };
7
+ const camelKeys = {
8
+ offset: "strokeDashoffset",
9
+ array: "strokeDasharray",
10
+ };
11
+ /**
12
+ * Build SVG path properties. Uses the path's measured length to convert
13
+ * our custom pathLength, pathSpacing and pathOffset into stroke-dashoffset
14
+ * and stroke-dasharray attributes.
15
+ *
16
+ * This function is mutative to reduce per-frame GC.
17
+ */
18
+ function buildSVGPath(attrs, length, spacing = 1, offset = 0, useDashCase = true) {
19
+ // Normalise path length by setting SVG attribute pathLength to 1
20
+ attrs.pathLength = 1;
21
+ // We use dash case when setting attributes directly to the DOM node and camel case
22
+ // when defining props on a React component.
23
+ const keys = useDashCase ? dashKeys : camelKeys;
24
+ // Build the dash offset
25
+ attrs[keys.offset] = px.transform(-offset);
26
+ // Build the dash array
27
+ const pathLength = px.transform(length);
28
+ const pathSpacing = px.transform(spacing);
29
+ attrs[keys.array] = `${pathLength} ${pathSpacing}`;
30
+ }
31
+
32
+ export { buildSVGPath };
@@ -0,0 +1,12 @@
1
+ import { camelToDash } from '../../dom/utils/camel-to-dash.js';
2
+ import { renderHTML } from '../../html/utils/render.js';
3
+ import { camelCaseAttributes } from './camel-case-attrs.js';
4
+
5
+ function renderSVG(element, renderState, _styleProp, projection) {
6
+ renderHTML(element, renderState, undefined, projection);
7
+ for (const key in renderState.attrs) {
8
+ element.setAttribute(!camelCaseAttributes.has(key) ? camelToDash(key) : key, renderState.attrs[key]);
9
+ }
10
+ }
11
+
12
+ export { renderSVG };
@@ -0,0 +1,18 @@
1
+ import { isMotionValue } from '../../../value/utils/is-motion-value.js';
2
+ import { scrapeMotionValuesFromProps as scrapeMotionValuesFromProps$1 } from '../../html/utils/scrape-motion-values.js';
3
+ import { transformPropOrder } from '../../html/utils/transform.js';
4
+
5
+ function scrapeMotionValuesFromProps(props, prevProps) {
6
+ const newValues = scrapeMotionValuesFromProps$1(props, prevProps);
7
+ for (const key in props) {
8
+ if (isMotionValue(props[key]) || isMotionValue(prevProps[key])) {
9
+ const targetKey = transformPropOrder.indexOf(key) !== -1
10
+ ? "attr" + key.charAt(0).toUpperCase() + key.substring(1)
11
+ : key;
12
+ newValues[targetKey] = props[key];
13
+ }
14
+ }
15
+ return newValues;
16
+ }
17
+
18
+ export { scrapeMotionValuesFromProps };
@@ -0,0 +1,18 @@
1
+ import { px } from '../../../value/types/numbers/units.js';
2
+
3
+ function calcOrigin(origin, offset, size) {
4
+ return typeof origin === "string"
5
+ ? origin
6
+ : px.transform(offset + size * origin);
7
+ }
8
+ /**
9
+ * The SVG transform origin defaults are different to CSS and is less intuitive,
10
+ * so we use the measured dimensions of the SVG to reconcile these.
11
+ */
12
+ function calcSVGTransformOrigin(dimensions, originX, originY) {
13
+ const pxOriginX = calcOrigin(originX, dimensions.x, dimensions.width);
14
+ const pxOriginY = calcOrigin(originY, dimensions.y, dimensions.height);
15
+ return `${pxOriginX} ${pxOriginY}`;
16
+ }
17
+
18
+ export { calcSVGTransformOrigin };