@teamturing/react-kit 2.4.0 → 2.6.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 (244) hide show
  1. package/dist/core/Button/index.d.ts +1 -1
  2. package/dist/core/Dialog/index.d.ts +16 -0
  3. package/dist/core/DialogHandler/index.d.ts +13 -0
  4. package/dist/core/GradientText/index.d.ts +11 -12
  5. package/dist/core/Grid/index.d.ts +2 -2
  6. package/dist/core/IconButton/index.d.ts +1 -1
  7. package/dist/core/ItemList/index.d.ts +2 -2
  8. package/dist/core/MotionView/index.d.ts +3 -0
  9. package/dist/core/Spinner/index.d.ts +116 -116
  10. package/dist/core/Stack/index.d.ts +2 -2
  11. package/dist/core/TextInput/index.d.ts +39 -0
  12. package/dist/core/Textarea/index.d.ts +9 -0
  13. package/dist/hook/useDialogHandler.d.ts +6 -0
  14. package/dist/index.d.ts +8 -0
  15. package/dist/index.js +10732 -593
  16. package/dist/utils/index.d.ts +1 -0
  17. package/dist/utils/isFunction.d.ts +1 -0
  18. package/esm/_virtual/index.js +3 -0
  19. package/esm/_virtual/react-is.development.js +3 -0
  20. package/esm/_virtual/react-is.production.min.js +3 -0
  21. package/esm/core/Dialog/index.js +188 -0
  22. package/esm/core/DialogHandler/index.js +33 -0
  23. package/esm/core/MotionView/index.js +6 -0
  24. package/esm/core/TextInput/index.js +220 -0
  25. package/esm/core/Textarea/index.js +158 -0
  26. package/esm/hook/useDialogHandler.js +14 -0
  27. package/esm/index.js +5 -0
  28. package/esm/node_modules/framer-motion/dist/es/animation/animators/instant.js +40 -0
  29. package/esm/node_modules/framer-motion/dist/es/animation/animators/js/driver-frameloop.js +16 -0
  30. package/esm/node_modules/framer-motion/dist/es/animation/animators/js/index.js +303 -0
  31. package/esm/node_modules/framer-motion/dist/es/animation/animators/waapi/create-accelerated-animation.js +199 -0
  32. package/esm/node_modules/framer-motion/dist/es/animation/animators/waapi/easing.js +31 -0
  33. package/esm/node_modules/framer-motion/dist/es/animation/animators/waapi/index.js +23 -0
  34. package/esm/node_modules/framer-motion/dist/es/animation/animators/waapi/utils/get-final-keyframe.js +8 -0
  35. package/esm/node_modules/framer-motion/dist/es/animation/generators/inertia.js +87 -0
  36. package/esm/node_modules/framer-motion/dist/es/animation/generators/keyframes.js +51 -0
  37. package/esm/node_modules/framer-motion/dist/es/animation/generators/spring/find.js +89 -0
  38. package/esm/node_modules/framer-motion/dist/es/animation/generators/spring/index.js +129 -0
  39. package/esm/node_modules/framer-motion/dist/es/animation/generators/utils/calc-duration.js +17 -0
  40. package/esm/node_modules/framer-motion/dist/es/animation/generators/utils/velocity.js +9 -0
  41. package/esm/node_modules/framer-motion/dist/es/animation/interfaces/motion-value.js +101 -0
  42. package/esm/node_modules/framer-motion/dist/es/animation/interfaces/single-value.js +11 -0
  43. package/esm/node_modules/framer-motion/dist/es/animation/interfaces/visual-element-target.js +71 -0
  44. package/esm/node_modules/framer-motion/dist/es/animation/interfaces/visual-element-variant.js +63 -0
  45. package/esm/node_modules/framer-motion/dist/es/animation/interfaces/visual-element.js +24 -0
  46. package/esm/node_modules/framer-motion/dist/es/animation/optimized-appear/data-id.js +6 -0
  47. package/esm/node_modules/framer-motion/dist/es/animation/utils/default-transitions.js +40 -0
  48. package/esm/node_modules/framer-motion/dist/es/animation/utils/is-animatable.js +30 -0
  49. package/esm/node_modules/framer-motion/dist/es/animation/utils/is-animation-controls.js +5 -0
  50. package/esm/node_modules/framer-motion/dist/es/animation/utils/is-keyframes-target.js +5 -0
  51. package/esm/node_modules/framer-motion/dist/es/animation/utils/is-none.js +12 -0
  52. package/esm/node_modules/framer-motion/dist/es/animation/utils/keyframes.js +45 -0
  53. package/esm/node_modules/framer-motion/dist/es/animation/utils/transitions.js +13 -0
  54. package/esm/node_modules/framer-motion/dist/es/components/AnimatePresence/PopChild.js +71 -0
  55. package/esm/node_modules/framer-motion/dist/es/components/AnimatePresence/PresenceChild.js +56 -0
  56. package/esm/node_modules/framer-motion/dist/es/components/AnimatePresence/index.js +158 -0
  57. package/esm/node_modules/framer-motion/dist/es/components/AnimatePresence/use-presence.js +40 -0
  58. package/esm/node_modules/framer-motion/dist/es/context/LayoutGroupContext.js +5 -0
  59. package/esm/node_modules/framer-motion/dist/es/context/LazyContext.js +5 -0
  60. package/esm/node_modules/framer-motion/dist/es/context/MotionConfigContext.js +12 -0
  61. package/esm/node_modules/framer-motion/dist/es/context/MotionContext/create.js +13 -0
  62. package/esm/node_modules/framer-motion/dist/es/context/MotionContext/index.js +5 -0
  63. package/esm/node_modules/framer-motion/dist/es/context/MotionContext/utils.js +17 -0
  64. package/esm/node_modules/framer-motion/dist/es/context/PresenceContext.js +8 -0
  65. package/esm/node_modules/framer-motion/dist/es/context/SwitchLayoutGroupContext.js +8 -0
  66. package/esm/node_modules/framer-motion/dist/es/debug/record.js +7 -0
  67. package/esm/node_modules/framer-motion/dist/es/easing/anticipate.js +5 -0
  68. package/esm/node_modules/framer-motion/dist/es/easing/back.js +9 -0
  69. package/esm/node_modules/framer-motion/dist/es/easing/circ.js +8 -0
  70. package/esm/node_modules/framer-motion/dist/es/easing/cubic-bezier.js +51 -0
  71. package/esm/node_modules/framer-motion/dist/es/easing/ease.js +7 -0
  72. package/esm/node_modules/framer-motion/dist/es/easing/modifiers/mirror.js +5 -0
  73. package/esm/node_modules/framer-motion/dist/es/easing/modifiers/reverse.js +5 -0
  74. package/esm/node_modules/framer-motion/dist/es/easing/utils/is-bezier-definition.js +3 -0
  75. package/esm/node_modules/framer-motion/dist/es/easing/utils/is-easing-array.js +5 -0
  76. package/esm/node_modules/framer-motion/dist/es/easing/utils/map.js +37 -0
  77. package/esm/node_modules/framer-motion/dist/es/events/add-dom-event.js +6 -0
  78. package/esm/node_modules/framer-motion/dist/es/events/add-pointer-event.js +8 -0
  79. package/esm/node_modules/framer-motion/dist/es/events/event-info.js +15 -0
  80. package/esm/node_modules/framer-motion/dist/es/events/utils/is-primary-pointer.js +18 -0
  81. package/esm/node_modules/framer-motion/dist/es/frameloop/batcher.js +60 -0
  82. package/esm/node_modules/framer-motion/dist/es/frameloop/frame.js +6 -0
  83. package/esm/node_modules/framer-motion/dist/es/frameloop/render-step.js +104 -0
  84. package/esm/node_modules/framer-motion/dist/es/gestures/drag/VisualElementDragControls.js +457 -0
  85. package/esm/node_modules/framer-motion/dist/es/gestures/drag/index.js +27 -0
  86. package/esm/node_modules/framer-motion/dist/es/gestures/drag/utils/constraints.js +125 -0
  87. package/esm/node_modules/framer-motion/dist/es/gestures/drag/utils/lock.js +53 -0
  88. package/esm/node_modules/framer-motion/dist/es/gestures/focus.js +41 -0
  89. package/esm/node_modules/framer-motion/dist/es/gestures/hover.js +32 -0
  90. package/esm/node_modules/framer-motion/dist/es/gestures/pan/PanSession.js +148 -0
  91. package/esm/node_modules/framer-motion/dist/es/gestures/pan/index.js +46 -0
  92. package/esm/node_modules/framer-motion/dist/es/gestures/press.js +120 -0
  93. package/esm/node_modules/framer-motion/dist/es/gestures/utils/is-node-or-child.js +20 -0
  94. package/esm/node_modules/framer-motion/dist/es/motion/features/Feature.js +9 -0
  95. package/esm/node_modules/framer-motion/dist/es/motion/features/animation/exit.js +31 -0
  96. package/esm/node_modules/framer-motion/dist/es/motion/features/animation/index.js +38 -0
  97. package/esm/node_modules/framer-motion/dist/es/motion/features/animations.js +13 -0
  98. package/esm/node_modules/framer-motion/dist/es/motion/features/definitions.js +28 -0
  99. package/esm/node_modules/framer-motion/dist/es/motion/features/drag.js +17 -0
  100. package/esm/node_modules/framer-motion/dist/es/motion/features/gestures.js +21 -0
  101. package/esm/node_modules/framer-motion/dist/es/motion/features/layout/MeasureLayout.js +131 -0
  102. package/esm/node_modules/framer-motion/dist/es/motion/features/layout.js +11 -0
  103. package/esm/node_modules/framer-motion/dist/es/motion/features/load-features.js +12 -0
  104. package/esm/node_modules/framer-motion/dist/es/motion/features/viewport/index.js +72 -0
  105. package/esm/node_modules/framer-motion/dist/es/motion/features/viewport/observers.js +49 -0
  106. package/esm/node_modules/framer-motion/dist/es/motion/index.js +79 -0
  107. package/esm/node_modules/framer-motion/dist/es/motion/utils/is-forced-motion-value.js +11 -0
  108. package/esm/node_modules/framer-motion/dist/es/motion/utils/symbol.js +3 -0
  109. package/esm/node_modules/framer-motion/dist/es/motion/utils/use-motion-ref.js +33 -0
  110. package/esm/node_modules/framer-motion/dist/es/motion/utils/use-visual-element.js +75 -0
  111. package/esm/node_modules/framer-motion/dist/es/motion/utils/use-visual-state.js +81 -0
  112. package/esm/node_modules/framer-motion/dist/es/motion/utils/valid-prop.js +59 -0
  113. package/esm/node_modules/framer-motion/dist/es/projection/animation/mix-values.js +93 -0
  114. package/esm/node_modules/framer-motion/dist/es/projection/geometry/conversion.js +33 -0
  115. package/esm/node_modules/framer-motion/dist/es/projection/geometry/copy.js +20 -0
  116. package/esm/node_modules/framer-motion/dist/es/projection/geometry/delta-apply.js +122 -0
  117. package/esm/node_modules/framer-motion/dist/es/projection/geometry/delta-calc.js +41 -0
  118. package/esm/node_modules/framer-motion/dist/es/projection/geometry/delta-remove.js +54 -0
  119. package/esm/node_modules/framer-motion/dist/es/projection/geometry/models.js +17 -0
  120. package/esm/node_modules/framer-motion/dist/es/projection/geometry/utils.js +25 -0
  121. package/esm/node_modules/framer-motion/dist/es/projection/node/DocumentProjectionNode.js +13 -0
  122. package/esm/node_modules/framer-motion/dist/es/projection/node/HTMLProjectionNode.js +27 -0
  123. package/esm/node_modules/framer-motion/dist/es/projection/node/create-projection-node.js +1494 -0
  124. package/esm/node_modules/framer-motion/dist/es/projection/node/state.js +19 -0
  125. package/esm/node_modules/framer-motion/dist/es/projection/shared/stack.js +112 -0
  126. package/esm/node_modules/framer-motion/dist/es/projection/styles/scale-border-radius.js +41 -0
  127. package/esm/node_modules/framer-motion/dist/es/projection/styles/scale-box-shadow.js +35 -0
  128. package/esm/node_modules/framer-motion/dist/es/projection/styles/scale-correction.js +6 -0
  129. package/esm/node_modules/framer-motion/dist/es/projection/styles/transform.js +42 -0
  130. package/esm/node_modules/framer-motion/dist/es/projection/utils/each-axis.js +5 -0
  131. package/esm/node_modules/framer-motion/dist/es/projection/utils/has-transform.js +24 -0
  132. package/esm/node_modules/framer-motion/dist/es/projection/utils/measure.js +17 -0
  133. package/esm/node_modules/framer-motion/dist/es/render/VisualElement.js +507 -0
  134. package/esm/node_modules/framer-motion/dist/es/render/dom/DOMVisualElement.js +48 -0
  135. package/esm/node_modules/framer-motion/dist/es/render/dom/create-visual-element.js +11 -0
  136. package/esm/node_modules/framer-motion/dist/es/render/dom/motion-proxy.js +47 -0
  137. package/esm/node_modules/framer-motion/dist/es/render/dom/motion.js +23 -0
  138. package/esm/node_modules/framer-motion/dist/es/render/dom/use-render.js +35 -0
  139. package/esm/node_modules/framer-motion/dist/es/render/dom/utils/camel-to-dash.js +6 -0
  140. package/esm/node_modules/framer-motion/dist/es/render/dom/utils/create-config.js +19 -0
  141. package/esm/node_modules/framer-motion/dist/es/render/dom/utils/css-variables-conversion.js +89 -0
  142. package/esm/node_modules/framer-motion/dist/es/render/dom/utils/filter-props.js +57 -0
  143. package/esm/node_modules/framer-motion/dist/es/render/dom/utils/is-css-variable.js +6 -0
  144. package/esm/node_modules/framer-motion/dist/es/render/dom/utils/is-svg-component.js +30 -0
  145. package/esm/node_modules/framer-motion/dist/es/render/dom/utils/is-svg-element.js +5 -0
  146. package/esm/node_modules/framer-motion/dist/es/render/dom/utils/parse-dom-variant.js +15 -0
  147. package/esm/node_modules/framer-motion/dist/es/render/dom/utils/unit-conversion.js +230 -0
  148. package/esm/node_modules/framer-motion/dist/es/render/dom/value-types/animatable-none.js +15 -0
  149. package/esm/node_modules/framer-motion/dist/es/render/dom/value-types/defaults.js +30 -0
  150. package/esm/node_modules/framer-motion/dist/es/render/dom/value-types/dimensions.js +15 -0
  151. package/esm/node_modules/framer-motion/dist/es/render/dom/value-types/find.js +15 -0
  152. package/esm/node_modules/framer-motion/dist/es/render/dom/value-types/get-as-type.js +10 -0
  153. package/esm/node_modules/framer-motion/dist/es/render/dom/value-types/number.js +72 -0
  154. package/esm/node_modules/framer-motion/dist/es/render/dom/value-types/test.js +6 -0
  155. package/esm/node_modules/framer-motion/dist/es/render/dom/value-types/type-auto.js +9 -0
  156. package/esm/node_modules/framer-motion/dist/es/render/dom/value-types/type-int.js +8 -0
  157. package/esm/node_modules/framer-motion/dist/es/render/html/HTMLVisualElement.js +55 -0
  158. package/esm/node_modules/framer-motion/dist/es/render/html/config-motion.js +12 -0
  159. package/esm/node_modules/framer-motion/dist/es/render/html/use-props.js +57 -0
  160. package/esm/node_modules/framer-motion/dist/es/render/html/utils/build-styles.js +74 -0
  161. package/esm/node_modules/framer-motion/dist/es/render/html/utils/build-transform.js +45 -0
  162. package/esm/node_modules/framer-motion/dist/es/render/html/utils/create-render-state.js +8 -0
  163. package/esm/node_modules/framer-motion/dist/es/render/html/utils/render.js +9 -0
  164. package/esm/node_modules/framer-motion/dist/es/render/html/utils/scrape-motion-values.js +17 -0
  165. package/esm/node_modules/framer-motion/dist/es/render/html/utils/transform.js +28 -0
  166. package/esm/node_modules/framer-motion/dist/es/render/store.js +3 -0
  167. package/esm/node_modules/framer-motion/dist/es/render/svg/SVGVisualElement.js +46 -0
  168. package/esm/node_modules/framer-motion/dist/es/render/svg/config-motion.js +40 -0
  169. package/esm/node_modules/framer-motion/dist/es/render/svg/lowercase-elements.js +33 -0
  170. package/esm/node_modules/framer-motion/dist/es/render/svg/use-props.js +24 -0
  171. package/esm/node_modules/framer-motion/dist/es/render/svg/utils/build-attrs.js +52 -0
  172. package/esm/node_modules/framer-motion/dist/es/render/svg/utils/camel-case-attrs.js +30 -0
  173. package/esm/node_modules/framer-motion/dist/es/render/svg/utils/create-render-state.js +8 -0
  174. package/esm/node_modules/framer-motion/dist/es/render/svg/utils/is-svg-tag.js +3 -0
  175. package/esm/node_modules/framer-motion/dist/es/render/svg/utils/path.js +32 -0
  176. package/esm/node_modules/framer-motion/dist/es/render/svg/utils/render.js +12 -0
  177. package/esm/node_modules/framer-motion/dist/es/render/svg/utils/scrape-motion-values.js +18 -0
  178. package/esm/node_modules/framer-motion/dist/es/render/svg/utils/transform-origin.js +18 -0
  179. package/esm/node_modules/framer-motion/dist/es/render/utils/animation-state.js +319 -0
  180. package/esm/node_modules/framer-motion/dist/es/render/utils/compare-by-depth.js +3 -0
  181. package/esm/node_modules/framer-motion/dist/es/render/utils/flat-tree.js +24 -0
  182. package/esm/node_modules/framer-motion/dist/es/render/utils/is-controlling-variants.js +13 -0
  183. package/esm/node_modules/framer-motion/dist/es/render/utils/is-variant-label.js +8 -0
  184. package/esm/node_modules/framer-motion/dist/es/render/utils/motion-values.js +63 -0
  185. package/esm/node_modules/framer-motion/dist/es/render/utils/resolve-dynamic-variants.js +24 -0
  186. package/esm/node_modules/framer-motion/dist/es/render/utils/resolve-variants.js +26 -0
  187. package/esm/node_modules/framer-motion/dist/es/render/utils/setters.js +101 -0
  188. package/esm/node_modules/framer-motion/dist/es/render/utils/variant-props.js +12 -0
  189. package/esm/node_modules/framer-motion/dist/es/utils/array.js +11 -0
  190. package/esm/node_modules/framer-motion/dist/es/utils/clamp.js +3 -0
  191. package/esm/node_modules/framer-motion/dist/es/utils/delay.js +19 -0
  192. package/esm/node_modules/framer-motion/dist/es/utils/distance.js +9 -0
  193. package/esm/node_modules/framer-motion/dist/es/utils/errors.js +18 -0
  194. package/esm/node_modules/framer-motion/dist/es/utils/hsla-to-rgba.js +42 -0
  195. package/esm/node_modules/framer-motion/dist/es/utils/interpolate.js +92 -0
  196. package/esm/node_modules/framer-motion/dist/es/utils/is-browser.js +3 -0
  197. package/esm/node_modules/framer-motion/dist/es/utils/is-numerical-string.js +6 -0
  198. package/esm/node_modules/framer-motion/dist/es/utils/is-ref-object.js +6 -0
  199. package/esm/node_modules/framer-motion/dist/es/utils/is-zero-value-string.js +6 -0
  200. package/esm/node_modules/framer-motion/dist/es/utils/memo.js +10 -0
  201. package/esm/node_modules/framer-motion/dist/es/utils/mix-color.js +40 -0
  202. package/esm/node_modules/framer-motion/dist/es/utils/mix-complex.js +64 -0
  203. package/esm/node_modules/framer-motion/dist/es/utils/mix.js +24 -0
  204. package/esm/node_modules/framer-motion/dist/es/utils/noop.js +3 -0
  205. package/esm/node_modules/framer-motion/dist/es/utils/offsets/default.js +9 -0
  206. package/esm/node_modules/framer-motion/dist/es/utils/offsets/fill.js +12 -0
  207. package/esm/node_modules/framer-motion/dist/es/utils/offsets/time.js +5 -0
  208. package/esm/node_modules/framer-motion/dist/es/utils/pipe.js +11 -0
  209. package/esm/node_modules/framer-motion/dist/es/utils/progress.js +18 -0
  210. package/esm/node_modules/framer-motion/dist/es/utils/reduced-motion/index.js +19 -0
  211. package/esm/node_modules/framer-motion/dist/es/utils/reduced-motion/state.js +5 -0
  212. package/esm/node_modules/framer-motion/dist/es/utils/resolve-value.js +11 -0
  213. package/esm/node_modules/framer-motion/dist/es/utils/shallow-compare.js +14 -0
  214. package/esm/node_modules/framer-motion/dist/es/utils/subscription-manager.js +40 -0
  215. package/esm/node_modules/framer-motion/dist/es/utils/time-conversion.js +10 -0
  216. package/esm/node_modules/framer-motion/dist/es/utils/use-constant.js +18 -0
  217. package/esm/node_modules/framer-motion/dist/es/utils/use-force-update.js +19 -0
  218. package/esm/node_modules/framer-motion/dist/es/utils/use-instant-transition-state.js +5 -0
  219. package/esm/node_modules/framer-motion/dist/es/utils/use-is-mounted.js +15 -0
  220. package/esm/node_modules/framer-motion/dist/es/utils/use-isomorphic-effect.js +6 -0
  221. package/esm/node_modules/framer-motion/dist/es/utils/use-unmount-effect.js +7 -0
  222. package/esm/node_modules/framer-motion/dist/es/utils/velocity-per-second.js +11 -0
  223. package/esm/node_modules/framer-motion/dist/es/utils/warn-once.js +11 -0
  224. package/esm/node_modules/framer-motion/dist/es/value/index.js +331 -0
  225. package/esm/node_modules/framer-motion/dist/es/value/types/color/hex.js +40 -0
  226. package/esm/node_modules/framer-motion/dist/es/value/types/color/hsla.js +22 -0
  227. package/esm/node_modules/framer-motion/dist/es/value/types/color/index.js +28 -0
  228. package/esm/node_modules/framer-motion/dist/es/value/types/color/rgba.js +25 -0
  229. package/esm/node_modules/framer-motion/dist/es/value/types/color/utils.js +23 -0
  230. package/esm/node_modules/framer-motion/dist/es/value/types/complex/filter.js +30 -0
  231. package/esm/node_modules/framer-motion/dist/es/value/types/complex/index.js +92 -0
  232. package/esm/node_modules/framer-motion/dist/es/value/types/numbers/index.js +17 -0
  233. package/esm/node_modules/framer-motion/dist/es/value/types/numbers/units.js +19 -0
  234. package/esm/node_modules/framer-motion/dist/es/value/types/utils.js +15 -0
  235. package/esm/node_modules/framer-motion/dist/es/value/use-will-change/is.js +7 -0
  236. package/esm/node_modules/framer-motion/dist/es/value/utils/is-motion-value.js +3 -0
  237. package/esm/node_modules/framer-motion/dist/es/value/utils/resolve-motion-value.js +16 -0
  238. package/esm/node_modules/react-is/cjs/react-is.development.js +211 -0
  239. package/esm/node_modules/react-is/cjs/react-is.production.min.js +123 -0
  240. package/esm/node_modules/react-is/index.js +12 -0
  241. package/esm/packages/icons/esm/Close.js +17 -0
  242. package/esm/packages/token-studio/esm/token/elevation/index.js +5 -1
  243. package/esm/utils/isFunction.js +3 -0
  244. package/package.json +5 -3
@@ -0,0 +1,457 @@
1
+ import { invariant } from '../../utils/errors.js';
2
+ import { PanSession } from '../pan/PanSession.js';
3
+ import { getGlobalLock } from './utils/lock.js';
4
+ import { isRefObject } from '../../utils/is-ref-object.js';
5
+ import { addPointerEvent } from '../../events/add-pointer-event.js';
6
+ import { applyConstraints, calcRelativeConstraints, resolveDragElastic, calcViewportConstraints, rebaseAxisConstraints, calcOrigin, defaultElastic } from './utils/constraints.js';
7
+ import { createBox } from '../../projection/geometry/models.js';
8
+ import { eachAxis } from '../../projection/utils/each-axis.js';
9
+ import { measurePageBox } from '../../projection/utils/measure.js';
10
+ import { extractEventInfo } from '../../events/event-info.js';
11
+ import { convertBoxToBoundingBox, convertBoundingBoxToBox } from '../../projection/geometry/conversion.js';
12
+ import { addDomEvent } from '../../events/add-dom-event.js';
13
+ import { calcLength } from '../../projection/geometry/delta-calc.js';
14
+ import { mix } from '../../utils/mix.js';
15
+ import { percent } from '../../value/types/numbers/units.js';
16
+ import { animateMotionValue } from '../../animation/interfaces/motion-value.js';
17
+ import { frame } from '../../frameloop/frame.js';
18
+
19
+ const elementDragControls = new WeakMap();
20
+ /**
21
+ *
22
+ */
23
+ // let latestPointerEvent: PointerEvent
24
+ class VisualElementDragControls {
25
+ constructor(visualElement) {
26
+ // This is a reference to the global drag gesture lock, ensuring only one component
27
+ // can "capture" the drag of one or both axes.
28
+ // TODO: Look into moving this into pansession?
29
+ this.openGlobalLock = null;
30
+ this.isDragging = false;
31
+ this.currentDirection = null;
32
+ this.originPoint = { x: 0, y: 0 };
33
+ /**
34
+ * The permitted boundaries of travel, in pixels.
35
+ */
36
+ this.constraints = false;
37
+ this.hasMutatedConstraints = false;
38
+ /**
39
+ * The per-axis resolved elastic values.
40
+ */
41
+ this.elastic = createBox();
42
+ this.visualElement = visualElement;
43
+ }
44
+ start(originEvent, { snapToCursor = false } = {}) {
45
+ /**
46
+ * Don't start dragging if this component is exiting
47
+ */
48
+ const { presenceContext } = this.visualElement;
49
+ if (presenceContext && presenceContext.isPresent === false)
50
+ return;
51
+ const onSessionStart = (event) => {
52
+ // Stop any animations on both axis values immediately. This allows the user to throw and catch
53
+ // the component.
54
+ this.stopAnimation();
55
+ if (snapToCursor) {
56
+ this.snapToCursor(extractEventInfo(event, "page").point);
57
+ }
58
+ };
59
+ const onStart = (event, info) => {
60
+ // Attempt to grab the global drag gesture lock - maybe make this part of PanSession
61
+ const { drag, dragPropagation, onDragStart } = this.getProps();
62
+ if (drag && !dragPropagation) {
63
+ if (this.openGlobalLock)
64
+ this.openGlobalLock();
65
+ this.openGlobalLock = getGlobalLock(drag);
66
+ // If we don 't have the lock, don't start dragging
67
+ if (!this.openGlobalLock)
68
+ return;
69
+ }
70
+ this.isDragging = true;
71
+ this.currentDirection = null;
72
+ this.resolveConstraints();
73
+ if (this.visualElement.projection) {
74
+ this.visualElement.projection.isAnimationBlocked = true;
75
+ this.visualElement.projection.target = undefined;
76
+ }
77
+ /**
78
+ * Record gesture origin
79
+ */
80
+ eachAxis((axis) => {
81
+ let current = this.getAxisMotionValue(axis).get() || 0;
82
+ /**
83
+ * If the MotionValue is a percentage value convert to px
84
+ */
85
+ if (percent.test(current)) {
86
+ const { projection } = this.visualElement;
87
+ if (projection && projection.layout) {
88
+ const measuredAxis = projection.layout.layoutBox[axis];
89
+ if (measuredAxis) {
90
+ const length = calcLength(measuredAxis);
91
+ current = length * (parseFloat(current) / 100);
92
+ }
93
+ }
94
+ }
95
+ this.originPoint[axis] = current;
96
+ });
97
+ // Fire onDragStart event
98
+ if (onDragStart) {
99
+ frame.update(() => onDragStart(event, info), false, true);
100
+ }
101
+ const { animationState } = this.visualElement;
102
+ animationState && animationState.setActive("whileDrag", true);
103
+ };
104
+ const onMove = (event, info) => {
105
+ // latestPointerEvent = event
106
+ const { dragPropagation, dragDirectionLock, onDirectionLock, onDrag, } = this.getProps();
107
+ // If we didn't successfully receive the gesture lock, early return.
108
+ if (!dragPropagation && !this.openGlobalLock)
109
+ return;
110
+ const { offset } = info;
111
+ // Attempt to detect drag direction if directionLock is true
112
+ if (dragDirectionLock && this.currentDirection === null) {
113
+ this.currentDirection = getCurrentDirection(offset);
114
+ // If we've successfully set a direction, notify listener
115
+ if (this.currentDirection !== null) {
116
+ onDirectionLock && onDirectionLock(this.currentDirection);
117
+ }
118
+ return;
119
+ }
120
+ // Update each point with the latest position
121
+ this.updateAxis("x", info.point, offset);
122
+ this.updateAxis("y", info.point, offset);
123
+ /**
124
+ * Ideally we would leave the renderer to fire naturally at the end of
125
+ * this frame but if the element is about to change layout as the result
126
+ * of a re-render we want to ensure the browser can read the latest
127
+ * bounding box to ensure the pointer and element don't fall out of sync.
128
+ */
129
+ this.visualElement.render();
130
+ /**
131
+ * This must fire after the render call as it might trigger a state
132
+ * change which itself might trigger a layout update.
133
+ */
134
+ onDrag && onDrag(event, info);
135
+ };
136
+ const onSessionEnd = (event, info) => this.stop(event, info);
137
+ this.panSession = new PanSession(originEvent, {
138
+ onSessionStart,
139
+ onStart,
140
+ onMove,
141
+ onSessionEnd,
142
+ }, { transformPagePoint: this.visualElement.getTransformPagePoint() });
143
+ }
144
+ stop(event, info) {
145
+ const isDragging = this.isDragging;
146
+ this.cancel();
147
+ if (!isDragging)
148
+ return;
149
+ const { velocity } = info;
150
+ this.startAnimation(velocity);
151
+ const { onDragEnd } = this.getProps();
152
+ if (onDragEnd) {
153
+ frame.update(() => onDragEnd(event, info));
154
+ }
155
+ }
156
+ cancel() {
157
+ this.isDragging = false;
158
+ const { projection, animationState } = this.visualElement;
159
+ if (projection) {
160
+ projection.isAnimationBlocked = false;
161
+ }
162
+ this.panSession && this.panSession.end();
163
+ this.panSession = undefined;
164
+ const { dragPropagation } = this.getProps();
165
+ if (!dragPropagation && this.openGlobalLock) {
166
+ this.openGlobalLock();
167
+ this.openGlobalLock = null;
168
+ }
169
+ animationState && animationState.setActive("whileDrag", false);
170
+ }
171
+ updateAxis(axis, _point, offset) {
172
+ const { drag } = this.getProps();
173
+ // If we're not dragging this axis, do an early return.
174
+ if (!offset || !shouldDrag(axis, drag, this.currentDirection))
175
+ return;
176
+ const axisValue = this.getAxisMotionValue(axis);
177
+ let next = this.originPoint[axis] + offset[axis];
178
+ // Apply constraints
179
+ if (this.constraints && this.constraints[axis]) {
180
+ next = applyConstraints(next, this.constraints[axis], this.elastic[axis]);
181
+ }
182
+ axisValue.set(next);
183
+ }
184
+ resolveConstraints() {
185
+ const { dragConstraints, dragElastic } = this.getProps();
186
+ const { layout } = this.visualElement.projection || {};
187
+ const prevConstraints = this.constraints;
188
+ if (dragConstraints && isRefObject(dragConstraints)) {
189
+ if (!this.constraints) {
190
+ this.constraints = this.resolveRefConstraints();
191
+ }
192
+ }
193
+ else {
194
+ if (dragConstraints && layout) {
195
+ this.constraints = calcRelativeConstraints(layout.layoutBox, dragConstraints);
196
+ }
197
+ else {
198
+ this.constraints = false;
199
+ }
200
+ }
201
+ this.elastic = resolveDragElastic(dragElastic);
202
+ /**
203
+ * If we're outputting to external MotionValues, we want to rebase the measured constraints
204
+ * from viewport-relative to component-relative.
205
+ */
206
+ if (prevConstraints !== this.constraints &&
207
+ layout &&
208
+ this.constraints &&
209
+ !this.hasMutatedConstraints) {
210
+ eachAxis((axis) => {
211
+ if (this.getAxisMotionValue(axis)) {
212
+ this.constraints[axis] = rebaseAxisConstraints(layout.layoutBox[axis], this.constraints[axis]);
213
+ }
214
+ });
215
+ }
216
+ }
217
+ resolveRefConstraints() {
218
+ const { dragConstraints: constraints, onMeasureDragConstraints } = this.getProps();
219
+ if (!constraints || !isRefObject(constraints))
220
+ return false;
221
+ const constraintsElement = constraints.current;
222
+ invariant(constraintsElement !== null, "If `dragConstraints` is set as a React ref, that ref must be passed to another component's `ref` prop.");
223
+ const { projection } = this.visualElement;
224
+ // TODO
225
+ if (!projection || !projection.layout)
226
+ return false;
227
+ const constraintsBox = measurePageBox(constraintsElement, projection.root, this.visualElement.getTransformPagePoint());
228
+ let measuredConstraints = calcViewportConstraints(projection.layout.layoutBox, constraintsBox);
229
+ /**
230
+ * If there's an onMeasureDragConstraints listener we call it and
231
+ * if different constraints are returned, set constraints to that
232
+ */
233
+ if (onMeasureDragConstraints) {
234
+ const userConstraints = onMeasureDragConstraints(convertBoxToBoundingBox(measuredConstraints));
235
+ this.hasMutatedConstraints = !!userConstraints;
236
+ if (userConstraints) {
237
+ measuredConstraints = convertBoundingBoxToBox(userConstraints);
238
+ }
239
+ }
240
+ return measuredConstraints;
241
+ }
242
+ startAnimation(velocity) {
243
+ const { drag, dragMomentum, dragElastic, dragTransition, dragSnapToOrigin, onDragTransitionEnd, } = this.getProps();
244
+ const constraints = this.constraints || {};
245
+ const momentumAnimations = eachAxis((axis) => {
246
+ if (!shouldDrag(axis, drag, this.currentDirection)) {
247
+ return;
248
+ }
249
+ let transition = (constraints && constraints[axis]) || {};
250
+ if (dragSnapToOrigin)
251
+ transition = { min: 0, max: 0 };
252
+ /**
253
+ * Overdamp the boundary spring if `dragElastic` is disabled. There's still a frame
254
+ * of spring animations so we should look into adding a disable spring option to `inertia`.
255
+ * We could do something here where we affect the `bounceStiffness` and `bounceDamping`
256
+ * using the value of `dragElastic`.
257
+ */
258
+ const bounceStiffness = dragElastic ? 200 : 1000000;
259
+ const bounceDamping = dragElastic ? 40 : 10000000;
260
+ const inertia = {
261
+ type: "inertia",
262
+ velocity: dragMomentum ? velocity[axis] : 0,
263
+ bounceStiffness,
264
+ bounceDamping,
265
+ timeConstant: 750,
266
+ restDelta: 1,
267
+ restSpeed: 10,
268
+ ...dragTransition,
269
+ ...transition,
270
+ };
271
+ // If we're not animating on an externally-provided `MotionValue` we can use the
272
+ // component's animation controls which will handle interactions with whileHover (etc),
273
+ // otherwise we just have to animate the `MotionValue` itself.
274
+ return this.startAxisValueAnimation(axis, inertia);
275
+ });
276
+ // Run all animations and then resolve the new drag constraints.
277
+ return Promise.all(momentumAnimations).then(onDragTransitionEnd);
278
+ }
279
+ startAxisValueAnimation(axis, transition) {
280
+ const axisValue = this.getAxisMotionValue(axis);
281
+ return axisValue.start(animateMotionValue(axis, axisValue, 0, transition));
282
+ }
283
+ stopAnimation() {
284
+ eachAxis((axis) => this.getAxisMotionValue(axis).stop());
285
+ }
286
+ /**
287
+ * Drag works differently depending on which props are provided.
288
+ *
289
+ * - If _dragX and _dragY are provided, we output the gesture delta directly to those motion values.
290
+ * - Otherwise, we apply the delta to the x/y motion values.
291
+ */
292
+ getAxisMotionValue(axis) {
293
+ const dragKey = "_drag" + axis.toUpperCase();
294
+ const props = this.visualElement.getProps();
295
+ const externalMotionValue = props[dragKey];
296
+ return externalMotionValue
297
+ ? externalMotionValue
298
+ : this.visualElement.getValue(axis, (props.initial ? props.initial[axis] : undefined) || 0);
299
+ }
300
+ snapToCursor(point) {
301
+ eachAxis((axis) => {
302
+ const { drag } = this.getProps();
303
+ // If we're not dragging this axis, do an early return.
304
+ if (!shouldDrag(axis, drag, this.currentDirection))
305
+ return;
306
+ const { projection } = this.visualElement;
307
+ const axisValue = this.getAxisMotionValue(axis);
308
+ if (projection && projection.layout) {
309
+ const { min, max } = projection.layout.layoutBox[axis];
310
+ axisValue.set(point[axis] - mix(min, max, 0.5));
311
+ }
312
+ });
313
+ }
314
+ /**
315
+ * When the viewport resizes we want to check if the measured constraints
316
+ * have changed and, if so, reposition the element within those new constraints
317
+ * relative to where it was before the resize.
318
+ */
319
+ scalePositionWithinConstraints() {
320
+ if (!this.visualElement.current)
321
+ return;
322
+ const { drag, dragConstraints } = this.getProps();
323
+ const { projection } = this.visualElement;
324
+ if (!isRefObject(dragConstraints) || !projection || !this.constraints)
325
+ return;
326
+ /**
327
+ * Stop current animations as there can be visual glitching if we try to do
328
+ * this mid-animation
329
+ */
330
+ this.stopAnimation();
331
+ /**
332
+ * Record the relative position of the dragged element relative to the
333
+ * constraints box and save as a progress value.
334
+ */
335
+ const boxProgress = { x: 0, y: 0 };
336
+ eachAxis((axis) => {
337
+ const axisValue = this.getAxisMotionValue(axis);
338
+ if (axisValue) {
339
+ const latest = axisValue.get();
340
+ boxProgress[axis] = calcOrigin({ min: latest, max: latest }, this.constraints[axis]);
341
+ }
342
+ });
343
+ /**
344
+ * Update the layout of this element and resolve the latest drag constraints
345
+ */
346
+ const { transformTemplate } = this.visualElement.getProps();
347
+ this.visualElement.current.style.transform = transformTemplate
348
+ ? transformTemplate({}, "")
349
+ : "none";
350
+ projection.root && projection.root.updateScroll();
351
+ projection.updateLayout();
352
+ this.resolveConstraints();
353
+ /**
354
+ * For each axis, calculate the current progress of the layout axis
355
+ * within the new constraints.
356
+ */
357
+ eachAxis((axis) => {
358
+ if (!shouldDrag(axis, drag, null))
359
+ return;
360
+ /**
361
+ * Calculate a new transform based on the previous box progress
362
+ */
363
+ const axisValue = this.getAxisMotionValue(axis);
364
+ const { min, max } = this.constraints[axis];
365
+ axisValue.set(mix(min, max, boxProgress[axis]));
366
+ });
367
+ }
368
+ addListeners() {
369
+ if (!this.visualElement.current)
370
+ return;
371
+ elementDragControls.set(this.visualElement, this);
372
+ const element = this.visualElement.current;
373
+ /**
374
+ * Attach a pointerdown event listener on this DOM element to initiate drag tracking.
375
+ */
376
+ const stopPointerListener = addPointerEvent(element, "pointerdown", (event) => {
377
+ const { drag, dragListener = true } = this.getProps();
378
+ drag && dragListener && this.start(event);
379
+ });
380
+ const measureDragConstraints = () => {
381
+ const { dragConstraints } = this.getProps();
382
+ if (isRefObject(dragConstraints)) {
383
+ this.constraints = this.resolveRefConstraints();
384
+ }
385
+ };
386
+ const { projection } = this.visualElement;
387
+ const stopMeasureLayoutListener = projection.addEventListener("measure", measureDragConstraints);
388
+ if (projection && !projection.layout) {
389
+ projection.root && projection.root.updateScroll();
390
+ projection.updateLayout();
391
+ }
392
+ measureDragConstraints();
393
+ /**
394
+ * Attach a window resize listener to scale the draggable target within its defined
395
+ * constraints as the window resizes.
396
+ */
397
+ const stopResizeListener = addDomEvent(window, "resize", () => this.scalePositionWithinConstraints());
398
+ /**
399
+ * If the element's layout changes, calculate the delta and apply that to
400
+ * the drag gesture's origin point.
401
+ */
402
+ const stopLayoutUpdateListener = projection.addEventListener("didUpdate", (({ delta, hasLayoutChanged }) => {
403
+ if (this.isDragging && hasLayoutChanged) {
404
+ eachAxis((axis) => {
405
+ const motionValue = this.getAxisMotionValue(axis);
406
+ if (!motionValue)
407
+ return;
408
+ this.originPoint[axis] += delta[axis].translate;
409
+ motionValue.set(motionValue.get() + delta[axis].translate);
410
+ });
411
+ this.visualElement.render();
412
+ }
413
+ }));
414
+ return () => {
415
+ stopResizeListener();
416
+ stopPointerListener();
417
+ stopMeasureLayoutListener();
418
+ stopLayoutUpdateListener && stopLayoutUpdateListener();
419
+ };
420
+ }
421
+ getProps() {
422
+ const props = this.visualElement.getProps();
423
+ const { drag = false, dragDirectionLock = false, dragPropagation = false, dragConstraints = false, dragElastic = defaultElastic, dragMomentum = true, } = props;
424
+ return {
425
+ ...props,
426
+ drag,
427
+ dragDirectionLock,
428
+ dragPropagation,
429
+ dragConstraints,
430
+ dragElastic,
431
+ dragMomentum,
432
+ };
433
+ }
434
+ }
435
+ function shouldDrag(direction, drag, currentDirection) {
436
+ return ((drag === true || drag === direction) &&
437
+ (currentDirection === null || currentDirection === direction));
438
+ }
439
+ /**
440
+ * Based on an x/y offset determine the current drag direction. If both axis' offsets are lower
441
+ * than the provided threshold, return `null`.
442
+ *
443
+ * @param offset - The x/y offset from origin.
444
+ * @param lockThreshold - (Optional) - the minimum absolute offset before we can determine a drag direction.
445
+ */
446
+ function getCurrentDirection(offset, lockThreshold = 10) {
447
+ let direction = null;
448
+ if (Math.abs(offset.y) > lockThreshold) {
449
+ direction = "y";
450
+ }
451
+ else if (Math.abs(offset.x) > lockThreshold) {
452
+ direction = "x";
453
+ }
454
+ return direction;
455
+ }
456
+
457
+ export { VisualElementDragControls, elementDragControls };
@@ -0,0 +1,27 @@
1
+ import { Feature } from '../../motion/features/Feature.js';
2
+ import { noop } from '../../utils/noop.js';
3
+ import { VisualElementDragControls } from './VisualElementDragControls.js';
4
+
5
+ class DragGesture extends Feature {
6
+ constructor(node) {
7
+ super(node);
8
+ this.removeGroupControls = noop;
9
+ this.removeListeners = noop;
10
+ this.controls = new VisualElementDragControls(node);
11
+ }
12
+ mount() {
13
+ // If we've been provided a DragControls for manual control over the drag gesture,
14
+ // subscribe this component to it on mount.
15
+ const { dragControls } = this.node.getProps();
16
+ if (dragControls) {
17
+ this.removeGroupControls = dragControls.subscribe(this.controls);
18
+ }
19
+ this.removeListeners = this.controls.addListeners() || noop;
20
+ }
21
+ unmount() {
22
+ this.removeGroupControls();
23
+ this.removeListeners();
24
+ }
25
+ }
26
+
27
+ export { DragGesture };
@@ -0,0 +1,125 @@
1
+ import { progress } from '../../../utils/progress.js';
2
+ import { calcLength } from '../../../projection/geometry/delta-calc.js';
3
+ import { clamp } from '../../../utils/clamp.js';
4
+ import { mix } from '../../../utils/mix.js';
5
+
6
+ /**
7
+ * Apply constraints to a point. These constraints are both physical along an
8
+ * axis, and an elastic factor that determines how much to constrain the point
9
+ * by if it does lie outside the defined parameters.
10
+ */
11
+ function applyConstraints(point, { min, max }, elastic) {
12
+ if (min !== undefined && point < min) {
13
+ // If we have a min point defined, and this is outside of that, constrain
14
+ point = elastic ? mix(min, point, elastic.min) : Math.max(point, min);
15
+ }
16
+ else if (max !== undefined && point > max) {
17
+ // If we have a max point defined, and this is outside of that, constrain
18
+ point = elastic ? mix(max, point, elastic.max) : Math.min(point, max);
19
+ }
20
+ return point;
21
+ }
22
+ /**
23
+ * Calculate constraints in terms of the viewport when defined relatively to the
24
+ * measured axis. This is measured from the nearest edge, so a max constraint of 200
25
+ * on an axis with a max value of 300 would return a constraint of 500 - axis length
26
+ */
27
+ function calcRelativeAxisConstraints(axis, min, max) {
28
+ return {
29
+ min: min !== undefined ? axis.min + min : undefined,
30
+ max: max !== undefined
31
+ ? axis.max + max - (axis.max - axis.min)
32
+ : undefined,
33
+ };
34
+ }
35
+ /**
36
+ * Calculate constraints in terms of the viewport when
37
+ * defined relatively to the measured bounding box.
38
+ */
39
+ function calcRelativeConstraints(layoutBox, { top, left, bottom, right }) {
40
+ return {
41
+ x: calcRelativeAxisConstraints(layoutBox.x, left, right),
42
+ y: calcRelativeAxisConstraints(layoutBox.y, top, bottom),
43
+ };
44
+ }
45
+ /**
46
+ * Calculate viewport constraints when defined as another viewport-relative axis
47
+ */
48
+ function calcViewportAxisConstraints(layoutAxis, constraintsAxis) {
49
+ let min = constraintsAxis.min - layoutAxis.min;
50
+ let max = constraintsAxis.max - layoutAxis.max;
51
+ // If the constraints axis is actually smaller than the layout axis then we can
52
+ // flip the constraints
53
+ if (constraintsAxis.max - constraintsAxis.min <
54
+ layoutAxis.max - layoutAxis.min) {
55
+ [min, max] = [max, min];
56
+ }
57
+ return { min, max };
58
+ }
59
+ /**
60
+ * Calculate viewport constraints when defined as another viewport-relative box
61
+ */
62
+ function calcViewportConstraints(layoutBox, constraintsBox) {
63
+ return {
64
+ x: calcViewportAxisConstraints(layoutBox.x, constraintsBox.x),
65
+ y: calcViewportAxisConstraints(layoutBox.y, constraintsBox.y),
66
+ };
67
+ }
68
+ /**
69
+ * Calculate a transform origin relative to the source axis, between 0-1, that results
70
+ * in an asthetically pleasing scale/transform needed to project from source to target.
71
+ */
72
+ function calcOrigin(source, target) {
73
+ let origin = 0.5;
74
+ const sourceLength = calcLength(source);
75
+ const targetLength = calcLength(target);
76
+ if (targetLength > sourceLength) {
77
+ origin = progress(target.min, target.max - sourceLength, source.min);
78
+ }
79
+ else if (sourceLength > targetLength) {
80
+ origin = progress(source.min, source.max - targetLength, target.min);
81
+ }
82
+ return clamp(0, 1, origin);
83
+ }
84
+ /**
85
+ * Rebase the calculated viewport constraints relative to the layout.min point.
86
+ */
87
+ function rebaseAxisConstraints(layout, constraints) {
88
+ const relativeConstraints = {};
89
+ if (constraints.min !== undefined) {
90
+ relativeConstraints.min = constraints.min - layout.min;
91
+ }
92
+ if (constraints.max !== undefined) {
93
+ relativeConstraints.max = constraints.max - layout.min;
94
+ }
95
+ return relativeConstraints;
96
+ }
97
+ const defaultElastic = 0.35;
98
+ /**
99
+ * Accepts a dragElastic prop and returns resolved elastic values for each axis.
100
+ */
101
+ function resolveDragElastic(dragElastic = defaultElastic) {
102
+ if (dragElastic === false) {
103
+ dragElastic = 0;
104
+ }
105
+ else if (dragElastic === true) {
106
+ dragElastic = defaultElastic;
107
+ }
108
+ return {
109
+ x: resolveAxisElastic(dragElastic, "left", "right"),
110
+ y: resolveAxisElastic(dragElastic, "top", "bottom"),
111
+ };
112
+ }
113
+ function resolveAxisElastic(dragElastic, minLabel, maxLabel) {
114
+ return {
115
+ min: resolvePointElastic(dragElastic, minLabel),
116
+ max: resolvePointElastic(dragElastic, maxLabel),
117
+ };
118
+ }
119
+ function resolvePointElastic(dragElastic, label) {
120
+ return typeof dragElastic === "number"
121
+ ? dragElastic
122
+ : dragElastic[label] || 0;
123
+ }
124
+
125
+ export { applyConstraints, calcOrigin, calcRelativeAxisConstraints, calcRelativeConstraints, calcViewportAxisConstraints, calcViewportConstraints, defaultElastic, rebaseAxisConstraints, resolveAxisElastic, resolveDragElastic, resolvePointElastic };
@@ -0,0 +1,53 @@
1
+ function createLock(name) {
2
+ let lock = null;
3
+ return () => {
4
+ const openLock = () => {
5
+ lock = null;
6
+ };
7
+ if (lock === null) {
8
+ lock = name;
9
+ return openLock;
10
+ }
11
+ return false;
12
+ };
13
+ }
14
+ const globalHorizontalLock = createLock("dragHorizontal");
15
+ const globalVerticalLock = createLock("dragVertical");
16
+ function getGlobalLock(drag) {
17
+ let lock = false;
18
+ if (drag === "y") {
19
+ lock = globalVerticalLock();
20
+ }
21
+ else if (drag === "x") {
22
+ lock = globalHorizontalLock();
23
+ }
24
+ else {
25
+ const openHorizontal = globalHorizontalLock();
26
+ const openVertical = globalVerticalLock();
27
+ if (openHorizontal && openVertical) {
28
+ lock = () => {
29
+ openHorizontal();
30
+ openVertical();
31
+ };
32
+ }
33
+ else {
34
+ // Release the locks because we don't use them
35
+ if (openHorizontal)
36
+ openHorizontal();
37
+ if (openVertical)
38
+ openVertical();
39
+ }
40
+ }
41
+ return lock;
42
+ }
43
+ function isDragActive() {
44
+ // Check the gesture lock - if we get it, it means no drag gesture is active
45
+ // and we can safely fire the tap gesture.
46
+ const openGestureLock = getGlobalLock(true);
47
+ if (!openGestureLock)
48
+ return true;
49
+ openGestureLock();
50
+ return false;
51
+ }
52
+
53
+ export { createLock, getGlobalLock, isDragActive };