m.js 61 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729
  1. 'use strict';
  2. Object.defineProperty(exports, '__esModule', { value: true });
  3. var jsxRuntime = require('react/jsx-runtime');
  4. var motionUtils = require('motion-utils');
  5. var react = require('react');
  6. var motionDom = require('motion-dom');
  7. const LayoutGroupContext = react.createContext({});
  8. const LazyContext = react.createContext({ strict: false });
  9. /**
  10. * @public
  11. */
  12. const MotionConfigContext = react.createContext({
  13. transformPagePoint: (p) => p,
  14. isStatic: false,
  15. reducedMotion: "never",
  16. });
  17. const MotionContext = /* @__PURE__ */ react.createContext({});
  18. function isAnimationControls(v) {
  19. return (v !== null &&
  20. typeof v === "object" &&
  21. typeof v.start === "function");
  22. }
  23. /**
  24. * Decides if the supplied variable is variant label
  25. */
  26. function isVariantLabel(v) {
  27. return typeof v === "string" || Array.isArray(v);
  28. }
  29. const variantPriorityOrder = [
  30. "animate",
  31. "whileInView",
  32. "whileFocus",
  33. "whileHover",
  34. "whileTap",
  35. "whileDrag",
  36. "exit",
  37. ];
  38. const variantProps = ["initial", ...variantPriorityOrder];
  39. function isControllingVariants(props) {
  40. return (isAnimationControls(props.animate) ||
  41. variantProps.some((name) => isVariantLabel(props[name])));
  42. }
  43. function isVariantNode(props) {
  44. return Boolean(isControllingVariants(props) || props.variants);
  45. }
  46. function getCurrentTreeVariants(props, context) {
  47. if (isControllingVariants(props)) {
  48. const { initial, animate } = props;
  49. return {
  50. initial: initial === false || isVariantLabel(initial)
  51. ? initial
  52. : undefined,
  53. animate: isVariantLabel(animate) ? animate : undefined,
  54. };
  55. }
  56. return props.inherit !== false ? context : {};
  57. }
  58. function useCreateMotionContext(props) {
  59. const { initial, animate } = getCurrentTreeVariants(props, react.useContext(MotionContext));
  60. return react.useMemo(() => ({ initial, animate }), [variantLabelsAsDependency(initial), variantLabelsAsDependency(animate)]);
  61. }
  62. function variantLabelsAsDependency(prop) {
  63. return Array.isArray(prop) ? prop.join(" ") : prop;
  64. }
  65. const isBrowser = typeof window !== "undefined";
  66. const featureProps = {
  67. animation: [
  68. "animate",
  69. "variants",
  70. "whileHover",
  71. "whileTap",
  72. "exit",
  73. "whileInView",
  74. "whileFocus",
  75. "whileDrag",
  76. ],
  77. exit: ["exit"],
  78. drag: ["drag", "dragControls"],
  79. focus: ["whileFocus"],
  80. hover: ["whileHover", "onHoverStart", "onHoverEnd"],
  81. tap: ["whileTap", "onTap", "onTapStart", "onTapCancel"],
  82. pan: ["onPan", "onPanStart", "onPanSessionStart", "onPanEnd"],
  83. inView: ["whileInView", "onViewportEnter", "onViewportLeave"],
  84. layout: ["layout", "layoutId"],
  85. };
  86. const featureDefinitions = {};
  87. for (const key in featureProps) {
  88. featureDefinitions[key] = {
  89. isEnabled: (props) => featureProps[key].some((name) => !!props[name]),
  90. };
  91. }
  92. function loadFeatures(features) {
  93. for (const key in features) {
  94. featureDefinitions[key] = {
  95. ...featureDefinitions[key],
  96. ...features[key],
  97. };
  98. }
  99. }
  100. const motionComponentSymbol = Symbol.for("motionComponentSymbol");
  101. function isRefObject(ref) {
  102. return (ref &&
  103. typeof ref === "object" &&
  104. Object.prototype.hasOwnProperty.call(ref, "current"));
  105. }
  106. /**
  107. * Creates a ref function that, when called, hydrates the provided
  108. * external ref and VisualElement.
  109. */
  110. function useMotionRef(visualState, visualElement, externalRef) {
  111. return react.useCallback((instance) => {
  112. if (instance) {
  113. visualState.onMount && visualState.onMount(instance);
  114. }
  115. if (visualElement) {
  116. if (instance) {
  117. visualElement.mount(instance);
  118. }
  119. else {
  120. visualElement.unmount();
  121. }
  122. }
  123. if (externalRef) {
  124. if (typeof externalRef === "function") {
  125. externalRef(instance);
  126. }
  127. else if (isRefObject(externalRef)) {
  128. externalRef.current = instance;
  129. }
  130. }
  131. },
  132. /**
  133. * Only pass a new ref callback to React if we've received a visual element
  134. * factory. Otherwise we'll be mounting/remounting every time externalRef
  135. * or other dependencies change.
  136. */
  137. [visualElement]);
  138. }
  139. /**
  140. * Convert camelCase to dash-case properties.
  141. */
  142. const camelToDash = (str) => str.replace(/([a-z])([A-Z])/gu, "$1-$2").toLowerCase();
  143. const optimizedAppearDataId = "framerAppearId";
  144. const optimizedAppearDataAttribute = "data-" + camelToDash(optimizedAppearDataId);
  145. /**
  146. * @public
  147. */
  148. const PresenceContext =
  149. /* @__PURE__ */ react.createContext(null);
  150. /**
  151. * Internal, exported only for usage in Framer
  152. */
  153. const SwitchLayoutGroupContext = react.createContext({});
  154. const useIsomorphicLayoutEffect = isBrowser ? react.useLayoutEffect : react.useEffect;
  155. function useVisualElement(Component, visualState, props, createVisualElement, ProjectionNodeConstructor) {
  156. const { visualElement: parent } = react.useContext(MotionContext);
  157. const lazyContext = react.useContext(LazyContext);
  158. const presenceContext = react.useContext(PresenceContext);
  159. const reducedMotionConfig = react.useContext(MotionConfigContext).reducedMotion;
  160. const visualElementRef = react.useRef(null);
  161. /**
  162. * If we haven't preloaded a renderer, check to see if we have one lazy-loaded
  163. */
  164. createVisualElement = createVisualElement || lazyContext.renderer;
  165. if (!visualElementRef.current && createVisualElement) {
  166. visualElementRef.current = createVisualElement(Component, {
  167. visualState,
  168. parent,
  169. props,
  170. presenceContext,
  171. blockInitialAnimation: presenceContext
  172. ? presenceContext.initial === false
  173. : false,
  174. reducedMotionConfig,
  175. });
  176. }
  177. const visualElement = visualElementRef.current;
  178. /**
  179. * Load Motion gesture and animation features. These are rendered as renderless
  180. * components so each feature can optionally make use of React lifecycle methods.
  181. */
  182. const initialLayoutGroupConfig = react.useContext(SwitchLayoutGroupContext);
  183. if (visualElement &&
  184. !visualElement.projection &&
  185. ProjectionNodeConstructor &&
  186. (visualElement.type === "html" || visualElement.type === "svg")) {
  187. createProjectionNode(visualElementRef.current, props, ProjectionNodeConstructor, initialLayoutGroupConfig);
  188. }
  189. const isMounted = react.useRef(false);
  190. react.useInsertionEffect(() => {
  191. /**
  192. * Check the component has already mounted before calling
  193. * `update` unnecessarily. This ensures we skip the initial update.
  194. */
  195. if (visualElement && isMounted.current) {
  196. visualElement.update(props, presenceContext);
  197. }
  198. });
  199. /**
  200. * Cache this value as we want to know whether HandoffAppearAnimations
  201. * was present on initial render - it will be deleted after this.
  202. */
  203. const optimisedAppearId = props[optimizedAppearDataAttribute];
  204. const wantsHandoff = react.useRef(Boolean(optimisedAppearId) &&
  205. !window.MotionHandoffIsComplete?.(optimisedAppearId) &&
  206. window.MotionHasOptimisedAnimation?.(optimisedAppearId));
  207. useIsomorphicLayoutEffect(() => {
  208. if (!visualElement)
  209. return;
  210. isMounted.current = true;
  211. window.MotionIsMounted = true;
  212. visualElement.updateFeatures();
  213. motionDom.microtask.render(visualElement.render);
  214. /**
  215. * Ideally this function would always run in a useEffect.
  216. *
  217. * However, if we have optimised appear animations to handoff from,
  218. * it needs to happen synchronously to ensure there's no flash of
  219. * incorrect styles in the event of a hydration error.
  220. *
  221. * So if we detect a situtation where optimised appear animations
  222. * are running, we use useLayoutEffect to trigger animations.
  223. */
  224. if (wantsHandoff.current && visualElement.animationState) {
  225. visualElement.animationState.animateChanges();
  226. }
  227. });
  228. react.useEffect(() => {
  229. if (!visualElement)
  230. return;
  231. if (!wantsHandoff.current && visualElement.animationState) {
  232. visualElement.animationState.animateChanges();
  233. }
  234. if (wantsHandoff.current) {
  235. // This ensures all future calls to animateChanges() in this component will run in useEffect
  236. queueMicrotask(() => {
  237. window.MotionHandoffMarkAsComplete?.(optimisedAppearId);
  238. });
  239. wantsHandoff.current = false;
  240. }
  241. });
  242. return visualElement;
  243. }
  244. function createProjectionNode(visualElement, props, ProjectionNodeConstructor, initialPromotionConfig) {
  245. const { layoutId, layout, drag, dragConstraints, layoutScroll, layoutRoot, layoutCrossfade, } = props;
  246. visualElement.projection = new ProjectionNodeConstructor(visualElement.latestValues, props["data-framer-portal-id"]
  247. ? undefined
  248. : getClosestProjectingNode(visualElement.parent));
  249. visualElement.projection.setOptions({
  250. layoutId,
  251. layout,
  252. alwaysMeasureLayout: Boolean(drag) || (dragConstraints && isRefObject(dragConstraints)),
  253. visualElement,
  254. /**
  255. * TODO: Update options in an effect. This could be tricky as it'll be too late
  256. * to update by the time layout animations run.
  257. * We also need to fix this safeToRemove by linking it up to the one returned by usePresence,
  258. * ensuring it gets called if there's no potential layout animations.
  259. *
  260. */
  261. animationType: typeof layout === "string" ? layout : "both",
  262. initialPromotionConfig,
  263. crossfade: layoutCrossfade,
  264. layoutScroll,
  265. layoutRoot,
  266. });
  267. }
  268. function getClosestProjectingNode(visualElement) {
  269. if (!visualElement)
  270. return undefined;
  271. return visualElement.options.allowProjection !== false
  272. ? visualElement.projection
  273. : getClosestProjectingNode(visualElement.parent);
  274. }
  275. /**
  276. * Create a `motion` component.
  277. *
  278. * This function accepts a Component argument, which can be either a string (ie "div"
  279. * for `motion.div`), or an actual React component.
  280. *
  281. * Alongside this is a config option which provides a way of rendering the provided
  282. * component "offline", or outside the React render cycle.
  283. */
  284. function createRendererMotionComponent({ preloadedFeatures, createVisualElement, useRender, useVisualState, Component, }) {
  285. preloadedFeatures && loadFeatures(preloadedFeatures);
  286. function MotionComponent(props, externalRef) {
  287. /**
  288. * If we need to measure the element we load this functionality in a
  289. * separate class component in order to gain access to getSnapshotBeforeUpdate.
  290. */
  291. let MeasureLayout;
  292. const configAndProps = {
  293. ...react.useContext(MotionConfigContext),
  294. ...props,
  295. layoutId: useLayoutId(props),
  296. };
  297. const { isStatic } = configAndProps;
  298. const context = useCreateMotionContext(props);
  299. const visualState = useVisualState(props, isStatic);
  300. if (!isStatic && isBrowser) {
  301. useStrictMode(configAndProps, preloadedFeatures);
  302. const layoutProjection = getProjectionFunctionality(configAndProps);
  303. MeasureLayout = layoutProjection.MeasureLayout;
  304. /**
  305. * Create a VisualElement for this component. A VisualElement provides a common
  306. * interface to renderer-specific APIs (ie DOM/Three.js etc) as well as
  307. * providing a way of rendering to these APIs outside of the React render loop
  308. * for more performant animations and interactions
  309. */
  310. context.visualElement = useVisualElement(Component, visualState, configAndProps, createVisualElement, layoutProjection.ProjectionNode);
  311. }
  312. /**
  313. * The mount order and hierarchy is specific to ensure our element ref
  314. * is hydrated by the time features fire their effects.
  315. */
  316. return (jsxRuntime.jsxs(MotionContext.Provider, { value: context, children: [MeasureLayout && context.visualElement ? (jsxRuntime.jsx(MeasureLayout, { visualElement: context.visualElement, ...configAndProps })) : null, useRender(Component, props, useMotionRef(visualState, context.visualElement, externalRef), visualState, isStatic, context.visualElement)] }));
  317. }
  318. MotionComponent.displayName = `motion.${typeof Component === "string"
  319. ? Component
  320. : `create(${Component.displayName ?? Component.name ?? ""})`}`;
  321. const ForwardRefMotionComponent = react.forwardRef(MotionComponent);
  322. ForwardRefMotionComponent[motionComponentSymbol] = Component;
  323. return ForwardRefMotionComponent;
  324. }
  325. function useLayoutId({ layoutId }) {
  326. const layoutGroupId = react.useContext(LayoutGroupContext).id;
  327. return layoutGroupId && layoutId !== undefined
  328. ? layoutGroupId + "-" + layoutId
  329. : layoutId;
  330. }
  331. function useStrictMode(configAndProps, preloadedFeatures) {
  332. const isStrict = react.useContext(LazyContext).strict;
  333. /**
  334. * If we're in development mode, check to make sure we're not rendering a motion component
  335. * as a child of LazyMotion, as this will break the file-size benefits of using it.
  336. */
  337. if (process.env.NODE_ENV !== "production" &&
  338. preloadedFeatures &&
  339. isStrict) {
  340. const strictMessage = "You have rendered a `motion` component within a `LazyMotion` component. This will break tree shaking. Import and render a `m` component instead.";
  341. configAndProps.ignoreStrict
  342. ? motionUtils.warning(false, strictMessage)
  343. : motionUtils.invariant(false, strictMessage);
  344. }
  345. }
  346. function getProjectionFunctionality(props) {
  347. const { drag, layout } = featureDefinitions;
  348. if (!drag && !layout)
  349. return {};
  350. const combined = { ...drag, ...layout };
  351. return {
  352. MeasureLayout: drag?.isEnabled(props) || layout?.isEnabled(props)
  353. ? combined.MeasureLayout
  354. : undefined,
  355. ProjectionNode: combined.ProjectionNode,
  356. };
  357. }
  358. const checkStringStartsWith = (token) => (key) => typeof key === "string" && key.startsWith(token);
  359. const isCSSVariableName =
  360. /*@__PURE__*/ checkStringStartsWith("--");
  361. const scaleCorrectors = {};
  362. /**
  363. * Generate a list of every possible transform key.
  364. */
  365. const transformPropOrder = [
  366. "transformPerspective",
  367. "x",
  368. "y",
  369. "z",
  370. "translateX",
  371. "translateY",
  372. "translateZ",
  373. "scale",
  374. "scaleX",
  375. "scaleY",
  376. "rotate",
  377. "rotateX",
  378. "rotateY",
  379. "rotateZ",
  380. "skew",
  381. "skewX",
  382. "skewY",
  383. ];
  384. /**
  385. * A quick lookup for transform props.
  386. */
  387. const transformProps = new Set(transformPropOrder);
  388. function isForcedMotionValue(key, { layout, layoutId }) {
  389. return (transformProps.has(key) ||
  390. key.startsWith("origin") ||
  391. ((layout || layoutId !== undefined) &&
  392. (!!scaleCorrectors[key] || key === "opacity")));
  393. }
  394. const isMotionValue = (value) => Boolean(value && value.getVelocity);
  395. /**
  396. * Provided a value and a ValueType, returns the value as that value type.
  397. */
  398. const getValueAsType = (value, type) => {
  399. return type && typeof value === "number"
  400. ? type.transform(value)
  401. : value;
  402. };
  403. const clamp = (min, max, v) => {
  404. if (v > max)
  405. return max;
  406. if (v < min)
  407. return min;
  408. return v;
  409. };
  410. const number = {
  411. test: (v) => typeof v === "number",
  412. parse: parseFloat,
  413. transform: (v) => v,
  414. };
  415. const alpha = {
  416. ...number,
  417. transform: (v) => clamp(0, 1, v),
  418. };
  419. const scale = {
  420. ...number,
  421. default: 1,
  422. };
  423. const createUnitType = (unit) => ({
  424. test: (v) => typeof v === "string" && v.endsWith(unit) && v.split(" ").length === 1,
  425. parse: parseFloat,
  426. transform: (v) => `${v}${unit}`,
  427. });
  428. const degrees = /*@__PURE__*/ createUnitType("deg");
  429. const percent = /*@__PURE__*/ createUnitType("%");
  430. const px = /*@__PURE__*/ createUnitType("px");
  431. const progressPercentage = {
  432. ...percent,
  433. parse: (v) => percent.parse(v) / 100,
  434. transform: (v) => percent.transform(v * 100),
  435. };
  436. const browserNumberValueTypes = {
  437. // Border props
  438. borderWidth: px,
  439. borderTopWidth: px,
  440. borderRightWidth: px,
  441. borderBottomWidth: px,
  442. borderLeftWidth: px,
  443. borderRadius: px,
  444. radius: px,
  445. borderTopLeftRadius: px,
  446. borderTopRightRadius: px,
  447. borderBottomRightRadius: px,
  448. borderBottomLeftRadius: px,
  449. // Positioning props
  450. width: px,
  451. maxWidth: px,
  452. height: px,
  453. maxHeight: px,
  454. top: px,
  455. right: px,
  456. bottom: px,
  457. left: px,
  458. // Spacing props
  459. padding: px,
  460. paddingTop: px,
  461. paddingRight: px,
  462. paddingBottom: px,
  463. paddingLeft: px,
  464. margin: px,
  465. marginTop: px,
  466. marginRight: px,
  467. marginBottom: px,
  468. marginLeft: px,
  469. // Misc
  470. backgroundPositionX: px,
  471. backgroundPositionY: px,
  472. };
  473. const transformValueTypes = {
  474. rotate: degrees,
  475. rotateX: degrees,
  476. rotateY: degrees,
  477. rotateZ: degrees,
  478. scale,
  479. scaleX: scale,
  480. scaleY: scale,
  481. scaleZ: scale,
  482. skew: degrees,
  483. skewX: degrees,
  484. skewY: degrees,
  485. distance: px,
  486. translateX: px,
  487. translateY: px,
  488. translateZ: px,
  489. x: px,
  490. y: px,
  491. z: px,
  492. perspective: px,
  493. transformPerspective: px,
  494. opacity: alpha,
  495. originX: progressPercentage,
  496. originY: progressPercentage,
  497. originZ: px,
  498. };
  499. const int = {
  500. ...number,
  501. transform: Math.round,
  502. };
  503. const numberValueTypes = {
  504. ...browserNumberValueTypes,
  505. ...transformValueTypes,
  506. zIndex: int,
  507. size: px,
  508. // SVG
  509. fillOpacity: alpha,
  510. strokeOpacity: alpha,
  511. numOctaves: int,
  512. };
  513. const translateAlias = {
  514. x: "translateX",
  515. y: "translateY",
  516. z: "translateZ",
  517. transformPerspective: "perspective",
  518. };
  519. const numTransforms = transformPropOrder.length;
  520. /**
  521. * Build a CSS transform style from individual x/y/scale etc properties.
  522. *
  523. * This outputs with a default order of transforms/scales/rotations, this can be customised by
  524. * providing a transformTemplate function.
  525. */
  526. function buildTransform(latestValues, transform, transformTemplate) {
  527. // The transform string we're going to build into.
  528. let transformString = "";
  529. let transformIsDefault = true;
  530. /**
  531. * Loop over all possible transforms in order, adding the ones that
  532. * are present to the transform string.
  533. */
  534. for (let i = 0; i < numTransforms; i++) {
  535. const key = transformPropOrder[i];
  536. const value = latestValues[key];
  537. if (value === undefined)
  538. continue;
  539. let valueIsDefault = true;
  540. if (typeof value === "number") {
  541. valueIsDefault = value === (key.startsWith("scale") ? 1 : 0);
  542. }
  543. else {
  544. valueIsDefault = parseFloat(value) === 0;
  545. }
  546. if (!valueIsDefault || transformTemplate) {
  547. const valueAsType = getValueAsType(value, numberValueTypes[key]);
  548. if (!valueIsDefault) {
  549. transformIsDefault = false;
  550. const transformName = translateAlias[key] || key;
  551. transformString += `${transformName}(${valueAsType}) `;
  552. }
  553. if (transformTemplate) {
  554. transform[key] = valueAsType;
  555. }
  556. }
  557. }
  558. transformString = transformString.trim();
  559. // If we have a custom `transform` template, pass our transform values and
  560. // generated transformString to that before returning
  561. if (transformTemplate) {
  562. transformString = transformTemplate(transform, transformIsDefault ? "" : transformString);
  563. }
  564. else if (transformIsDefault) {
  565. transformString = "none";
  566. }
  567. return transformString;
  568. }
  569. function buildHTMLStyles(state, latestValues, transformTemplate) {
  570. const { style, vars, transformOrigin } = state;
  571. // Track whether we encounter any transform or transformOrigin values.
  572. let hasTransform = false;
  573. let hasTransformOrigin = false;
  574. /**
  575. * Loop over all our latest animated values and decide whether to handle them
  576. * as a style or CSS variable.
  577. *
  578. * Transforms and transform origins are kept separately for further processing.
  579. */
  580. for (const key in latestValues) {
  581. const value = latestValues[key];
  582. if (transformProps.has(key)) {
  583. // If this is a transform, flag to enable further transform processing
  584. hasTransform = true;
  585. continue;
  586. }
  587. else if (isCSSVariableName(key)) {
  588. vars[key] = value;
  589. continue;
  590. }
  591. else {
  592. // Convert the value to its default value type, ie 0 -> "0px"
  593. const valueAsType = getValueAsType(value, numberValueTypes[key]);
  594. if (key.startsWith("origin")) {
  595. // If this is a transform origin, flag and enable further transform-origin processing
  596. hasTransformOrigin = true;
  597. transformOrigin[key] =
  598. valueAsType;
  599. }
  600. else {
  601. style[key] = valueAsType;
  602. }
  603. }
  604. }
  605. if (!latestValues.transform) {
  606. if (hasTransform || transformTemplate) {
  607. style.transform = buildTransform(latestValues, state.transform, transformTemplate);
  608. }
  609. else if (style.transform) {
  610. /**
  611. * If we have previously created a transform but currently don't have any,
  612. * reset transform style to none.
  613. */
  614. style.transform = "none";
  615. }
  616. }
  617. /**
  618. * Build a transformOrigin style. Uses the same defaults as the browser for
  619. * undefined origins.
  620. */
  621. if (hasTransformOrigin) {
  622. const { originX = "50%", originY = "50%", originZ = 0, } = transformOrigin;
  623. style.transformOrigin = `${originX} ${originY} ${originZ}`;
  624. }
  625. }
  626. const createHtmlRenderState = () => ({
  627. style: {},
  628. transform: {},
  629. transformOrigin: {},
  630. vars: {},
  631. });
  632. function copyRawValuesOnly(target, source, props) {
  633. for (const key in source) {
  634. if (!isMotionValue(source[key]) && !isForcedMotionValue(key, props)) {
  635. target[key] = source[key];
  636. }
  637. }
  638. }
  639. function useInitialMotionValues({ transformTemplate }, visualState) {
  640. return react.useMemo(() => {
  641. const state = createHtmlRenderState();
  642. buildHTMLStyles(state, visualState, transformTemplate);
  643. return Object.assign({}, state.vars, state.style);
  644. }, [visualState]);
  645. }
  646. function useStyle(props, visualState) {
  647. const styleProp = props.style || {};
  648. const style = {};
  649. /**
  650. * Copy non-Motion Values straight into style
  651. */
  652. copyRawValuesOnly(style, styleProp, props);
  653. Object.assign(style, useInitialMotionValues(props, visualState));
  654. return style;
  655. }
  656. function useHTMLProps(props, visualState) {
  657. // The `any` isn't ideal but it is the type of createElement props argument
  658. const htmlProps = {};
  659. const style = useStyle(props, visualState);
  660. if (props.drag && props.dragListener !== false) {
  661. // Disable the ghost element when a user drags
  662. htmlProps.draggable = false;
  663. // Disable text selection
  664. style.userSelect =
  665. style.WebkitUserSelect =
  666. style.WebkitTouchCallout =
  667. "none";
  668. // Disable scrolling on the draggable direction
  669. style.touchAction =
  670. props.drag === true
  671. ? "none"
  672. : `pan-${props.drag === "x" ? "y" : "x"}`;
  673. }
  674. if (props.tabIndex === undefined &&
  675. (props.onTap || props.onTapStart || props.whileTap)) {
  676. htmlProps.tabIndex = 0;
  677. }
  678. htmlProps.style = style;
  679. return htmlProps;
  680. }
  681. /**
  682. * A list of all valid MotionProps.
  683. *
  684. * @privateRemarks
  685. * This doesn't throw if a `MotionProp` name is missing - it should.
  686. */
  687. const validMotionProps = new Set([
  688. "animate",
  689. "exit",
  690. "variants",
  691. "initial",
  692. "style",
  693. "values",
  694. "variants",
  695. "transition",
  696. "transformTemplate",
  697. "custom",
  698. "inherit",
  699. "onBeforeLayoutMeasure",
  700. "onAnimationStart",
  701. "onAnimationComplete",
  702. "onUpdate",
  703. "onDragStart",
  704. "onDrag",
  705. "onDragEnd",
  706. "onMeasureDragConstraints",
  707. "onDirectionLock",
  708. "onDragTransitionEnd",
  709. "_dragX",
  710. "_dragY",
  711. "onHoverStart",
  712. "onHoverEnd",
  713. "onViewportEnter",
  714. "onViewportLeave",
  715. "globalTapTarget",
  716. "ignoreStrict",
  717. "viewport",
  718. ]);
  719. /**
  720. * Check whether a prop name is a valid `MotionProp` key.
  721. *
  722. * @param key - Name of the property to check
  723. * @returns `true` is key is a valid `MotionProp`.
  724. *
  725. * @public
  726. */
  727. function isValidMotionProp(key) {
  728. return (key.startsWith("while") ||
  729. (key.startsWith("drag") && key !== "draggable") ||
  730. key.startsWith("layout") ||
  731. key.startsWith("onTap") ||
  732. key.startsWith("onPan") ||
  733. key.startsWith("onLayout") ||
  734. validMotionProps.has(key));
  735. }
  736. let shouldForward = (key) => !isValidMotionProp(key);
  737. function loadExternalIsValidProp(isValidProp) {
  738. if (!isValidProp)
  739. return;
  740. // Explicitly filter our events
  741. shouldForward = (key) => key.startsWith("on") ? !isValidMotionProp(key) : isValidProp(key);
  742. }
  743. /**
  744. * Emotion and Styled Components both allow users to pass through arbitrary props to their components
  745. * to dynamically generate CSS. They both use the `@emotion/is-prop-valid` package to determine which
  746. * of these should be passed to the underlying DOM node.
  747. *
  748. * However, when styling a Motion component `styled(motion.div)`, both packages pass through *all* props
  749. * as it's seen as an arbitrary component rather than a DOM node. Motion only allows arbitrary props
  750. * passed through the `custom` prop so it doesn't *need* the payload or computational overhead of
  751. * `@emotion/is-prop-valid`, however to fix this problem we need to use it.
  752. *
  753. * By making it an optionalDependency we can offer this functionality only in the situations where it's
  754. * actually required.
  755. */
  756. try {
  757. /**
  758. * We attempt to import this package but require won't be defined in esm environments, in that case
  759. * isPropValid will have to be provided via `MotionContext`. In a 6.0.0 this should probably be removed
  760. * in favour of explicit injection.
  761. */
  762. loadExternalIsValidProp(require("@emotion/is-prop-valid").default);
  763. }
  764. catch {
  765. // We don't need to actually do anything here - the fallback is the existing `isPropValid`.
  766. }
  767. function filterProps(props, isDom, forwardMotionProps) {
  768. const filteredProps = {};
  769. for (const key in props) {
  770. /**
  771. * values is considered a valid prop by Emotion, so if it's present
  772. * this will be rendered out to the DOM unless explicitly filtered.
  773. *
  774. * We check the type as it could be used with the `feColorMatrix`
  775. * element, which we support.
  776. */
  777. if (key === "values" && typeof props.values === "object")
  778. continue;
  779. if (shouldForward(key) ||
  780. (forwardMotionProps === true && isValidMotionProp(key)) ||
  781. (!isDom && !isValidMotionProp(key)) ||
  782. // If trying to use native HTML drag events, forward drag listeners
  783. (props["draggable"] &&
  784. key.startsWith("onDrag"))) {
  785. filteredProps[key] =
  786. props[key];
  787. }
  788. }
  789. return filteredProps;
  790. }
  791. /**
  792. * We keep these listed separately as we use the lowercase tag names as part
  793. * of the runtime bundle to detect SVG components
  794. */
  795. const lowercaseSVGElements = [
  796. "animate",
  797. "circle",
  798. "defs",
  799. "desc",
  800. "ellipse",
  801. "g",
  802. "image",
  803. "line",
  804. "filter",
  805. "marker",
  806. "mask",
  807. "metadata",
  808. "path",
  809. "pattern",
  810. "polygon",
  811. "polyline",
  812. "rect",
  813. "stop",
  814. "switch",
  815. "symbol",
  816. "svg",
  817. "text",
  818. "tspan",
  819. "use",
  820. "view",
  821. ];
  822. function isSVGComponent(Component) {
  823. if (
  824. /**
  825. * If it's not a string, it's a custom React component. Currently we only support
  826. * HTML custom React components.
  827. */
  828. typeof Component !== "string" ||
  829. /**
  830. * If it contains a dash, the element is a custom HTML webcomponent.
  831. */
  832. Component.includes("-")) {
  833. return false;
  834. }
  835. else if (
  836. /**
  837. * If it's in our list of lowercase SVG tags, it's an SVG component
  838. */
  839. lowercaseSVGElements.indexOf(Component) > -1 ||
  840. /**
  841. * If it contains a capital letter, it's an SVG component
  842. */
  843. /[A-Z]/u.test(Component)) {
  844. return true;
  845. }
  846. return false;
  847. }
  848. const dashKeys = {
  849. offset: "stroke-dashoffset",
  850. array: "stroke-dasharray",
  851. };
  852. const camelKeys = {
  853. offset: "strokeDashoffset",
  854. array: "strokeDasharray",
  855. };
  856. /**
  857. * Build SVG path properties. Uses the path's measured length to convert
  858. * our custom pathLength, pathSpacing and pathOffset into stroke-dashoffset
  859. * and stroke-dasharray attributes.
  860. *
  861. * This function is mutative to reduce per-frame GC.
  862. */
  863. function buildSVGPath(attrs, length, spacing = 1, offset = 0, useDashCase = true) {
  864. // Normalise path length by setting SVG attribute pathLength to 1
  865. attrs.pathLength = 1;
  866. // We use dash case when setting attributes directly to the DOM node and camel case
  867. // when defining props on a React component.
  868. const keys = useDashCase ? dashKeys : camelKeys;
  869. // Build the dash offset
  870. attrs[keys.offset] = px.transform(-offset);
  871. // Build the dash array
  872. const pathLength = px.transform(length);
  873. const pathSpacing = px.transform(spacing);
  874. attrs[keys.array] = `${pathLength} ${pathSpacing}`;
  875. }
  876. function calcOrigin(origin, offset, size) {
  877. return typeof origin === "string"
  878. ? origin
  879. : px.transform(offset + size * origin);
  880. }
  881. /**
  882. * The SVG transform origin defaults are different to CSS and is less intuitive,
  883. * so we use the measured dimensions of the SVG to reconcile these.
  884. */
  885. function calcSVGTransformOrigin(dimensions, originX, originY) {
  886. const pxOriginX = calcOrigin(originX, dimensions.x, dimensions.width);
  887. const pxOriginY = calcOrigin(originY, dimensions.y, dimensions.height);
  888. return `${pxOriginX} ${pxOriginY}`;
  889. }
  890. /**
  891. * Build SVG visual attrbutes, like cx and style.transform
  892. */
  893. function buildSVGAttrs(state, { attrX, attrY, attrScale, originX, originY, pathLength, pathSpacing = 1, pathOffset = 0,
  894. // This is object creation, which we try to avoid per-frame.
  895. ...latest }, isSVGTag, transformTemplate) {
  896. buildHTMLStyles(state, latest, transformTemplate);
  897. /**
  898. * For svg tags we just want to make sure viewBox is animatable and treat all the styles
  899. * as normal HTML tags.
  900. */
  901. if (isSVGTag) {
  902. if (state.style.viewBox) {
  903. state.attrs.viewBox = state.style.viewBox;
  904. }
  905. return;
  906. }
  907. state.attrs = state.style;
  908. state.style = {};
  909. const { attrs, style, dimensions } = state;
  910. /**
  911. * However, we apply transforms as CSS transforms. So if we detect a transform we take it from attrs
  912. * and copy it into style.
  913. */
  914. if (attrs.transform) {
  915. if (dimensions)
  916. style.transform = attrs.transform;
  917. delete attrs.transform;
  918. }
  919. // Parse transformOrigin
  920. if (dimensions &&
  921. (originX !== undefined || originY !== undefined || style.transform)) {
  922. style.transformOrigin = calcSVGTransformOrigin(dimensions, originX !== undefined ? originX : 0.5, originY !== undefined ? originY : 0.5);
  923. }
  924. // Render attrX/attrY/attrScale as attributes
  925. if (attrX !== undefined)
  926. attrs.x = attrX;
  927. if (attrY !== undefined)
  928. attrs.y = attrY;
  929. if (attrScale !== undefined)
  930. attrs.scale = attrScale;
  931. // Build SVG path if one has been defined
  932. if (pathLength !== undefined) {
  933. buildSVGPath(attrs, pathLength, pathSpacing, pathOffset, false);
  934. }
  935. }
  936. const createSvgRenderState = () => ({
  937. ...createHtmlRenderState(),
  938. attrs: {},
  939. });
  940. const isSVGTag = (tag) => typeof tag === "string" && tag.toLowerCase() === "svg";
  941. function useSVGProps(props, visualState, _isStatic, Component) {
  942. const visualProps = react.useMemo(() => {
  943. const state = createSvgRenderState();
  944. buildSVGAttrs(state, visualState, isSVGTag(Component), props.transformTemplate);
  945. return {
  946. ...state.attrs,
  947. style: { ...state.style },
  948. };
  949. }, [visualState]);
  950. if (props.style) {
  951. const rawStyles = {};
  952. copyRawValuesOnly(rawStyles, props.style, props);
  953. visualProps.style = { ...rawStyles, ...visualProps.style };
  954. }
  955. return visualProps;
  956. }
  957. function createUseRender(forwardMotionProps = false) {
  958. const useRender = (Component, props, ref, { latestValues }, isStatic) => {
  959. const useVisualProps = isSVGComponent(Component)
  960. ? useSVGProps
  961. : useHTMLProps;
  962. const visualProps = useVisualProps(props, latestValues, isStatic, Component);
  963. const filteredProps = filterProps(props, typeof Component === "string", forwardMotionProps);
  964. const elementProps = Component !== react.Fragment
  965. ? { ...filteredProps, ...visualProps, ref }
  966. : {};
  967. /**
  968. * If component has been handed a motion value as its child,
  969. * memoise its initial value and render that. Subsequent updates
  970. * will be handled by the onChange handler
  971. */
  972. const { children } = props;
  973. const renderedChildren = react.useMemo(() => (isMotionValue(children) ? children.get() : children), [children]);
  974. return react.createElement(Component, {
  975. ...elementProps,
  976. children: renderedChildren,
  977. });
  978. };
  979. return useRender;
  980. }
  981. function getValueState(visualElement) {
  982. const state = [{}, {}];
  983. visualElement?.values.forEach((value, key) => {
  984. state[0][key] = value.get();
  985. state[1][key] = value.getVelocity();
  986. });
  987. return state;
  988. }
  989. function resolveVariantFromProps(props, definition, custom, visualElement) {
  990. /**
  991. * If the variant definition is a function, resolve.
  992. */
  993. if (typeof definition === "function") {
  994. const [current, velocity] = getValueState(visualElement);
  995. definition = definition(custom !== undefined ? custom : props.custom, current, velocity);
  996. }
  997. /**
  998. * If the variant definition is a variant label, or
  999. * the function returned a variant label, resolve.
  1000. */
  1001. if (typeof definition === "string") {
  1002. definition = props.variants && props.variants[definition];
  1003. }
  1004. /**
  1005. * At this point we've resolved both functions and variant labels,
  1006. * but the resolved variant label might itself have been a function.
  1007. * If so, resolve. This can only have returned a valid target object.
  1008. */
  1009. if (typeof definition === "function") {
  1010. const [current, velocity] = getValueState(visualElement);
  1011. definition = definition(custom !== undefined ? custom : props.custom, current, velocity);
  1012. }
  1013. return definition;
  1014. }
  1015. /**
  1016. * Creates a constant value over the lifecycle of a component.
  1017. *
  1018. * Even if `useMemo` is provided an empty array as its final argument, it doesn't offer
  1019. * a guarantee that it won't re-run for performance reasons later on. By using `useConstant`
  1020. * you can ensure that initialisers don't execute twice or more.
  1021. */
  1022. function useConstant(init) {
  1023. const ref = react.useRef(null);
  1024. if (ref.current === null) {
  1025. ref.current = init();
  1026. }
  1027. return ref.current;
  1028. }
  1029. const isCustomValue = (v) => {
  1030. return Boolean(v && typeof v === "object" && v.mix && v.toValue);
  1031. };
  1032. /**
  1033. * If the provided value is a MotionValue, this returns the actual value, otherwise just the value itself
  1034. *
  1035. * TODO: Remove and move to library
  1036. */
  1037. function resolveMotionValue(value) {
  1038. const unwrappedValue = isMotionValue(value) ? value.get() : value;
  1039. return isCustomValue(unwrappedValue)
  1040. ? unwrappedValue.toValue()
  1041. : unwrappedValue;
  1042. }
  1043. function makeState({ scrapeMotionValuesFromProps, createRenderState, onUpdate, }, props, context, presenceContext) {
  1044. const state = {
  1045. latestValues: makeLatestValues(props, context, presenceContext, scrapeMotionValuesFromProps),
  1046. renderState: createRenderState(),
  1047. };
  1048. if (onUpdate) {
  1049. /**
  1050. * onMount works without the VisualElement because it could be
  1051. * called before the VisualElement payload has been hydrated.
  1052. * (e.g. if someone is using m components <m.circle />)
  1053. */
  1054. state.onMount = (instance) => onUpdate({ props, current: instance, ...state });
  1055. state.onUpdate = (visualElement) => onUpdate(visualElement);
  1056. }
  1057. return state;
  1058. }
  1059. const makeUseVisualState = (config) => (props, isStatic) => {
  1060. const context = react.useContext(MotionContext);
  1061. const presenceContext = react.useContext(PresenceContext);
  1062. const make = () => makeState(config, props, context, presenceContext);
  1063. return isStatic ? make() : useConstant(make);
  1064. };
  1065. function makeLatestValues(props, context, presenceContext, scrapeMotionValues) {
  1066. const values = {};
  1067. const motionValues = scrapeMotionValues(props, {});
  1068. for (const key in motionValues) {
  1069. values[key] = resolveMotionValue(motionValues[key]);
  1070. }
  1071. let { initial, animate } = props;
  1072. const isControllingVariants$1 = isControllingVariants(props);
  1073. const isVariantNode$1 = isVariantNode(props);
  1074. if (context &&
  1075. isVariantNode$1 &&
  1076. !isControllingVariants$1 &&
  1077. props.inherit !== false) {
  1078. if (initial === undefined)
  1079. initial = context.initial;
  1080. if (animate === undefined)
  1081. animate = context.animate;
  1082. }
  1083. let isInitialAnimationBlocked = presenceContext
  1084. ? presenceContext.initial === false
  1085. : false;
  1086. isInitialAnimationBlocked = isInitialAnimationBlocked || initial === false;
  1087. const variantToSet = isInitialAnimationBlocked ? animate : initial;
  1088. if (variantToSet &&
  1089. typeof variantToSet !== "boolean" &&
  1090. !isAnimationControls(variantToSet)) {
  1091. const list = Array.isArray(variantToSet) ? variantToSet : [variantToSet];
  1092. for (let i = 0; i < list.length; i++) {
  1093. const resolved = resolveVariantFromProps(props, list[i]);
  1094. if (resolved) {
  1095. const { transitionEnd, transition, ...target } = resolved;
  1096. for (const key in target) {
  1097. let valueTarget = target[key];
  1098. if (Array.isArray(valueTarget)) {
  1099. /**
  1100. * Take final keyframe if the initial animation is blocked because
  1101. * we want to initialise at the end of that blocked animation.
  1102. */
  1103. const index = isInitialAnimationBlocked
  1104. ? valueTarget.length - 1
  1105. : 0;
  1106. valueTarget = valueTarget[index];
  1107. }
  1108. if (valueTarget !== null) {
  1109. values[key] = valueTarget;
  1110. }
  1111. }
  1112. for (const key in transitionEnd) {
  1113. values[key] = transitionEnd[key];
  1114. }
  1115. }
  1116. }
  1117. }
  1118. return values;
  1119. }
  1120. function scrapeMotionValuesFromProps$1(props, prevProps, visualElement) {
  1121. const { style } = props;
  1122. const newValues = {};
  1123. for (const key in style) {
  1124. if (isMotionValue(style[key]) ||
  1125. (prevProps.style &&
  1126. isMotionValue(prevProps.style[key])) ||
  1127. isForcedMotionValue(key, props) ||
  1128. visualElement?.getValue(key)?.liveStyle !== undefined) {
  1129. newValues[key] = style[key];
  1130. }
  1131. }
  1132. return newValues;
  1133. }
  1134. const htmlMotionConfig = {
  1135. useVisualState: makeUseVisualState({
  1136. scrapeMotionValuesFromProps: scrapeMotionValuesFromProps$1,
  1137. createRenderState: createHtmlRenderState,
  1138. }),
  1139. };
  1140. function updateSVGDimensions(instance, renderState) {
  1141. try {
  1142. renderState.dimensions =
  1143. typeof instance.getBBox === "function"
  1144. ? instance.getBBox()
  1145. : instance.getBoundingClientRect();
  1146. }
  1147. catch (e) {
  1148. // Most likely trying to measure an unrendered element under Firefox
  1149. renderState.dimensions = {
  1150. x: 0,
  1151. y: 0,
  1152. width: 0,
  1153. height: 0,
  1154. };
  1155. }
  1156. }
  1157. function renderHTML(element, { style, vars }, styleProp, projection) {
  1158. Object.assign(element.style, style, projection && projection.getProjectionStyles(styleProp));
  1159. // Loop over any CSS variables and assign those.
  1160. for (const key in vars) {
  1161. element.style.setProperty(key, vars[key]);
  1162. }
  1163. }
  1164. /**
  1165. * A set of attribute names that are always read/written as camel case.
  1166. */
  1167. const camelCaseAttributes = new Set([
  1168. "baseFrequency",
  1169. "diffuseConstant",
  1170. "kernelMatrix",
  1171. "kernelUnitLength",
  1172. "keySplines",
  1173. "keyTimes",
  1174. "limitingConeAngle",
  1175. "markerHeight",
  1176. "markerWidth",
  1177. "numOctaves",
  1178. "targetX",
  1179. "targetY",
  1180. "surfaceScale",
  1181. "specularConstant",
  1182. "specularExponent",
  1183. "stdDeviation",
  1184. "tableValues",
  1185. "viewBox",
  1186. "gradientTransform",
  1187. "pathLength",
  1188. "startOffset",
  1189. "textLength",
  1190. "lengthAdjust",
  1191. ]);
  1192. function renderSVG(element, renderState, _styleProp, projection) {
  1193. renderHTML(element, renderState, undefined, projection);
  1194. for (const key in renderState.attrs) {
  1195. element.setAttribute(!camelCaseAttributes.has(key) ? camelToDash(key) : key, renderState.attrs[key]);
  1196. }
  1197. }
  1198. function scrapeMotionValuesFromProps(props, prevProps, visualElement) {
  1199. const newValues = scrapeMotionValuesFromProps$1(props, prevProps, visualElement);
  1200. for (const key in props) {
  1201. if (isMotionValue(props[key]) ||
  1202. isMotionValue(prevProps[key])) {
  1203. const targetKey = transformPropOrder.indexOf(key) !== -1
  1204. ? "attr" + key.charAt(0).toUpperCase() + key.substring(1)
  1205. : key;
  1206. newValues[targetKey] = props[key];
  1207. }
  1208. }
  1209. return newValues;
  1210. }
  1211. const layoutProps = ["x", "y", "width", "height", "cx", "cy", "r"];
  1212. const svgMotionConfig = {
  1213. useVisualState: makeUseVisualState({
  1214. scrapeMotionValuesFromProps: scrapeMotionValuesFromProps,
  1215. createRenderState: createSvgRenderState,
  1216. onUpdate: ({ props, prevProps, current, renderState, latestValues, }) => {
  1217. if (!current)
  1218. return;
  1219. let hasTransform = !!props.drag;
  1220. if (!hasTransform) {
  1221. for (const key in latestValues) {
  1222. if (transformProps.has(key)) {
  1223. hasTransform = true;
  1224. break;
  1225. }
  1226. }
  1227. }
  1228. if (!hasTransform)
  1229. return;
  1230. let needsMeasure = !prevProps;
  1231. if (prevProps) {
  1232. /**
  1233. * Check the layout props for changes, if any are found we need to
  1234. * measure the element again.
  1235. */
  1236. for (let i = 0; i < layoutProps.length; i++) {
  1237. const key = layoutProps[i];
  1238. if (props[key] !==
  1239. prevProps[key]) {
  1240. needsMeasure = true;
  1241. }
  1242. }
  1243. }
  1244. if (!needsMeasure)
  1245. return;
  1246. motionDom.frame.read(() => {
  1247. updateSVGDimensions(current, renderState);
  1248. motionDom.frame.render(() => {
  1249. buildSVGAttrs(renderState, latestValues, isSVGTag(current.tagName), props.transformTemplate);
  1250. renderSVG(current, renderState);
  1251. });
  1252. });
  1253. },
  1254. }),
  1255. };
  1256. function createMotionComponentFactory(preloadedFeatures, createVisualElement) {
  1257. return function createMotionComponent(Component, { forwardMotionProps } = { forwardMotionProps: false }) {
  1258. const baseConfig = isSVGComponent(Component)
  1259. ? svgMotionConfig
  1260. : htmlMotionConfig;
  1261. const config = {
  1262. ...baseConfig,
  1263. preloadedFeatures,
  1264. useRender: createUseRender(forwardMotionProps),
  1265. createVisualElement,
  1266. Component,
  1267. };
  1268. return createRendererMotionComponent(config);
  1269. };
  1270. }
  1271. const createMinimalMotionComponent =
  1272. /*@__PURE__*/ createMotionComponentFactory();
  1273. /**
  1274. * HTML components
  1275. */
  1276. const MotionA = /*@__PURE__*/ createMinimalMotionComponent("a");
  1277. const MotionAbbr = /*@__PURE__*/ createMinimalMotionComponent("abbr");
  1278. const MotionAddress =
  1279. /*@__PURE__*/ createMinimalMotionComponent("address");
  1280. const MotionArea = /*@__PURE__*/ createMinimalMotionComponent("area");
  1281. const MotionArticle =
  1282. /*@__PURE__*/ createMinimalMotionComponent("article");
  1283. const MotionAside = /*@__PURE__*/ createMinimalMotionComponent("aside");
  1284. const MotionAudio = /*@__PURE__*/ createMinimalMotionComponent("audio");
  1285. const MotionB = /*@__PURE__*/ createMinimalMotionComponent("b");
  1286. const MotionBase = /*@__PURE__*/ createMinimalMotionComponent("base");
  1287. const MotionBdi = /*@__PURE__*/ createMinimalMotionComponent("bdi");
  1288. const MotionBdo = /*@__PURE__*/ createMinimalMotionComponent("bdo");
  1289. const MotionBig = /*@__PURE__*/ createMinimalMotionComponent("big");
  1290. const MotionBlockquote =
  1291. /*@__PURE__*/ createMinimalMotionComponent("blockquote");
  1292. const MotionBody = /*@__PURE__*/ createMinimalMotionComponent("body");
  1293. const MotionButton = /*@__PURE__*/ createMinimalMotionComponent("button");
  1294. const MotionCanvas = /*@__PURE__*/ createMinimalMotionComponent("canvas");
  1295. const MotionCaption =
  1296. /*@__PURE__*/ createMinimalMotionComponent("caption");
  1297. const MotionCite = /*@__PURE__*/ createMinimalMotionComponent("cite");
  1298. const MotionCode = /*@__PURE__*/ createMinimalMotionComponent("code");
  1299. const MotionCol = /*@__PURE__*/ createMinimalMotionComponent("col");
  1300. const MotionColgroup =
  1301. /*@__PURE__*/ createMinimalMotionComponent("colgroup");
  1302. const MotionData = /*@__PURE__*/ createMinimalMotionComponent("data");
  1303. const MotionDatalist =
  1304. /*@__PURE__*/ createMinimalMotionComponent("datalist");
  1305. const MotionDd = /*@__PURE__*/ createMinimalMotionComponent("dd");
  1306. const MotionDel = /*@__PURE__*/ createMinimalMotionComponent("del");
  1307. const MotionDetails =
  1308. /*@__PURE__*/ createMinimalMotionComponent("details");
  1309. const MotionDfn = /*@__PURE__*/ createMinimalMotionComponent("dfn");
  1310. const MotionDialog = /*@__PURE__*/ createMinimalMotionComponent("dialog");
  1311. const MotionDiv = /*@__PURE__*/ createMinimalMotionComponent("div");
  1312. const MotionDl = /*@__PURE__*/ createMinimalMotionComponent("dl");
  1313. const MotionDt = /*@__PURE__*/ createMinimalMotionComponent("dt");
  1314. const MotionEm = /*@__PURE__*/ createMinimalMotionComponent("em");
  1315. const MotionEmbed = /*@__PURE__*/ createMinimalMotionComponent("embed");
  1316. const MotionFieldset =
  1317. /*@__PURE__*/ createMinimalMotionComponent("fieldset");
  1318. const MotionFigcaption =
  1319. /*@__PURE__*/ createMinimalMotionComponent("figcaption");
  1320. const MotionFigure = /*@__PURE__*/ createMinimalMotionComponent("figure");
  1321. const MotionFooter = /*@__PURE__*/ createMinimalMotionComponent("footer");
  1322. const MotionForm = /*@__PURE__*/ createMinimalMotionComponent("form");
  1323. const MotionH1 = /*@__PURE__*/ createMinimalMotionComponent("h1");
  1324. const MotionH2 = /*@__PURE__*/ createMinimalMotionComponent("h2");
  1325. const MotionH3 = /*@__PURE__*/ createMinimalMotionComponent("h3");
  1326. const MotionH4 = /*@__PURE__*/ createMinimalMotionComponent("h4");
  1327. const MotionH5 = /*@__PURE__*/ createMinimalMotionComponent("h5");
  1328. const MotionH6 = /*@__PURE__*/ createMinimalMotionComponent("h6");
  1329. const MotionHead = /*@__PURE__*/ createMinimalMotionComponent("head");
  1330. const MotionHeader = /*@__PURE__*/ createMinimalMotionComponent("header");
  1331. const MotionHgroup = /*@__PURE__*/ createMinimalMotionComponent("hgroup");
  1332. const MotionHr = /*@__PURE__*/ createMinimalMotionComponent("hr");
  1333. const MotionHtml = /*@__PURE__*/ createMinimalMotionComponent("html");
  1334. const MotionI = /*@__PURE__*/ createMinimalMotionComponent("i");
  1335. const MotionIframe = /*@__PURE__*/ createMinimalMotionComponent("iframe");
  1336. const MotionImg = /*@__PURE__*/ createMinimalMotionComponent("img");
  1337. const MotionInput = /*@__PURE__*/ createMinimalMotionComponent("input");
  1338. const MotionIns = /*@__PURE__*/ createMinimalMotionComponent("ins");
  1339. const MotionKbd = /*@__PURE__*/ createMinimalMotionComponent("kbd");
  1340. const MotionKeygen = /*@__PURE__*/ createMinimalMotionComponent("keygen");
  1341. const MotionLabel = /*@__PURE__*/ createMinimalMotionComponent("label");
  1342. const MotionLegend = /*@__PURE__*/ createMinimalMotionComponent("legend");
  1343. const MotionLi = /*@__PURE__*/ createMinimalMotionComponent("li");
  1344. const MotionLink = /*@__PURE__*/ createMinimalMotionComponent("link");
  1345. const MotionMain = /*@__PURE__*/ createMinimalMotionComponent("main");
  1346. const MotionMap = /*@__PURE__*/ createMinimalMotionComponent("map");
  1347. const MotionMark = /*@__PURE__*/ createMinimalMotionComponent("mark");
  1348. const MotionMenu = /*@__PURE__*/ createMinimalMotionComponent("menu");
  1349. const MotionMenuitem =
  1350. /*@__PURE__*/ createMinimalMotionComponent("menuitem");
  1351. const MotionMeter = /*@__PURE__*/ createMinimalMotionComponent("meter");
  1352. const MotionNav = /*@__PURE__*/ createMinimalMotionComponent("nav");
  1353. const MotionObject = /*@__PURE__*/ createMinimalMotionComponent("object");
  1354. const MotionOl = /*@__PURE__*/ createMinimalMotionComponent("ol");
  1355. const MotionOptgroup =
  1356. /*@__PURE__*/ createMinimalMotionComponent("optgroup");
  1357. const MotionOption = /*@__PURE__*/ createMinimalMotionComponent("option");
  1358. const MotionOutput = /*@__PURE__*/ createMinimalMotionComponent("output");
  1359. const MotionP = /*@__PURE__*/ createMinimalMotionComponent("p");
  1360. const MotionParam = /*@__PURE__*/ createMinimalMotionComponent("param");
  1361. const MotionPicture =
  1362. /*@__PURE__*/ createMinimalMotionComponent("picture");
  1363. const MotionPre = /*@__PURE__*/ createMinimalMotionComponent("pre");
  1364. const MotionProgress =
  1365. /*@__PURE__*/ createMinimalMotionComponent("progress");
  1366. const MotionQ = /*@__PURE__*/ createMinimalMotionComponent("q");
  1367. const MotionRp = /*@__PURE__*/ createMinimalMotionComponent("rp");
  1368. const MotionRt = /*@__PURE__*/ createMinimalMotionComponent("rt");
  1369. const MotionRuby = /*@__PURE__*/ createMinimalMotionComponent("ruby");
  1370. const MotionS = /*@__PURE__*/ createMinimalMotionComponent("s");
  1371. const MotionSamp = /*@__PURE__*/ createMinimalMotionComponent("samp");
  1372. const MotionScript = /*@__PURE__*/ createMinimalMotionComponent("script");
  1373. const MotionSection =
  1374. /*@__PURE__*/ createMinimalMotionComponent("section");
  1375. const MotionSelect = /*@__PURE__*/ createMinimalMotionComponent("select");
  1376. const MotionSmall = /*@__PURE__*/ createMinimalMotionComponent("small");
  1377. const MotionSource = /*@__PURE__*/ createMinimalMotionComponent("source");
  1378. const MotionSpan = /*@__PURE__*/ createMinimalMotionComponent("span");
  1379. const MotionStrong = /*@__PURE__*/ createMinimalMotionComponent("strong");
  1380. const MotionStyle = /*@__PURE__*/ createMinimalMotionComponent("style");
  1381. const MotionSub = /*@__PURE__*/ createMinimalMotionComponent("sub");
  1382. const MotionSummary =
  1383. /*@__PURE__*/ createMinimalMotionComponent("summary");
  1384. const MotionSup = /*@__PURE__*/ createMinimalMotionComponent("sup");
  1385. const MotionTable = /*@__PURE__*/ createMinimalMotionComponent("table");
  1386. const MotionTbody = /*@__PURE__*/ createMinimalMotionComponent("tbody");
  1387. const MotionTd = /*@__PURE__*/ createMinimalMotionComponent("td");
  1388. const MotionTextarea =
  1389. /*@__PURE__*/ createMinimalMotionComponent("textarea");
  1390. const MotionTfoot = /*@__PURE__*/ createMinimalMotionComponent("tfoot");
  1391. const MotionTh = /*@__PURE__*/ createMinimalMotionComponent("th");
  1392. const MotionThead = /*@__PURE__*/ createMinimalMotionComponent("thead");
  1393. const MotionTime = /*@__PURE__*/ createMinimalMotionComponent("time");
  1394. const MotionTitle = /*@__PURE__*/ createMinimalMotionComponent("title");
  1395. const MotionTr = /*@__PURE__*/ createMinimalMotionComponent("tr");
  1396. const MotionTrack = /*@__PURE__*/ createMinimalMotionComponent("track");
  1397. const MotionU = /*@__PURE__*/ createMinimalMotionComponent("u");
  1398. const MotionUl = /*@__PURE__*/ createMinimalMotionComponent("ul");
  1399. const MotionVideo = /*@__PURE__*/ createMinimalMotionComponent("video");
  1400. const MotionWbr = /*@__PURE__*/ createMinimalMotionComponent("wbr");
  1401. const MotionWebview =
  1402. /*@__PURE__*/ createMinimalMotionComponent("webview");
  1403. /**
  1404. * SVG components
  1405. */
  1406. const MotionAnimate =
  1407. /*@__PURE__*/ createMinimalMotionComponent("animate");
  1408. const MotionCircle = /*@__PURE__*/ createMinimalMotionComponent("circle");
  1409. const MotionDefs = /*@__PURE__*/ createMinimalMotionComponent("defs");
  1410. const MotionDesc = /*@__PURE__*/ createMinimalMotionComponent("desc");
  1411. const MotionEllipse =
  1412. /*@__PURE__*/ createMinimalMotionComponent("ellipse");
  1413. const MotionG = /*@__PURE__*/ createMinimalMotionComponent("g");
  1414. const MotionImage = /*@__PURE__*/ createMinimalMotionComponent("image");
  1415. const MotionLine = /*@__PURE__*/ createMinimalMotionComponent("line");
  1416. const MotionFilter = /*@__PURE__*/ createMinimalMotionComponent("filter");
  1417. const MotionMarker = /*@__PURE__*/ createMinimalMotionComponent("marker");
  1418. const MotionMask = /*@__PURE__*/ createMinimalMotionComponent("mask");
  1419. const MotionMetadata =
  1420. /*@__PURE__*/ createMinimalMotionComponent("metadata");
  1421. const MotionPath = /*@__PURE__*/ createMinimalMotionComponent("path");
  1422. const MotionPattern =
  1423. /*@__PURE__*/ createMinimalMotionComponent("pattern");
  1424. const MotionPolygon =
  1425. /*@__PURE__*/ createMinimalMotionComponent("polygon");
  1426. const MotionPolyline =
  1427. /*@__PURE__*/ createMinimalMotionComponent("polyline");
  1428. const MotionRect = /*@__PURE__*/ createMinimalMotionComponent("rect");
  1429. const MotionStop = /*@__PURE__*/ createMinimalMotionComponent("stop");
  1430. const MotionSvg = /*@__PURE__*/ createMinimalMotionComponent("svg");
  1431. const MotionSymbol = /*@__PURE__*/ createMinimalMotionComponent("symbol");
  1432. const MotionText = /*@__PURE__*/ createMinimalMotionComponent("text");
  1433. const MotionTspan = /*@__PURE__*/ createMinimalMotionComponent("tspan");
  1434. const MotionUse = /*@__PURE__*/ createMinimalMotionComponent("use");
  1435. const MotionView = /*@__PURE__*/ createMinimalMotionComponent("view");
  1436. const MotionClipPath =
  1437. /*@__PURE__*/ createMinimalMotionComponent("clipPath");
  1438. const MotionFeBlend =
  1439. /*@__PURE__*/ createMinimalMotionComponent("feBlend");
  1440. const MotionFeColorMatrix =
  1441. /*@__PURE__*/ createMinimalMotionComponent("feColorMatrix");
  1442. const MotionFeComponentTransfer =
  1443. /*@__PURE__*/ createMinimalMotionComponent("feComponentTransfer");
  1444. const MotionFeComposite =
  1445. /*@__PURE__*/ createMinimalMotionComponent("feComposite");
  1446. const MotionFeConvolveMatrix =
  1447. /*@__PURE__*/ createMinimalMotionComponent("feConvolveMatrix");
  1448. const MotionFeDiffuseLighting =
  1449. /*@__PURE__*/ createMinimalMotionComponent("feDiffuseLighting");
  1450. const MotionFeDisplacementMap =
  1451. /*@__PURE__*/ createMinimalMotionComponent("feDisplacementMap");
  1452. const MotionFeDistantLight =
  1453. /*@__PURE__*/ createMinimalMotionComponent("feDistantLight");
  1454. const MotionFeDropShadow =
  1455. /*@__PURE__*/ createMinimalMotionComponent("feDropShadow");
  1456. const MotionFeFlood =
  1457. /*@__PURE__*/ createMinimalMotionComponent("feFlood");
  1458. const MotionFeFuncA =
  1459. /*@__PURE__*/ createMinimalMotionComponent("feFuncA");
  1460. const MotionFeFuncB =
  1461. /*@__PURE__*/ createMinimalMotionComponent("feFuncB");
  1462. const MotionFeFuncG =
  1463. /*@__PURE__*/ createMinimalMotionComponent("feFuncG");
  1464. const MotionFeFuncR =
  1465. /*@__PURE__*/ createMinimalMotionComponent("feFuncR");
  1466. const MotionFeGaussianBlur =
  1467. /*@__PURE__*/ createMinimalMotionComponent("feGaussianBlur");
  1468. const MotionFeImage =
  1469. /*@__PURE__*/ createMinimalMotionComponent("feImage");
  1470. const MotionFeMerge =
  1471. /*@__PURE__*/ createMinimalMotionComponent("feMerge");
  1472. const MotionFeMergeNode =
  1473. /*@__PURE__*/ createMinimalMotionComponent("feMergeNode");
  1474. const MotionFeMorphology =
  1475. /*@__PURE__*/ createMinimalMotionComponent("feMorphology");
  1476. const MotionFeOffset =
  1477. /*@__PURE__*/ createMinimalMotionComponent("feOffset");
  1478. const MotionFePointLight =
  1479. /*@__PURE__*/ createMinimalMotionComponent("fePointLight");
  1480. const MotionFeSpecularLighting =
  1481. /*@__PURE__*/ createMinimalMotionComponent("feSpecularLighting");
  1482. const MotionFeSpotLight =
  1483. /*@__PURE__*/ createMinimalMotionComponent("feSpotLight");
  1484. const MotionFeTile = /*@__PURE__*/ createMinimalMotionComponent("feTile");
  1485. const MotionFeTurbulence =
  1486. /*@__PURE__*/ createMinimalMotionComponent("feTurbulence");
  1487. const MotionForeignObject =
  1488. /*@__PURE__*/ createMinimalMotionComponent("foreignObject");
  1489. const MotionLinearGradient =
  1490. /*@__PURE__*/ createMinimalMotionComponent("linearGradient");
  1491. const MotionRadialGradient =
  1492. /*@__PURE__*/ createMinimalMotionComponent("radialGradient");
  1493. const MotionTextPath =
  1494. /*@__PURE__*/ createMinimalMotionComponent("textPath");
  1495. exports.a = MotionA;
  1496. exports.abbr = MotionAbbr;
  1497. exports.address = MotionAddress;
  1498. exports.animate = MotionAnimate;
  1499. exports.area = MotionArea;
  1500. exports.article = MotionArticle;
  1501. exports.aside = MotionAside;
  1502. exports.audio = MotionAudio;
  1503. exports.b = MotionB;
  1504. exports.base = MotionBase;
  1505. exports.bdi = MotionBdi;
  1506. exports.bdo = MotionBdo;
  1507. exports.big = MotionBig;
  1508. exports.blockquote = MotionBlockquote;
  1509. exports.body = MotionBody;
  1510. exports.button = MotionButton;
  1511. exports.canvas = MotionCanvas;
  1512. exports.caption = MotionCaption;
  1513. exports.circle = MotionCircle;
  1514. exports.cite = MotionCite;
  1515. exports.clipPath = MotionClipPath;
  1516. exports.code = MotionCode;
  1517. exports.col = MotionCol;
  1518. exports.colgroup = MotionColgroup;
  1519. exports.create = createMinimalMotionComponent;
  1520. exports.data = MotionData;
  1521. exports.datalist = MotionDatalist;
  1522. exports.dd = MotionDd;
  1523. exports.defs = MotionDefs;
  1524. exports.del = MotionDel;
  1525. exports.desc = MotionDesc;
  1526. exports.details = MotionDetails;
  1527. exports.dfn = MotionDfn;
  1528. exports.dialog = MotionDialog;
  1529. exports.div = MotionDiv;
  1530. exports.dl = MotionDl;
  1531. exports.dt = MotionDt;
  1532. exports.ellipse = MotionEllipse;
  1533. exports.em = MotionEm;
  1534. exports.embed = MotionEmbed;
  1535. exports.feBlend = MotionFeBlend;
  1536. exports.feColorMatrix = MotionFeColorMatrix;
  1537. exports.feComponentTransfer = MotionFeComponentTransfer;
  1538. exports.feComposite = MotionFeComposite;
  1539. exports.feConvolveMatrix = MotionFeConvolveMatrix;
  1540. exports.feDiffuseLighting = MotionFeDiffuseLighting;
  1541. exports.feDisplacementMap = MotionFeDisplacementMap;
  1542. exports.feDistantLight = MotionFeDistantLight;
  1543. exports.feDropShadow = MotionFeDropShadow;
  1544. exports.feFlood = MotionFeFlood;
  1545. exports.feFuncA = MotionFeFuncA;
  1546. exports.feFuncB = MotionFeFuncB;
  1547. exports.feFuncG = MotionFeFuncG;
  1548. exports.feFuncR = MotionFeFuncR;
  1549. exports.feGaussianBlur = MotionFeGaussianBlur;
  1550. exports.feImage = MotionFeImage;
  1551. exports.feMerge = MotionFeMerge;
  1552. exports.feMergeNode = MotionFeMergeNode;
  1553. exports.feMorphology = MotionFeMorphology;
  1554. exports.feOffset = MotionFeOffset;
  1555. exports.fePointLight = MotionFePointLight;
  1556. exports.feSpecularLighting = MotionFeSpecularLighting;
  1557. exports.feSpotLight = MotionFeSpotLight;
  1558. exports.feTile = MotionFeTile;
  1559. exports.feTurbulence = MotionFeTurbulence;
  1560. exports.fieldset = MotionFieldset;
  1561. exports.figcaption = MotionFigcaption;
  1562. exports.figure = MotionFigure;
  1563. exports.filter = MotionFilter;
  1564. exports.footer = MotionFooter;
  1565. exports.foreignObject = MotionForeignObject;
  1566. exports.form = MotionForm;
  1567. exports.g = MotionG;
  1568. exports.h1 = MotionH1;
  1569. exports.h2 = MotionH2;
  1570. exports.h3 = MotionH3;
  1571. exports.h4 = MotionH4;
  1572. exports.h5 = MotionH5;
  1573. exports.h6 = MotionH6;
  1574. exports.head = MotionHead;
  1575. exports.header = MotionHeader;
  1576. exports.hgroup = MotionHgroup;
  1577. exports.hr = MotionHr;
  1578. exports.html = MotionHtml;
  1579. exports.i = MotionI;
  1580. exports.iframe = MotionIframe;
  1581. exports.image = MotionImage;
  1582. exports.img = MotionImg;
  1583. exports.input = MotionInput;
  1584. exports.ins = MotionIns;
  1585. exports.kbd = MotionKbd;
  1586. exports.keygen = MotionKeygen;
  1587. exports.label = MotionLabel;
  1588. exports.legend = MotionLegend;
  1589. exports.li = MotionLi;
  1590. exports.line = MotionLine;
  1591. exports.linearGradient = MotionLinearGradient;
  1592. exports.link = MotionLink;
  1593. exports.main = MotionMain;
  1594. exports.map = MotionMap;
  1595. exports.mark = MotionMark;
  1596. exports.marker = MotionMarker;
  1597. exports.mask = MotionMask;
  1598. exports.menu = MotionMenu;
  1599. exports.menuitem = MotionMenuitem;
  1600. exports.metadata = MotionMetadata;
  1601. exports.meter = MotionMeter;
  1602. exports.nav = MotionNav;
  1603. exports.object = MotionObject;
  1604. exports.ol = MotionOl;
  1605. exports.optgroup = MotionOptgroup;
  1606. exports.option = MotionOption;
  1607. exports.output = MotionOutput;
  1608. exports.p = MotionP;
  1609. exports.param = MotionParam;
  1610. exports.path = MotionPath;
  1611. exports.pattern = MotionPattern;
  1612. exports.picture = MotionPicture;
  1613. exports.polygon = MotionPolygon;
  1614. exports.polyline = MotionPolyline;
  1615. exports.pre = MotionPre;
  1616. exports.progress = MotionProgress;
  1617. exports.q = MotionQ;
  1618. exports.radialGradient = MotionRadialGradient;
  1619. exports.rect = MotionRect;
  1620. exports.rp = MotionRp;
  1621. exports.rt = MotionRt;
  1622. exports.ruby = MotionRuby;
  1623. exports.s = MotionS;
  1624. exports.samp = MotionSamp;
  1625. exports.script = MotionScript;
  1626. exports.section = MotionSection;
  1627. exports.select = MotionSelect;
  1628. exports.small = MotionSmall;
  1629. exports.source = MotionSource;
  1630. exports.span = MotionSpan;
  1631. exports.stop = MotionStop;
  1632. exports.strong = MotionStrong;
  1633. exports.style = MotionStyle;
  1634. exports.sub = MotionSub;
  1635. exports.summary = MotionSummary;
  1636. exports.sup = MotionSup;
  1637. exports.svg = MotionSvg;
  1638. exports.symbol = MotionSymbol;
  1639. exports.table = MotionTable;
  1640. exports.tbody = MotionTbody;
  1641. exports.td = MotionTd;
  1642. exports.text = MotionText;
  1643. exports.textPath = MotionTextPath;
  1644. exports.textarea = MotionTextarea;
  1645. exports.tfoot = MotionTfoot;
  1646. exports.th = MotionTh;
  1647. exports.thead = MotionThead;
  1648. exports.time = MotionTime;
  1649. exports.title = MotionTitle;
  1650. exports.tr = MotionTr;
  1651. exports.track = MotionTrack;
  1652. exports.tspan = MotionTspan;
  1653. exports.u = MotionU;
  1654. exports.ul = MotionUl;
  1655. exports.use = MotionUse;
  1656. exports.video = MotionVideo;
  1657. exports.view = MotionView;
  1658. exports.wbr = MotionWbr;
  1659. exports.webview = MotionWebview;