@dreamcommerce/aurora 3.0.0-41 → 3.0.0-44

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 (268) hide show
  1. package/build/cjs/_virtual/_rollupPluginBabelHelpers.js +49 -0
  2. package/build/cjs/_virtual/_rollupPluginBabelHelpers.js.map +1 -1
  3. package/build/cjs/external/@radix-ui/primitive/dist/index.mjs.js +19 -0
  4. package/build/cjs/external/@radix-ui/primitive/dist/index.mjs.js.map +1 -0
  5. package/build/cjs/external/@radix-ui/react-compose-refs/dist/index.mjs.js +34 -0
  6. package/build/cjs/external/@radix-ui/react-compose-refs/dist/index.mjs.js.map +1 -0
  7. package/build/cjs/external/@radix-ui/react-context/dist/index.mjs.js +111 -0
  8. package/build/cjs/external/@radix-ui/react-context/dist/index.mjs.js.map +1 -0
  9. package/build/cjs/external/@radix-ui/react-dialog/dist/index.mjs.js +390 -0
  10. package/build/cjs/external/@radix-ui/react-dialog/dist/index.mjs.js.map +1 -0
  11. package/build/cjs/external/@radix-ui/react-dismissable-layer/dist/index.mjs.js +247 -0
  12. package/build/cjs/external/@radix-ui/react-dismissable-layer/dist/index.mjs.js.map +1 -0
  13. package/build/cjs/external/@radix-ui/react-focus-guards/dist/index.mjs.js +37 -0
  14. package/build/cjs/external/@radix-ui/react-focus-guards/dist/index.mjs.js.map +1 -0
  15. package/build/cjs/external/@radix-ui/react-focus-scope/dist/index.mjs.js +286 -0
  16. package/build/cjs/external/@radix-ui/react-focus-scope/dist/index.mjs.js.map +1 -0
  17. package/build/cjs/external/@radix-ui/react-id/dist/index.mjs.js +49 -0
  18. package/build/cjs/external/@radix-ui/react-id/dist/index.mjs.js.map +1 -0
  19. package/build/cjs/external/@radix-ui/react-portal/dist/index.mjs.js +37 -0
  20. package/build/cjs/external/@radix-ui/react-portal/dist/index.mjs.js.map +1 -0
  21. package/build/cjs/external/@radix-ui/react-presence/dist/index.mjs.js +149 -0
  22. package/build/cjs/external/@radix-ui/react-presence/dist/index.mjs.js.map +1 -0
  23. package/build/cjs/external/@radix-ui/react-primitive/dist/index.mjs.js +36 -0
  24. package/build/cjs/external/@radix-ui/react-primitive/dist/index.mjs.js.map +1 -0
  25. package/build/cjs/external/@radix-ui/react-use-callback-ref/dist/index.mjs.js +25 -0
  26. package/build/cjs/external/@radix-ui/react-use-callback-ref/dist/index.mjs.js.map +1 -0
  27. package/build/cjs/external/@radix-ui/react-use-controllable-state/dist/index.mjs.js +53 -0
  28. package/build/cjs/external/@radix-ui/react-use-controllable-state/dist/index.mjs.js.map +1 -0
  29. package/build/cjs/external/@radix-ui/react-use-escape-keydown/dist/index.mjs.js +30 -0
  30. package/build/cjs/external/@radix-ui/react-use-escape-keydown/dist/index.mjs.js.map +1 -0
  31. package/build/cjs/external/@radix-ui/react-use-layout-effect/dist/index.mjs.js +11 -0
  32. package/build/cjs/external/@radix-ui/react-use-layout-effect/dist/index.mjs.js.map +1 -0
  33. package/build/cjs/external/aria-hidden/dist/es2015/index.js +141 -0
  34. package/build/cjs/external/aria-hidden/dist/es2015/index.js.map +1 -0
  35. package/build/cjs/external/get-nonce/dist/es2015/index.js +13 -0
  36. package/build/cjs/external/get-nonce/dist/es2015/index.js.map +1 -0
  37. package/build/cjs/external/react-remove-scroll/dist/es2015/Combination.js +14 -0
  38. package/build/cjs/external/react-remove-scroll/dist/es2015/Combination.js.map +1 -0
  39. package/build/cjs/external/react-remove-scroll/dist/es2015/SideEffect.js +167 -0
  40. package/build/cjs/external/react-remove-scroll/dist/es2015/SideEffect.js.map +1 -0
  41. package/build/cjs/external/react-remove-scroll/dist/es2015/UI.js +43 -0
  42. package/build/cjs/external/react-remove-scroll/dist/es2015/UI.js.map +1 -0
  43. package/build/cjs/external/react-remove-scroll/dist/es2015/aggresiveCapture.js +26 -0
  44. package/build/cjs/external/react-remove-scroll/dist/es2015/aggresiveCapture.js.map +1 -0
  45. package/build/cjs/external/react-remove-scroll/dist/es2015/handleScroll.js +115 -0
  46. package/build/cjs/external/react-remove-scroll/dist/es2015/handleScroll.js.map +1 -0
  47. package/build/cjs/external/react-remove-scroll/dist/es2015/medium.js +10 -0
  48. package/build/cjs/external/react-remove-scroll/dist/es2015/medium.js.map +1 -0
  49. package/build/cjs/external/react-remove-scroll/dist/es2015/sidecar.js +12 -0
  50. package/build/cjs/external/react-remove-scroll/dist/es2015/sidecar.js.map +1 -0
  51. package/build/cjs/external/react-remove-scroll/external/tslib/tslib.es6.mjs.js +60 -0
  52. package/build/cjs/external/react-remove-scroll/external/tslib/tslib.es6.mjs.js.map +1 -0
  53. package/build/cjs/external/react-remove-scroll-bar/dist/es2015/component.js +63 -0
  54. package/build/cjs/external/react-remove-scroll-bar/dist/es2015/component.js.map +1 -0
  55. package/build/cjs/external/react-remove-scroll-bar/dist/es2015/constants.js +18 -0
  56. package/build/cjs/external/react-remove-scroll-bar/dist/es2015/constants.js.map +1 -0
  57. package/build/cjs/external/react-remove-scroll-bar/dist/es2015/utils.js +37 -0
  58. package/build/cjs/external/react-remove-scroll-bar/dist/es2015/utils.js.map +1 -0
  59. package/build/cjs/external/react-style-singleton/dist/es2015/component.js +24 -0
  60. package/build/cjs/external/react-style-singleton/dist/es2015/component.js.map +1 -0
  61. package/build/cjs/external/react-style-singleton/dist/es2015/hook.js +30 -0
  62. package/build/cjs/external/react-style-singleton/dist/es2015/hook.js.map +1 -0
  63. package/build/cjs/external/react-style-singleton/dist/es2015/singleton.js +56 -0
  64. package/build/cjs/external/react-style-singleton/dist/es2015/singleton.js.map +1 -0
  65. package/build/cjs/external/use-callback-ref/dist/es2015/assignRef.js +29 -0
  66. package/build/cjs/external/use-callback-ref/dist/es2015/assignRef.js.map +1 -0
  67. package/build/cjs/external/use-callback-ref/dist/es2015/useMergeRef.js +53 -0
  68. package/build/cjs/external/use-callback-ref/dist/es2015/useMergeRef.js.map +1 -0
  69. package/build/cjs/external/use-callback-ref/dist/es2015/useRef.js +47 -0
  70. package/build/cjs/external/use-callback-ref/dist/es2015/useRef.js.map +1 -0
  71. package/build/cjs/external/use-sidecar/dist/es2015/exports.js +26 -0
  72. package/build/cjs/external/use-sidecar/dist/es2015/exports.js.map +1 -0
  73. package/build/cjs/external/use-sidecar/dist/es2015/medium.js +82 -0
  74. package/build/cjs/external/use-sidecar/dist/es2015/medium.js.map +1 -0
  75. package/build/cjs/external/use-sidecar/external/tslib/tslib.es6.mjs.js +49 -0
  76. package/build/cjs/external/use-sidecar/external/tslib/tslib.es6.mjs.js.map +1 -0
  77. package/build/cjs/external/vaul/dist/index.mjs.js +1666 -0
  78. package/build/cjs/external/vaul/dist/index.mjs.js.map +1 -0
  79. package/build/cjs/packages/aurora/src/components/drawer/components/drawer_close.js +2 -2
  80. package/build/cjs/packages/aurora/src/components/drawer/components/drawer_close.js.map +1 -1
  81. package/build/cjs/packages/aurora/src/components/drawer/components/drawer_content.js +5 -6
  82. package/build/cjs/packages/aurora/src/components/drawer/components/drawer_content.js.map +1 -1
  83. package/build/cjs/packages/aurora/src/components/drawer/components/drawer_portal.js +2 -2
  84. package/build/cjs/packages/aurora/src/components/drawer/components/drawer_portal.js.map +1 -1
  85. package/build/cjs/packages/aurora/src/components/drawer/components/drawer_title.js +3 -3
  86. package/build/cjs/packages/aurora/src/components/drawer/components/drawer_title.js.map +1 -1
  87. package/build/cjs/packages/aurora/src/components/drawer/components/drawer_trigger.js +2 -2
  88. package/build/cjs/packages/aurora/src/components/drawer/components/drawer_trigger.js.map +1 -1
  89. package/build/cjs/packages/aurora/src/components/drawer/drawer.js +2 -2
  90. package/build/cjs/packages/aurora/src/components/drawer/drawer.js.map +1 -1
  91. package/build/cjs/packages/aurora/src/components/drawer/drawer_variants.js +2 -2
  92. package/build/cjs/packages/aurora/src/components/label/label.js +5 -5
  93. package/build/cjs/packages/aurora/src/components/modal/components/modal/modal.js +2 -2
  94. package/build/cjs/packages/aurora/src/components/modal/components/modals_wrapper.js +2 -2
  95. package/build/cjs/packages/aurora/src/hooks/search/use_search.js +28 -0
  96. package/build/cjs/packages/aurora/src/hooks/search/use_search.js.map +1 -0
  97. package/build/cjs/packages/aurora/src/index.js +2 -0
  98. package/build/cjs/packages/aurora/src/index.js.map +1 -1
  99. package/build/cjs/packages/aurora/src/utilities/fuzzy_search.js +65 -0
  100. package/build/cjs/packages/aurora/src/utilities/fuzzy_search.js.map +1 -0
  101. package/build/esm/_virtual/_rollupPluginBabelHelpers.js +49 -1
  102. package/build/esm/_virtual/_rollupPluginBabelHelpers.js.map +1 -1
  103. package/build/esm/external/@radix-ui/primitive/dist/index.mjs.js +15 -0
  104. package/build/esm/external/@radix-ui/primitive/dist/index.mjs.js.map +1 -0
  105. package/build/esm/external/@radix-ui/react-compose-refs/dist/index.mjs.js +29 -0
  106. package/build/esm/external/@radix-ui/react-compose-refs/dist/index.mjs.js.map +1 -0
  107. package/build/esm/external/@radix-ui/react-context/dist/index.mjs.js +106 -0
  108. package/build/esm/external/@radix-ui/react-context/dist/index.mjs.js.map +1 -0
  109. package/build/esm/external/@radix-ui/react-dialog/dist/index.mjs.js +369 -0
  110. package/build/esm/external/@radix-ui/react-dialog/dist/index.mjs.js.map +1 -0
  111. package/build/esm/external/@radix-ui/react-dismissable-layer/dist/index.mjs.js +242 -0
  112. package/build/esm/external/@radix-ui/react-dismissable-layer/dist/index.mjs.js.map +1 -0
  113. package/build/esm/external/@radix-ui/react-focus-guards/dist/index.mjs.js +33 -0
  114. package/build/esm/external/@radix-ui/react-focus-guards/dist/index.mjs.js.map +1 -0
  115. package/build/esm/external/@radix-ui/react-focus-scope/dist/index.mjs.js +282 -0
  116. package/build/esm/external/@radix-ui/react-focus-scope/dist/index.mjs.js.map +1 -0
  117. package/build/esm/external/@radix-ui/react-id/dist/index.mjs.js +24 -0
  118. package/build/esm/external/@radix-ui/react-id/dist/index.mjs.js.map +1 -0
  119. package/build/esm/external/@radix-ui/react-portal/dist/index.mjs.js +29 -0
  120. package/build/esm/external/@radix-ui/react-portal/dist/index.mjs.js.map +1 -0
  121. package/build/esm/external/@radix-ui/react-presence/dist/index.mjs.js +145 -0
  122. package/build/esm/external/@radix-ui/react-presence/dist/index.mjs.js.map +1 -0
  123. package/build/esm/external/@radix-ui/react-primitive/dist/index.mjs.js +31 -0
  124. package/build/esm/external/@radix-ui/react-primitive/dist/index.mjs.js.map +1 -0
  125. package/build/esm/external/@radix-ui/react-use-callback-ref/dist/index.mjs.js +21 -0
  126. package/build/esm/external/@radix-ui/react-use-callback-ref/dist/index.mjs.js.map +1 -0
  127. package/build/esm/external/@radix-ui/react-use-controllable-state/dist/index.mjs.js +49 -0
  128. package/build/esm/external/@radix-ui/react-use-controllable-state/dist/index.mjs.js.map +1 -0
  129. package/build/esm/external/@radix-ui/react-use-escape-keydown/dist/index.mjs.js +26 -0
  130. package/build/esm/external/@radix-ui/react-use-escape-keydown/dist/index.mjs.js.map +1 -0
  131. package/build/esm/external/@radix-ui/react-use-layout-effect/dist/index.mjs.js +7 -0
  132. package/build/esm/external/@radix-ui/react-use-layout-effect/dist/index.mjs.js.map +1 -0
  133. package/build/esm/external/aria-hidden/dist/es2015/index.js +137 -0
  134. package/build/esm/external/aria-hidden/dist/es2015/index.js.map +1 -0
  135. package/build/esm/external/get-nonce/dist/es2015/index.js +9 -0
  136. package/build/esm/external/get-nonce/dist/es2015/index.js.map +1 -0
  137. package/build/esm/external/react-remove-scroll/dist/es2015/Combination.js +10 -0
  138. package/build/esm/external/react-remove-scroll/dist/es2015/Combination.js.map +1 -0
  139. package/build/esm/external/react-remove-scroll/dist/es2015/SideEffect.js +161 -0
  140. package/build/esm/external/react-remove-scroll/dist/es2015/SideEffect.js.map +1 -0
  141. package/build/esm/external/react-remove-scroll/dist/es2015/UI.js +39 -0
  142. package/build/esm/external/react-remove-scroll/dist/es2015/UI.js.map +1 -0
  143. package/build/esm/external/react-remove-scroll/dist/es2015/aggresiveCapture.js +22 -0
  144. package/build/esm/external/react-remove-scroll/dist/es2015/aggresiveCapture.js.map +1 -0
  145. package/build/esm/external/react-remove-scroll/dist/es2015/handleScroll.js +110 -0
  146. package/build/esm/external/react-remove-scroll/dist/es2015/handleScroll.js.map +1 -0
  147. package/build/esm/external/react-remove-scroll/dist/es2015/medium.js +6 -0
  148. package/build/esm/external/react-remove-scroll/dist/es2015/medium.js.map +1 -0
  149. package/build/esm/external/react-remove-scroll/dist/es2015/sidecar.js +8 -0
  150. package/build/esm/external/react-remove-scroll/dist/es2015/sidecar.js.map +1 -0
  151. package/build/esm/external/react-remove-scroll/external/tslib/tslib.es6.mjs.js +55 -0
  152. package/build/esm/external/react-remove-scroll/external/tslib/tslib.es6.mjs.js.map +1 -0
  153. package/build/esm/external/react-remove-scroll-bar/dist/es2015/component.js +57 -0
  154. package/build/esm/external/react-remove-scroll-bar/dist/es2015/component.js.map +1 -0
  155. package/build/esm/external/react-remove-scroll-bar/dist/es2015/constants.js +11 -0
  156. package/build/esm/external/react-remove-scroll-bar/dist/es2015/constants.js.map +1 -0
  157. package/build/esm/external/react-remove-scroll-bar/dist/es2015/utils.js +32 -0
  158. package/build/esm/external/react-remove-scroll-bar/dist/es2015/utils.js.map +1 -0
  159. package/build/esm/external/react-style-singleton/dist/es2015/component.js +20 -0
  160. package/build/esm/external/react-style-singleton/dist/es2015/component.js.map +1 -0
  161. package/build/esm/external/react-style-singleton/dist/es2015/hook.js +26 -0
  162. package/build/esm/external/react-style-singleton/dist/es2015/hook.js.map +1 -0
  163. package/build/esm/external/react-style-singleton/dist/es2015/singleton.js +52 -0
  164. package/build/esm/external/react-style-singleton/dist/es2015/singleton.js.map +1 -0
  165. package/build/esm/external/use-callback-ref/dist/es2015/assignRef.js +25 -0
  166. package/build/esm/external/use-callback-ref/dist/es2015/assignRef.js.map +1 -0
  167. package/build/esm/external/use-callback-ref/dist/es2015/useMergeRef.js +49 -0
  168. package/build/esm/external/use-callback-ref/dist/es2015/useMergeRef.js.map +1 -0
  169. package/build/esm/external/use-callback-ref/dist/es2015/useRef.js +43 -0
  170. package/build/esm/external/use-callback-ref/dist/es2015/useRef.js.map +1 -0
  171. package/build/esm/external/use-sidecar/dist/es2015/exports.js +22 -0
  172. package/build/esm/external/use-sidecar/dist/es2015/exports.js.map +1 -0
  173. package/build/esm/external/use-sidecar/dist/es2015/medium.js +78 -0
  174. package/build/esm/external/use-sidecar/dist/es2015/medium.js.map +1 -0
  175. package/build/esm/external/use-sidecar/external/tslib/tslib.es6.mjs.js +45 -0
  176. package/build/esm/external/use-sidecar/external/tslib/tslib.es6.mjs.js.map +1 -0
  177. package/build/esm/external/vaul/dist/index.mjs.js +1652 -0
  178. package/build/esm/external/vaul/dist/index.mjs.js.map +1 -0
  179. package/build/esm/packages/aurora/src/components/action_list/action_list.js +2 -2
  180. package/build/esm/packages/aurora/src/components/action_list/components/action_list_content.js +3 -3
  181. package/build/esm/packages/aurora/src/components/action_list/components/action_list_divider.js +2 -2
  182. package/build/esm/packages/aurora/src/components/action_list/components/action_list_group.js +3 -3
  183. package/build/esm/packages/aurora/src/components/action_list/components/action_list_item.js +3 -3
  184. package/build/esm/packages/aurora/src/components/action_list/components/action_list_label.js +5 -5
  185. package/build/esm/packages/aurora/src/components/action_list/components/action_list_radio_group.js +3 -3
  186. package/build/esm/packages/aurora/src/components/action_list/components/action_list_radio_item.js +4 -4
  187. package/build/esm/packages/aurora/src/components/action_list/components/action_list_sub_content.js +3 -3
  188. package/build/esm/packages/aurora/src/components/action_list/components/action_list_sub_trigger.js +5 -5
  189. package/build/esm/packages/aurora/src/components/action_list/components/action_list_trigger.js +3 -3
  190. package/build/esm/packages/aurora/src/components/box/box.js +3 -3
  191. package/build/esm/packages/aurora/src/components/button/button.js +3 -3
  192. package/build/esm/packages/aurora/src/components/control/control.d.ts +3 -0
  193. package/build/esm/packages/aurora/src/components/control/control.js +5 -0
  194. package/build/esm/packages/aurora/src/components/control/control.js.map +1 -0
  195. package/build/esm/packages/aurora/src/components/control/control_types.d.ts +5 -0
  196. package/build/esm/packages/aurora/src/components/control/control_types.js +2 -0
  197. package/build/esm/packages/aurora/src/components/control/control_types.js.map +1 -0
  198. package/build/esm/packages/aurora/src/components/controls/switch_control/switch_control.d.ts +3 -0
  199. package/build/esm/packages/aurora/src/components/controls/switch_control/switch_control.js +14 -0
  200. package/build/esm/packages/aurora/src/components/controls/switch_control/switch_control.js.map +1 -0
  201. package/build/esm/packages/aurora/src/components/controls/switch_control/switch_control_types.d.ts +8 -0
  202. package/build/esm/packages/aurora/src/components/controls/switch_control/switch_control_types.js +3 -0
  203. package/build/esm/packages/aurora/src/components/controls/switch_control/switch_control_types.js.map +1 -0
  204. package/build/esm/packages/aurora/src/components/divider/divider.js +3 -3
  205. package/build/esm/packages/aurora/src/components/drawer/components/drawer_close.js +1 -1
  206. package/build/esm/packages/aurora/src/components/drawer/components/drawer_close.js.map +1 -1
  207. package/build/esm/packages/aurora/src/components/drawer/components/drawer_content.js +4 -5
  208. package/build/esm/packages/aurora/src/components/drawer/components/drawer_content.js.map +1 -1
  209. package/build/esm/packages/aurora/src/components/drawer/components/drawer_portal.js +1 -1
  210. package/build/esm/packages/aurora/src/components/drawer/components/drawer_portal.js.map +1 -1
  211. package/build/esm/packages/aurora/src/components/drawer/components/drawer_title.js +1 -1
  212. package/build/esm/packages/aurora/src/components/drawer/components/drawer_title.js.map +1 -1
  213. package/build/esm/packages/aurora/src/components/drawer/components/drawer_trigger.js +1 -1
  214. package/build/esm/packages/aurora/src/components/drawer/components/drawer_trigger.js.map +1 -1
  215. package/build/esm/packages/aurora/src/components/drawer/context/drawer_context.js +2 -2
  216. package/build/esm/packages/aurora/src/components/drawer/drawer.js +1 -1
  217. package/build/esm/packages/aurora/src/components/drawer/drawer.js.map +1 -1
  218. package/build/esm/packages/aurora/src/components/drawer/drawer_variants.js +2 -2
  219. package/build/esm/packages/aurora/src/components/icon_button/icon_button.js +4 -4
  220. package/build/esm/packages/aurora/src/components/label/components/label_content.js +4 -4
  221. package/build/esm/packages/aurora/src/components/label/label.js +5 -5
  222. package/build/esm/packages/aurora/src/components/label/label_types.d.ts +2 -2
  223. package/build/esm/packages/aurora/src/components/link/link.js +3 -3
  224. package/build/esm/packages/aurora/src/components/loader/loader.js +2 -2
  225. package/build/esm/packages/aurora/src/components/message_box/message_box.js +11 -11
  226. package/build/esm/packages/aurora/src/components/modal/components/modal/modal.js +5 -5
  227. package/build/esm/packages/aurora/src/components/modal/components/modal/modal_close_icon.js +3 -3
  228. package/build/esm/packages/aurora/src/components/modal/components/modal/modal_footer.js +2 -2
  229. package/build/esm/packages/aurora/src/components/modal/components/modal/modal_header.js +4 -4
  230. package/build/esm/packages/aurora/src/components/modal/components/modals_wrapper.js +4 -4
  231. package/build/esm/packages/aurora/src/components/modal/modals_manager.js +3 -3
  232. package/build/esm/packages/aurora/src/components/segmented_control/components/segmented_control_item.js +4 -4
  233. package/build/esm/packages/aurora/src/components/segmented_control/context/segmented_control_context.js +2 -2
  234. package/build/esm/packages/aurora/src/components/segmented_control/segmented_control.js +4 -4
  235. package/build/esm/packages/aurora/src/components/sidebar/components/sidebar_trigger.js +3 -3
  236. package/build/esm/packages/aurora/src/components/sidebar/context/sidebar_context.js +2 -2
  237. package/build/esm/packages/aurora/src/components/sidebar/hooks/use_sidebar.js +2 -2
  238. package/build/esm/packages/aurora/src/components/stack/stack.js +3 -3
  239. package/build/esm/packages/aurora/src/components/switch/components/switch_thumb.d.ts +3 -0
  240. package/build/esm/packages/aurora/src/components/switch/components/switch_thumb.js +3 -0
  241. package/build/esm/packages/aurora/src/components/switch/components/switch_thumb.js.map +1 -0
  242. package/build/esm/packages/aurora/src/components/switch/switch.d.ts +3 -0
  243. package/build/esm/packages/aurora/src/components/switch/switch.js +11 -0
  244. package/build/esm/packages/aurora/src/components/switch/switch.js.map +1 -0
  245. package/build/esm/packages/aurora/src/components/switch/switch_types.d.ts +5 -0
  246. package/build/esm/packages/aurora/src/components/switch/switch_types.js +2 -0
  247. package/build/esm/packages/aurora/src/components/switch/switch_types.js.map +1 -0
  248. package/build/esm/packages/aurora/src/components/tabs/context/tabs_context.js +2 -2
  249. package/build/esm/packages/aurora/src/components/tabs/tabs.js +4 -4
  250. package/build/esm/packages/aurora/src/components/tag/tag.js +1 -1
  251. package/build/esm/packages/aurora/src/components/tag/tag.js.map +1 -1
  252. package/build/esm/packages/aurora/src/components/tag/tag_variants.js +1 -1
  253. package/build/esm/packages/aurora/src/components/tag/tag_variants.js.map +1 -1
  254. package/build/esm/packages/aurora/src/components/typography/typography.js +2 -2
  255. package/build/esm/packages/aurora/src/hooks/search/use_search.d.ts +2 -0
  256. package/build/esm/packages/aurora/src/hooks/search/use_search.js +24 -0
  257. package/build/esm/packages/aurora/src/hooks/search/use_search.js.map +1 -0
  258. package/build/esm/packages/aurora/src/hooks/search/use_search_types.d.ts +10 -0
  259. package/build/esm/packages/aurora/src/hooks/search/use_search_types.js +2 -0
  260. package/build/esm/packages/aurora/src/hooks/search/use_search_types.js.map +1 -0
  261. package/build/esm/packages/aurora/src/index.d.ts +1 -0
  262. package/build/esm/packages/aurora/src/index.js +1 -0
  263. package/build/esm/packages/aurora/src/index.js.map +1 -1
  264. package/build/esm/packages/aurora/src/utilities/fuzzy_search.d.ts +17 -0
  265. package/build/esm/packages/aurora/src/utilities/fuzzy_search.js +57 -0
  266. package/build/esm/packages/aurora/src/utilities/fuzzy_search.js.map +1 -0
  267. package/build/index.css +1 -1
  268. package/package.json +4 -3
@@ -0,0 +1,1666 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+
5
+ var React = require('react');
6
+ var index = require('../../@radix-ui/react-dialog/dist/index.mjs.js');
7
+
8
+ function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
9
+
10
+ var React__default = /*#__PURE__*/_interopDefaultLegacy(React);
11
+
12
+ function __insertCSS(code) {
13
+ if (!code || typeof document == 'undefined') return
14
+ let head = document.head || document.getElementsByTagName('head')[0];
15
+ let style = document.createElement('style');
16
+ style.type = 'text/css';
17
+ head.appendChild(style)
18
+ ;style.styleSheet ? (style.styleSheet.cssText = code) : style.appendChild(document.createTextNode(code));
19
+ }
20
+
21
+ const DrawerContext = React__default['default'].createContext({
22
+ drawerRef: {
23
+ current: null
24
+ },
25
+ overlayRef: {
26
+ current: null
27
+ },
28
+ onPress: ()=>{},
29
+ onRelease: ()=>{},
30
+ onDrag: ()=>{},
31
+ onNestedDrag: ()=>{},
32
+ onNestedOpenChange: ()=>{},
33
+ onNestedRelease: ()=>{},
34
+ openProp: undefined,
35
+ dismissible: false,
36
+ isOpen: false,
37
+ isDragging: false,
38
+ keyboardIsOpen: {
39
+ current: false
40
+ },
41
+ snapPointsOffset: null,
42
+ snapPoints: null,
43
+ handleOnly: false,
44
+ modal: false,
45
+ shouldFade: false,
46
+ activeSnapPoint: null,
47
+ onOpenChange: ()=>{},
48
+ setActiveSnapPoint: ()=>{},
49
+ closeDrawer: ()=>{},
50
+ direction: 'bottom',
51
+ shouldAnimate: {
52
+ current: true
53
+ },
54
+ shouldScaleBackground: false,
55
+ setBackgroundColorOnScale: true,
56
+ noBodyStyles: false,
57
+ container: null,
58
+ autoFocus: false
59
+ });
60
+ const useDrawerContext = ()=>{
61
+ const context = React__default['default'].useContext(DrawerContext);
62
+ if (!context) {
63
+ throw new Error('useDrawerContext must be used within a Drawer.Root');
64
+ }
65
+ return context;
66
+ };
67
+
68
+ __insertCSS("[data-vaul-drawer]{touch-action:none;will-change:transform;transition:transform .5s cubic-bezier(.32, .72, 0, 1);animation-duration:.5s;animation-timing-function:cubic-bezier(0.32,0.72,0,1)}[data-vaul-drawer][data-vaul-snap-points=false][data-vaul-drawer-direction=bottom][data-state=open]{animation-name:slideFromBottom}[data-vaul-drawer][data-vaul-snap-points=false][data-vaul-drawer-direction=bottom][data-state=closed]{animation-name:slideToBottom}[data-vaul-drawer][data-vaul-snap-points=false][data-vaul-drawer-direction=top][data-state=open]{animation-name:slideFromTop}[data-vaul-drawer][data-vaul-snap-points=false][data-vaul-drawer-direction=top][data-state=closed]{animation-name:slideToTop}[data-vaul-drawer][data-vaul-snap-points=false][data-vaul-drawer-direction=left][data-state=open]{animation-name:slideFromLeft}[data-vaul-drawer][data-vaul-snap-points=false][data-vaul-drawer-direction=left][data-state=closed]{animation-name:slideToLeft}[data-vaul-drawer][data-vaul-snap-points=false][data-vaul-drawer-direction=right][data-state=open]{animation-name:slideFromRight}[data-vaul-drawer][data-vaul-snap-points=false][data-vaul-drawer-direction=right][data-state=closed]{animation-name:slideToRight}[data-vaul-drawer][data-vaul-snap-points=true][data-vaul-drawer-direction=bottom]{transform:translate3d(0,var(--initial-transform,100%),0)}[data-vaul-drawer][data-vaul-snap-points=true][data-vaul-drawer-direction=top]{transform:translate3d(0,calc(var(--initial-transform,100%) * -1),0)}[data-vaul-drawer][data-vaul-snap-points=true][data-vaul-drawer-direction=left]{transform:translate3d(calc(var(--initial-transform,100%) * -1),0,0)}[data-vaul-drawer][data-vaul-snap-points=true][data-vaul-drawer-direction=right]{transform:translate3d(var(--initial-transform,100%),0,0)}[data-vaul-drawer][data-vaul-delayed-snap-points=true][data-vaul-drawer-direction=top]{transform:translate3d(0,var(--snap-point-height,0),0)}[data-vaul-drawer][data-vaul-delayed-snap-points=true][data-vaul-drawer-direction=bottom]{transform:translate3d(0,var(--snap-point-height,0),0)}[data-vaul-drawer][data-vaul-delayed-snap-points=true][data-vaul-drawer-direction=left]{transform:translate3d(var(--snap-point-height,0),0,0)}[data-vaul-drawer][data-vaul-delayed-snap-points=true][data-vaul-drawer-direction=right]{transform:translate3d(var(--snap-point-height,0),0,0)}[data-vaul-overlay][data-vaul-snap-points=false]{animation-duration:.5s;animation-timing-function:cubic-bezier(0.32,0.72,0,1)}[data-vaul-overlay][data-vaul-snap-points=false][data-state=open]{animation-name:fadeIn}[data-vaul-overlay][data-state=closed]{animation-name:fadeOut}[data-vaul-animate=false]{animation:none!important}[data-vaul-overlay][data-vaul-snap-points=true]{opacity:0;transition:opacity .5s cubic-bezier(.32, .72, 0, 1)}[data-vaul-overlay][data-vaul-snap-points=true]{opacity:1}[data-vaul-drawer]:not([data-vaul-custom-container=true])::after{content:'';position:absolute;background:inherit;background-color:inherit}[data-vaul-drawer][data-vaul-drawer-direction=top]::after{top:initial;bottom:100%;left:0;right:0;height:200%}[data-vaul-drawer][data-vaul-drawer-direction=bottom]::after{top:100%;bottom:initial;left:0;right:0;height:200%}[data-vaul-drawer][data-vaul-drawer-direction=left]::after{left:initial;right:100%;top:0;bottom:0;width:200%}[data-vaul-drawer][data-vaul-drawer-direction=right]::after{left:100%;right:initial;top:0;bottom:0;width:200%}[data-vaul-overlay][data-vaul-snap-points=true]:not([data-vaul-snap-points-overlay=true]):not(\n[data-state=closed]\n){opacity:0}[data-vaul-overlay][data-vaul-snap-points-overlay=true]{opacity:1}[data-vaul-handle]{display:block;position:relative;opacity:.7;background:#e2e2e4;margin-left:auto;margin-right:auto;height:5px;width:32px;border-radius:1rem;touch-action:pan-y}[data-vaul-handle]:active,[data-vaul-handle]:hover{opacity:1}[data-vaul-handle-hitarea]{position:absolute;left:50%;top:50%;transform:translate(-50%,-50%);width:max(100%,2.75rem);height:max(100%,2.75rem);touch-action:inherit}@media (hover:hover) and (pointer:fine){[data-vaul-drawer]{user-select:none}}@media (pointer:fine){[data-vaul-handle-hitarea]:{width:100%;height:100%}}@keyframes fadeIn{from{opacity:0}to{opacity:1}}@keyframes fadeOut{to{opacity:0}}@keyframes slideFromBottom{from{transform:translate3d(0,var(--initial-transform,100%),0)}to{transform:translate3d(0,0,0)}}@keyframes slideToBottom{to{transform:translate3d(0,var(--initial-transform,100%),0)}}@keyframes slideFromTop{from{transform:translate3d(0,calc(var(--initial-transform,100%) * -1),0)}to{transform:translate3d(0,0,0)}}@keyframes slideToTop{to{transform:translate3d(0,calc(var(--initial-transform,100%) * -1),0)}}@keyframes slideFromLeft{from{transform:translate3d(calc(var(--initial-transform,100%) * -1),0,0)}to{transform:translate3d(0,0,0)}}@keyframes slideToLeft{to{transform:translate3d(calc(var(--initial-transform,100%) * -1),0,0)}}@keyframes slideFromRight{from{transform:translate3d(var(--initial-transform,100%),0,0)}to{transform:translate3d(0,0,0)}}@keyframes slideToRight{to{transform:translate3d(var(--initial-transform,100%),0,0)}}");
69
+
70
+ function isMobileFirefox() {
71
+ const userAgent = navigator.userAgent;
72
+ return typeof window !== 'undefined' && (/Firefox/.test(userAgent) && /Mobile/.test(userAgent) || // Android Firefox
73
+ /FxiOS/.test(userAgent) // iOS Firefox
74
+ );
75
+ }
76
+ function isMac() {
77
+ return testPlatform(/^Mac/);
78
+ }
79
+ function isIPhone() {
80
+ return testPlatform(/^iPhone/);
81
+ }
82
+ function isSafari() {
83
+ return /^((?!chrome|android).)*safari/i.test(navigator.userAgent);
84
+ }
85
+ function isIPad() {
86
+ return testPlatform(/^iPad/) || // iPadOS 13 lies and says it's a Mac, but we can distinguish by detecting touch support.
87
+ isMac() && navigator.maxTouchPoints > 1;
88
+ }
89
+ function isIOS() {
90
+ return isIPhone() || isIPad();
91
+ }
92
+ function testPlatform(re) {
93
+ return typeof window !== 'undefined' && window.navigator != null ? re.test(window.navigator.platform) : undefined;
94
+ }
95
+
96
+ // This code comes from https://github.com/adobe/react-spectrum/blob/main/packages/%40react-aria/overlays/src/usePreventScroll.ts
97
+ const KEYBOARD_BUFFER = 24;
98
+ const useIsomorphicLayoutEffect = typeof window !== 'undefined' ? React.useLayoutEffect : React.useEffect;
99
+ function chain$1(...callbacks) {
100
+ return (...args)=>{
101
+ for (let callback of callbacks){
102
+ if (typeof callback === 'function') {
103
+ callback(...args);
104
+ }
105
+ }
106
+ };
107
+ }
108
+ // @ts-ignore
109
+ const visualViewport = typeof document !== 'undefined' && window.visualViewport;
110
+ function isScrollable(node) {
111
+ let style = window.getComputedStyle(node);
112
+ return /(auto|scroll)/.test(style.overflow + style.overflowX + style.overflowY);
113
+ }
114
+ function getScrollParent(node) {
115
+ if (isScrollable(node)) {
116
+ node = node.parentElement;
117
+ }
118
+ while(node && !isScrollable(node)){
119
+ node = node.parentElement;
120
+ }
121
+ return node || document.scrollingElement || document.documentElement;
122
+ }
123
+ // HTML input types that do not cause the software keyboard to appear.
124
+ const nonTextInputTypes = new Set([
125
+ 'checkbox',
126
+ 'radio',
127
+ 'range',
128
+ 'color',
129
+ 'file',
130
+ 'image',
131
+ 'button',
132
+ 'submit',
133
+ 'reset'
134
+ ]);
135
+ // The number of active usePreventScroll calls. Used to determine whether to revert back to the original page style/scroll position
136
+ let preventScrollCount = 0;
137
+ let restore;
138
+ /**
139
+ * Prevents scrolling on the document body on mount, and
140
+ * restores it on unmount. Also ensures that content does not
141
+ * shift due to the scrollbars disappearing.
142
+ */ function usePreventScroll(options = {}) {
143
+ let { isDisabled } = options;
144
+ useIsomorphicLayoutEffect(()=>{
145
+ if (isDisabled) {
146
+ return;
147
+ }
148
+ preventScrollCount++;
149
+ if (preventScrollCount === 1) {
150
+ if (isIOS()) {
151
+ restore = preventScrollMobileSafari();
152
+ }
153
+ }
154
+ return ()=>{
155
+ preventScrollCount--;
156
+ if (preventScrollCount === 0) {
157
+ restore == null ? void 0 : restore();
158
+ }
159
+ };
160
+ }, [
161
+ isDisabled
162
+ ]);
163
+ }
164
+ // Mobile Safari is a whole different beast. Even with overflow: hidden,
165
+ // it still scrolls the page in many situations:
166
+ //
167
+ // 1. When the bottom toolbar and address bar are collapsed, page scrolling is always allowed.
168
+ // 2. When the keyboard is visible, the viewport does not resize. Instead, the keyboard covers part of
169
+ // it, so it becomes scrollable.
170
+ // 3. When tapping on an input, the page always scrolls so that the input is centered in the visual viewport.
171
+ // This may cause even fixed position elements to scroll off the screen.
172
+ // 4. When using the next/previous buttons in the keyboard to navigate between inputs, the whole page always
173
+ // scrolls, even if the input is inside a nested scrollable element that could be scrolled instead.
174
+ //
175
+ // In order to work around these cases, and prevent scrolling without jankiness, we do a few things:
176
+ //
177
+ // 1. Prevent default on `touchmove` events that are not in a scrollable element. This prevents touch scrolling
178
+ // on the window.
179
+ // 2. Prevent default on `touchmove` events inside a scrollable element when the scroll position is at the
180
+ // top or bottom. This avoids the whole page scrolling instead, but does prevent overscrolling.
181
+ // 3. Prevent default on `touchend` events on input elements and handle focusing the element ourselves.
182
+ // 4. When focusing an input, apply a transform to trick Safari into thinking the input is at the top
183
+ // of the page, which prevents it from scrolling the page. After the input is focused, scroll the element
184
+ // into view ourselves, without scrolling the whole page.
185
+ // 5. Offset the body by the scroll position using a negative margin and scroll to the top. This should appear the
186
+ // same visually, but makes the actual scroll position always zero. This is required to make all of the
187
+ // above work or Safari will still try to scroll the page when focusing an input.
188
+ // 6. As a last resort, handle window scroll events, and scroll back to the top. This can happen when attempting
189
+ // to navigate to an input with the next/previous buttons that's outside a modal.
190
+ function preventScrollMobileSafari() {
191
+ let scrollable;
192
+ let lastY = 0;
193
+ let onTouchStart = (e)=>{
194
+ // Store the nearest scrollable parent element from the element that the user touched.
195
+ scrollable = getScrollParent(e.target);
196
+ if (scrollable === document.documentElement && scrollable === document.body) {
197
+ return;
198
+ }
199
+ lastY = e.changedTouches[0].pageY;
200
+ };
201
+ let onTouchMove = (e)=>{
202
+ // Prevent scrolling the window.
203
+ if (!scrollable || scrollable === document.documentElement || scrollable === document.body) {
204
+ e.preventDefault();
205
+ return;
206
+ }
207
+ // Prevent scrolling up when at the top and scrolling down when at the bottom
208
+ // of a nested scrollable area, otherwise mobile Safari will start scrolling
209
+ // the window instead. Unfortunately, this disables bounce scrolling when at
210
+ // the top but it's the best we can do.
211
+ let y = e.changedTouches[0].pageY;
212
+ let scrollTop = scrollable.scrollTop;
213
+ let bottom = scrollable.scrollHeight - scrollable.clientHeight;
214
+ if (bottom === 0) {
215
+ return;
216
+ }
217
+ if (scrollTop <= 0 && y > lastY || scrollTop >= bottom && y < lastY) {
218
+ e.preventDefault();
219
+ }
220
+ lastY = y;
221
+ };
222
+ let onTouchEnd = (e)=>{
223
+ let target = e.target;
224
+ // Apply this change if we're not already focused on the target element
225
+ if (isInput(target) && target !== document.activeElement) {
226
+ e.preventDefault();
227
+ // Apply a transform to trick Safari into thinking the input is at the top of the page
228
+ // so it doesn't try to scroll it into view. When tapping on an input, this needs to
229
+ // be done before the "focus" event, so we have to focus the element ourselves.
230
+ target.style.transform = 'translateY(-2000px)';
231
+ target.focus();
232
+ requestAnimationFrame(()=>{
233
+ target.style.transform = '';
234
+ });
235
+ }
236
+ };
237
+ let onFocus = (e)=>{
238
+ let target = e.target;
239
+ if (isInput(target)) {
240
+ // Transform also needs to be applied in the focus event in cases where focus moves
241
+ // other than tapping on an input directly, e.g. the next/previous buttons in the
242
+ // software keyboard. In these cases, it seems applying the transform in the focus event
243
+ // is good enough, whereas when tapping an input, it must be done before the focus event. 🤷‍♂️
244
+ target.style.transform = 'translateY(-2000px)';
245
+ requestAnimationFrame(()=>{
246
+ target.style.transform = '';
247
+ // This will have prevented the browser from scrolling the focused element into view,
248
+ // so we need to do this ourselves in a way that doesn't cause the whole page to scroll.
249
+ if (visualViewport) {
250
+ if (visualViewport.height < window.innerHeight) {
251
+ // If the keyboard is already visible, do this after one additional frame
252
+ // to wait for the transform to be removed.
253
+ requestAnimationFrame(()=>{
254
+ scrollIntoView(target);
255
+ });
256
+ } else {
257
+ // Otherwise, wait for the visual viewport to resize before scrolling so we can
258
+ // measure the correct position to scroll to.
259
+ visualViewport.addEventListener('resize', ()=>scrollIntoView(target), {
260
+ once: true
261
+ });
262
+ }
263
+ }
264
+ });
265
+ }
266
+ };
267
+ let onWindowScroll = ()=>{
268
+ // Last resort. If the window scrolled, scroll it back to the top.
269
+ // It should always be at the top because the body will have a negative margin (see below).
270
+ window.scrollTo(0, 0);
271
+ };
272
+ // Record the original scroll position so we can restore it.
273
+ // Then apply a negative margin to the body to offset it by the scroll position. This will
274
+ // enable us to scroll the window to the top, which is required for the rest of this to work.
275
+ let scrollX = window.pageXOffset;
276
+ let scrollY = window.pageYOffset;
277
+ let restoreStyles = chain$1(setStyle(document.documentElement, 'paddingRight', `${window.innerWidth - document.documentElement.clientWidth}px`));
278
+ // Scroll to the top. The negative margin on the body will make this appear the same.
279
+ window.scrollTo(0, 0);
280
+ let removeEvents = chain$1(addEvent(document, 'touchstart', onTouchStart, {
281
+ passive: false,
282
+ capture: true
283
+ }), addEvent(document, 'touchmove', onTouchMove, {
284
+ passive: false,
285
+ capture: true
286
+ }), addEvent(document, 'touchend', onTouchEnd, {
287
+ passive: false,
288
+ capture: true
289
+ }), addEvent(document, 'focus', onFocus, true), addEvent(window, 'scroll', onWindowScroll));
290
+ return ()=>{
291
+ // Restore styles and scroll the page back to where it was.
292
+ restoreStyles();
293
+ removeEvents();
294
+ window.scrollTo(scrollX, scrollY);
295
+ };
296
+ }
297
+ // Sets a CSS property on an element, and returns a function to revert it to the previous value.
298
+ function setStyle(element, style, value) {
299
+ // https://github.com/microsoft/TypeScript/issues/17827#issuecomment-391663310
300
+ // @ts-ignore
301
+ let cur = element.style[style];
302
+ // @ts-ignore
303
+ element.style[style] = value;
304
+ return ()=>{
305
+ // @ts-ignore
306
+ element.style[style] = cur;
307
+ };
308
+ }
309
+ // Adds an event listener to an element, and returns a function to remove it.
310
+ function addEvent(target, event, handler, options) {
311
+ // @ts-ignore
312
+ target.addEventListener(event, handler, options);
313
+ return ()=>{
314
+ // @ts-ignore
315
+ target.removeEventListener(event, handler, options);
316
+ };
317
+ }
318
+ function scrollIntoView(target) {
319
+ let root = document.scrollingElement || document.documentElement;
320
+ while(target && target !== root){
321
+ // Find the parent scrollable element and adjust the scroll position if the target is not already in view.
322
+ let scrollable = getScrollParent(target);
323
+ if (scrollable !== document.documentElement && scrollable !== document.body && scrollable !== target) {
324
+ let scrollableTop = scrollable.getBoundingClientRect().top;
325
+ let targetTop = target.getBoundingClientRect().top;
326
+ let targetBottom = target.getBoundingClientRect().bottom;
327
+ // Buffer is needed for some edge cases
328
+ const keyboardHeight = scrollable.getBoundingClientRect().bottom + KEYBOARD_BUFFER;
329
+ if (targetBottom > keyboardHeight) {
330
+ scrollable.scrollTop += targetTop - scrollableTop;
331
+ }
332
+ }
333
+ // @ts-ignore
334
+ target = scrollable.parentElement;
335
+ }
336
+ }
337
+ function isInput(target) {
338
+ return target instanceof HTMLInputElement && !nonTextInputTypes.has(target.type) || target instanceof HTMLTextAreaElement || target instanceof HTMLElement && target.isContentEditable;
339
+ }
340
+
341
+ // This code comes from https://github.com/radix-ui/primitives/tree/main/packages/react/compose-refs
342
+ /**
343
+ * Set a given ref to a given value
344
+ * This utility takes care of different types of refs: callback refs and RefObject(s)
345
+ */ function setRef(ref, value) {
346
+ if (typeof ref === 'function') {
347
+ ref(value);
348
+ } else if (ref !== null && ref !== undefined) {
349
+ ref.current = value;
350
+ }
351
+ }
352
+ /**
353
+ * A utility to compose multiple refs together
354
+ * Accepts callback refs and RefObject(s)
355
+ */ function composeRefs(...refs) {
356
+ return (node)=>refs.forEach((ref)=>setRef(ref, node));
357
+ }
358
+ /**
359
+ * A custom hook that composes multiple refs
360
+ * Accepts callback refs and RefObject(s)
361
+ */ function useComposedRefs(...refs) {
362
+ // eslint-disable-next-line react-hooks/exhaustive-deps
363
+ return React.useCallback(composeRefs(...refs), refs);
364
+ }
365
+
366
+ const cache = new WeakMap();
367
+ function set(el, styles, ignoreCache = false) {
368
+ if (!el || !(el instanceof HTMLElement)) return;
369
+ let originalStyles = {};
370
+ Object.entries(styles).forEach(([key, value])=>{
371
+ if (key.startsWith('--')) {
372
+ el.style.setProperty(key, value);
373
+ return;
374
+ }
375
+ originalStyles[key] = el.style[key];
376
+ el.style[key] = value;
377
+ });
378
+ if (ignoreCache) return;
379
+ cache.set(el, originalStyles);
380
+ }
381
+ function reset(el, prop) {
382
+ if (!el || !(el instanceof HTMLElement)) return;
383
+ let originalStyles = cache.get(el);
384
+ if (!originalStyles) {
385
+ return;
386
+ }
387
+ {
388
+ el.style[prop] = originalStyles[prop];
389
+ }
390
+ }
391
+ const isVertical = (direction)=>{
392
+ switch(direction){
393
+ case 'top':
394
+ case 'bottom':
395
+ return true;
396
+ case 'left':
397
+ case 'right':
398
+ return false;
399
+ default:
400
+ return direction;
401
+ }
402
+ };
403
+ function getTranslate(element, direction) {
404
+ if (!element) {
405
+ return null;
406
+ }
407
+ const style = window.getComputedStyle(element);
408
+ const transform = // @ts-ignore
409
+ style.transform || style.webkitTransform || style.mozTransform;
410
+ let mat = transform.match(/^matrix3d\((.+)\)$/);
411
+ if (mat) {
412
+ // https://developer.mozilla.org/en-US/docs/Web/CSS/transform-function/matrix3d
413
+ return parseFloat(mat[1].split(', ')[isVertical(direction) ? 13 : 12]);
414
+ }
415
+ // https://developer.mozilla.org/en-US/docs/Web/CSS/transform-function/matrix
416
+ mat = transform.match(/^matrix\((.+)\)$/);
417
+ return mat ? parseFloat(mat[1].split(', ')[isVertical(direction) ? 5 : 4]) : null;
418
+ }
419
+ function dampenValue(v) {
420
+ return 8 * (Math.log(v + 1) - 2);
421
+ }
422
+ function assignStyle(element, style) {
423
+ if (!element) return ()=>{};
424
+ const prevStyle = element.style.cssText;
425
+ Object.assign(element.style, style);
426
+ return ()=>{
427
+ element.style.cssText = prevStyle;
428
+ };
429
+ }
430
+ /**
431
+ * Receives functions as arguments and returns a new function that calls all.
432
+ */ function chain(...fns) {
433
+ return (...args)=>{
434
+ for (const fn of fns){
435
+ if (typeof fn === 'function') {
436
+ // @ts-ignore
437
+ fn(...args);
438
+ }
439
+ }
440
+ };
441
+ }
442
+
443
+ const TRANSITIONS = {
444
+ DURATION: 0.5,
445
+ EASE: [
446
+ 0.32,
447
+ 0.72,
448
+ 0,
449
+ 1
450
+ ]
451
+ };
452
+ const VELOCITY_THRESHOLD = 0.4;
453
+ const CLOSE_THRESHOLD = 0.25;
454
+ const SCROLL_LOCK_TIMEOUT = 100;
455
+ const BORDER_RADIUS = 8;
456
+ const NESTED_DISPLACEMENT = 16;
457
+ const WINDOW_TOP_OFFSET = 26;
458
+ const DRAG_CLASS = 'vaul-dragging';
459
+
460
+ // This code comes from https://github.com/radix-ui/primitives/blob/main/packages/react/use-controllable-state/src/useControllableState.tsx
461
+ function useCallbackRef(callback) {
462
+ const callbackRef = React__default['default'].useRef(callback);
463
+ React__default['default'].useEffect(()=>{
464
+ callbackRef.current = callback;
465
+ });
466
+ // https://github.com/facebook/react/issues/19240
467
+ return React__default['default'].useMemo(()=>(...args)=>callbackRef.current == null ? void 0 : callbackRef.current.call(callbackRef, ...args), []);
468
+ }
469
+ function useUncontrolledState({ defaultProp, onChange }) {
470
+ const uncontrolledState = React__default['default'].useState(defaultProp);
471
+ const [value] = uncontrolledState;
472
+ const prevValueRef = React__default['default'].useRef(value);
473
+ const handleChange = useCallbackRef(onChange);
474
+ React__default['default'].useEffect(()=>{
475
+ if (prevValueRef.current !== value) {
476
+ handleChange(value);
477
+ prevValueRef.current = value;
478
+ }
479
+ }, [
480
+ value,
481
+ prevValueRef,
482
+ handleChange
483
+ ]);
484
+ return uncontrolledState;
485
+ }
486
+ function useControllableState({ prop, defaultProp, onChange = ()=>{} }) {
487
+ const [uncontrolledProp, setUncontrolledProp] = useUncontrolledState({
488
+ defaultProp,
489
+ onChange
490
+ });
491
+ const isControlled = prop !== undefined;
492
+ const value = isControlled ? prop : uncontrolledProp;
493
+ const handleChange = useCallbackRef(onChange);
494
+ const setValue = React__default['default'].useCallback((nextValue)=>{
495
+ if (isControlled) {
496
+ const setter = nextValue;
497
+ const value = typeof nextValue === 'function' ? setter(prop) : nextValue;
498
+ if (value !== prop) handleChange(value);
499
+ } else {
500
+ setUncontrolledProp(nextValue);
501
+ }
502
+ }, [
503
+ isControlled,
504
+ prop,
505
+ setUncontrolledProp,
506
+ handleChange
507
+ ]);
508
+ return [
509
+ value,
510
+ setValue
511
+ ];
512
+ }
513
+
514
+ function useSnapPoints({ activeSnapPointProp, setActiveSnapPointProp, snapPoints, drawerRef, overlayRef, fadeFromIndex, onSnapPointChange, direction = 'bottom', container, snapToSequentialPoint }) {
515
+ const [activeSnapPoint, setActiveSnapPoint] = useControllableState({
516
+ prop: activeSnapPointProp,
517
+ defaultProp: snapPoints == null ? void 0 : snapPoints[0],
518
+ onChange: setActiveSnapPointProp
519
+ });
520
+ const [windowDimensions, setWindowDimensions] = React__default['default'].useState(typeof window !== 'undefined' ? {
521
+ innerWidth: window.innerWidth,
522
+ innerHeight: window.innerHeight
523
+ } : undefined);
524
+ React__default['default'].useEffect(()=>{
525
+ function onResize() {
526
+ setWindowDimensions({
527
+ innerWidth: window.innerWidth,
528
+ innerHeight: window.innerHeight
529
+ });
530
+ }
531
+ window.addEventListener('resize', onResize);
532
+ return ()=>window.removeEventListener('resize', onResize);
533
+ }, []);
534
+ const isLastSnapPoint = React__default['default'].useMemo(()=>activeSnapPoint === (snapPoints == null ? void 0 : snapPoints[snapPoints.length - 1]) || null, [
535
+ snapPoints,
536
+ activeSnapPoint
537
+ ]);
538
+ const activeSnapPointIndex = React__default['default'].useMemo(()=>{
539
+ var _snapPoints_findIndex;
540
+ return (_snapPoints_findIndex = snapPoints == null ? void 0 : snapPoints.findIndex((snapPoint)=>snapPoint === activeSnapPoint)) != null ? _snapPoints_findIndex : null;
541
+ }, [
542
+ snapPoints,
543
+ activeSnapPoint
544
+ ]);
545
+ const shouldFade = snapPoints && snapPoints.length > 0 && (fadeFromIndex || fadeFromIndex === 0) && !Number.isNaN(fadeFromIndex) && snapPoints[fadeFromIndex] === activeSnapPoint || !snapPoints;
546
+ const snapPointsOffset = React__default['default'].useMemo(()=>{
547
+ const containerSize = container ? {
548
+ width: container.getBoundingClientRect().width,
549
+ height: container.getBoundingClientRect().height
550
+ } : typeof window !== 'undefined' ? {
551
+ width: window.innerWidth,
552
+ height: window.innerHeight
553
+ } : {
554
+ width: 0,
555
+ height: 0
556
+ };
557
+ var _snapPoints_map;
558
+ return (_snapPoints_map = snapPoints == null ? void 0 : snapPoints.map((snapPoint)=>{
559
+ const isPx = typeof snapPoint === 'string';
560
+ let snapPointAsNumber = 0;
561
+ if (isPx) {
562
+ snapPointAsNumber = parseInt(snapPoint, 10);
563
+ }
564
+ if (isVertical(direction)) {
565
+ const height = isPx ? snapPointAsNumber : windowDimensions ? snapPoint * containerSize.height : 0;
566
+ if (windowDimensions) {
567
+ return direction === 'bottom' ? containerSize.height - height : -containerSize.height + height;
568
+ }
569
+ return height;
570
+ }
571
+ const width = isPx ? snapPointAsNumber : windowDimensions ? snapPoint * containerSize.width : 0;
572
+ if (windowDimensions) {
573
+ return direction === 'right' ? containerSize.width - width : -containerSize.width + width;
574
+ }
575
+ return width;
576
+ })) != null ? _snapPoints_map : [];
577
+ }, [
578
+ snapPoints,
579
+ windowDimensions,
580
+ container
581
+ ]);
582
+ const activeSnapPointOffset = React__default['default'].useMemo(()=>activeSnapPointIndex !== null ? snapPointsOffset == null ? void 0 : snapPointsOffset[activeSnapPointIndex] : null, [
583
+ snapPointsOffset,
584
+ activeSnapPointIndex
585
+ ]);
586
+ const snapToPoint = React__default['default'].useCallback((dimension)=>{
587
+ var _snapPointsOffset_findIndex;
588
+ const newSnapPointIndex = (_snapPointsOffset_findIndex = snapPointsOffset == null ? void 0 : snapPointsOffset.findIndex((snapPointDim)=>snapPointDim === dimension)) != null ? _snapPointsOffset_findIndex : null;
589
+ onSnapPointChange(newSnapPointIndex);
590
+ set(drawerRef.current, {
591
+ transition: `transform ${TRANSITIONS.DURATION}s cubic-bezier(${TRANSITIONS.EASE.join(',')})`,
592
+ transform: isVertical(direction) ? `translate3d(0, ${dimension}px, 0)` : `translate3d(${dimension}px, 0, 0)`
593
+ });
594
+ if (snapPointsOffset && newSnapPointIndex !== snapPointsOffset.length - 1 && fadeFromIndex !== undefined && newSnapPointIndex !== fadeFromIndex && newSnapPointIndex < fadeFromIndex) {
595
+ set(overlayRef.current, {
596
+ transition: `opacity ${TRANSITIONS.DURATION}s cubic-bezier(${TRANSITIONS.EASE.join(',')})`,
597
+ opacity: '0'
598
+ });
599
+ } else {
600
+ set(overlayRef.current, {
601
+ transition: `opacity ${TRANSITIONS.DURATION}s cubic-bezier(${TRANSITIONS.EASE.join(',')})`,
602
+ opacity: '1'
603
+ });
604
+ }
605
+ setActiveSnapPoint(snapPoints == null ? void 0 : snapPoints[Math.max(newSnapPointIndex, 0)]);
606
+ }, [
607
+ drawerRef.current,
608
+ snapPoints,
609
+ snapPointsOffset,
610
+ fadeFromIndex,
611
+ overlayRef,
612
+ setActiveSnapPoint
613
+ ]);
614
+ React__default['default'].useEffect(()=>{
615
+ if (activeSnapPoint || activeSnapPointProp) {
616
+ var _snapPoints_findIndex;
617
+ const newIndex = (_snapPoints_findIndex = snapPoints == null ? void 0 : snapPoints.findIndex((snapPoint)=>snapPoint === activeSnapPointProp || snapPoint === activeSnapPoint)) != null ? _snapPoints_findIndex : -1;
618
+ if (snapPointsOffset && newIndex !== -1 && typeof snapPointsOffset[newIndex] === 'number') {
619
+ snapToPoint(snapPointsOffset[newIndex]);
620
+ }
621
+ }
622
+ }, [
623
+ activeSnapPoint,
624
+ activeSnapPointProp,
625
+ snapPoints,
626
+ snapPointsOffset,
627
+ snapToPoint
628
+ ]);
629
+ function onRelease({ draggedDistance, closeDrawer, velocity, dismissible }) {
630
+ if (fadeFromIndex === undefined) return;
631
+ const currentPosition = direction === 'bottom' || direction === 'right' ? (activeSnapPointOffset != null ? activeSnapPointOffset : 0) - draggedDistance : (activeSnapPointOffset != null ? activeSnapPointOffset : 0) + draggedDistance;
632
+ const isOverlaySnapPoint = activeSnapPointIndex === fadeFromIndex - 1;
633
+ const isFirst = activeSnapPointIndex === 0;
634
+ const hasDraggedUp = draggedDistance > 0;
635
+ if (isOverlaySnapPoint) {
636
+ set(overlayRef.current, {
637
+ transition: `opacity ${TRANSITIONS.DURATION}s cubic-bezier(${TRANSITIONS.EASE.join(',')})`
638
+ });
639
+ }
640
+ if (!snapToSequentialPoint && velocity > 2 && !hasDraggedUp) {
641
+ if (dismissible) closeDrawer();
642
+ else snapToPoint(snapPointsOffset[0]); // snap to initial point
643
+ return;
644
+ }
645
+ if (!snapToSequentialPoint && velocity > 2 && hasDraggedUp && snapPointsOffset && snapPoints) {
646
+ snapToPoint(snapPointsOffset[snapPoints.length - 1]);
647
+ return;
648
+ }
649
+ // Find the closest snap point to the current position
650
+ const closestSnapPoint = snapPointsOffset == null ? void 0 : snapPointsOffset.reduce((prev, curr)=>{
651
+ if (typeof prev !== 'number' || typeof curr !== 'number') return prev;
652
+ return Math.abs(curr - currentPosition) < Math.abs(prev - currentPosition) ? curr : prev;
653
+ });
654
+ const dim = isVertical(direction) ? window.innerHeight : window.innerWidth;
655
+ if (velocity > VELOCITY_THRESHOLD && Math.abs(draggedDistance) < dim * 0.4) {
656
+ const dragDirection = hasDraggedUp ? 1 : -1; // 1 = up, -1 = down
657
+ // Don't do anything if we swipe upwards while being on the last snap point
658
+ if (dragDirection > 0 && isLastSnapPoint && snapPoints) {
659
+ snapToPoint(snapPointsOffset[snapPoints.length - 1]);
660
+ return;
661
+ }
662
+ if (isFirst && dragDirection < 0 && dismissible) {
663
+ closeDrawer();
664
+ }
665
+ if (activeSnapPointIndex === null) return;
666
+ snapToPoint(snapPointsOffset[activeSnapPointIndex + dragDirection]);
667
+ return;
668
+ }
669
+ snapToPoint(closestSnapPoint);
670
+ }
671
+ function onDrag({ draggedDistance }) {
672
+ if (activeSnapPointOffset === null) return;
673
+ const newValue = direction === 'bottom' || direction === 'right' ? activeSnapPointOffset - draggedDistance : activeSnapPointOffset + draggedDistance;
674
+ // Don't do anything if we exceed the last(biggest) snap point
675
+ if ((direction === 'bottom' || direction === 'right') && newValue < snapPointsOffset[snapPointsOffset.length - 1]) {
676
+ return;
677
+ }
678
+ if ((direction === 'top' || direction === 'left') && newValue > snapPointsOffset[snapPointsOffset.length - 1]) {
679
+ return;
680
+ }
681
+ set(drawerRef.current, {
682
+ transform: isVertical(direction) ? `translate3d(0, ${newValue}px, 0)` : `translate3d(${newValue}px, 0, 0)`
683
+ });
684
+ }
685
+ function getPercentageDragged(absDraggedDistance, isDraggingDown) {
686
+ if (!snapPoints || typeof activeSnapPointIndex !== 'number' || !snapPointsOffset || fadeFromIndex === undefined) return null;
687
+ // If this is true we are dragging to a snap point that is supposed to have an overlay
688
+ const isOverlaySnapPoint = activeSnapPointIndex === fadeFromIndex - 1;
689
+ const isOverlaySnapPointOrHigher = activeSnapPointIndex >= fadeFromIndex;
690
+ if (isOverlaySnapPointOrHigher && isDraggingDown) {
691
+ return 0;
692
+ }
693
+ // Don't animate, but still use this one if we are dragging away from the overlaySnapPoint
694
+ if (isOverlaySnapPoint && !isDraggingDown) return 1;
695
+ if (!shouldFade && !isOverlaySnapPoint) return null;
696
+ // Either fadeFrom index or the one before
697
+ const targetSnapPointIndex = isOverlaySnapPoint ? activeSnapPointIndex + 1 : activeSnapPointIndex - 1;
698
+ // Get the distance from overlaySnapPoint to the one before or vice-versa to calculate the opacity percentage accordingly
699
+ const snapPointDistance = isOverlaySnapPoint ? snapPointsOffset[targetSnapPointIndex] - snapPointsOffset[targetSnapPointIndex - 1] : snapPointsOffset[targetSnapPointIndex + 1] - snapPointsOffset[targetSnapPointIndex];
700
+ const percentageDragged = absDraggedDistance / Math.abs(snapPointDistance);
701
+ if (isOverlaySnapPoint) {
702
+ return 1 - percentageDragged;
703
+ } else {
704
+ return percentageDragged;
705
+ }
706
+ }
707
+ return {
708
+ isLastSnapPoint,
709
+ activeSnapPoint,
710
+ shouldFade,
711
+ getPercentageDragged,
712
+ setActiveSnapPoint,
713
+ activeSnapPointIndex,
714
+ onRelease,
715
+ onDrag,
716
+ snapPointsOffset
717
+ };
718
+ }
719
+
720
+ const noop = ()=>()=>{};
721
+ function useScaleBackground() {
722
+ const { direction, isOpen, shouldScaleBackground, setBackgroundColorOnScale, noBodyStyles } = useDrawerContext();
723
+ const timeoutIdRef = React__default['default'].useRef(null);
724
+ const initialBackgroundColor = React.useMemo(()=>document.body.style.backgroundColor, []);
725
+ function getScale() {
726
+ return (window.innerWidth - WINDOW_TOP_OFFSET) / window.innerWidth;
727
+ }
728
+ React__default['default'].useEffect(()=>{
729
+ if (isOpen && shouldScaleBackground) {
730
+ if (timeoutIdRef.current) clearTimeout(timeoutIdRef.current);
731
+ const wrapper = document.querySelector('[data-vaul-drawer-wrapper]') || document.querySelector('[vaul-drawer-wrapper]');
732
+ if (!wrapper) return;
733
+ chain(setBackgroundColorOnScale && !noBodyStyles ? assignStyle(document.body, {
734
+ background: 'black'
735
+ }) : noop, assignStyle(wrapper, {
736
+ transformOrigin: isVertical(direction) ? 'top' : 'left',
737
+ transitionProperty: 'transform, border-radius',
738
+ transitionDuration: `${TRANSITIONS.DURATION}s`,
739
+ transitionTimingFunction: `cubic-bezier(${TRANSITIONS.EASE.join(',')})`
740
+ }));
741
+ const wrapperStylesCleanup = assignStyle(wrapper, {
742
+ borderRadius: `${BORDER_RADIUS}px`,
743
+ overflow: 'hidden',
744
+ ...isVertical(direction) ? {
745
+ transform: `scale(${getScale()}) translate3d(0, calc(env(safe-area-inset-top) + 14px), 0)`
746
+ } : {
747
+ transform: `scale(${getScale()}) translate3d(calc(env(safe-area-inset-top) + 14px), 0, 0)`
748
+ }
749
+ });
750
+ return ()=>{
751
+ wrapperStylesCleanup();
752
+ timeoutIdRef.current = window.setTimeout(()=>{
753
+ if (initialBackgroundColor) {
754
+ document.body.style.background = initialBackgroundColor;
755
+ } else {
756
+ document.body.style.removeProperty('background');
757
+ }
758
+ }, TRANSITIONS.DURATION * 1000);
759
+ };
760
+ }
761
+ }, [
762
+ isOpen,
763
+ shouldScaleBackground,
764
+ initialBackgroundColor
765
+ ]);
766
+ }
767
+
768
+ let previousBodyPosition = null;
769
+ /**
770
+ * This hook is necessary to prevent buggy behavior on iOS devices (need to test on Android).
771
+ * I won't get into too much detail about what bugs it solves, but so far I've found that setting the body to `position: fixed` is the most reliable way to prevent those bugs.
772
+ * Issues that this hook solves:
773
+ * https://github.com/emilkowalski/vaul/issues/435
774
+ * https://github.com/emilkowalski/vaul/issues/433
775
+ * And more that I discovered, but were just not reported.
776
+ */ function usePositionFixed({ isOpen, modal, nested, hasBeenOpened, preventScrollRestoration, noBodyStyles }) {
777
+ const [activeUrl, setActiveUrl] = React__default['default'].useState(()=>typeof window !== 'undefined' ? window.location.href : '');
778
+ const scrollPos = React__default['default'].useRef(0);
779
+ const setPositionFixed = React__default['default'].useCallback(()=>{
780
+ // All browsers on iOS will return true here.
781
+ if (!isSafari()) return;
782
+ // If previousBodyPosition is already set, don't set it again.
783
+ if (previousBodyPosition === null && isOpen && !noBodyStyles) {
784
+ previousBodyPosition = {
785
+ position: document.body.style.position,
786
+ top: document.body.style.top,
787
+ left: document.body.style.left,
788
+ height: document.body.style.height,
789
+ right: 'unset'
790
+ };
791
+ // Update the dom inside an animation frame
792
+ const { scrollX, innerHeight } = window;
793
+ document.body.style.setProperty('position', 'fixed', 'important');
794
+ Object.assign(document.body.style, {
795
+ top: `${-scrollPos.current}px`,
796
+ left: `${-scrollX}px`,
797
+ right: '0px',
798
+ height: 'auto'
799
+ });
800
+ window.setTimeout(()=>window.requestAnimationFrame(()=>{
801
+ // Attempt to check if the bottom bar appeared due to the position change
802
+ const bottomBarHeight = innerHeight - window.innerHeight;
803
+ if (bottomBarHeight && scrollPos.current >= innerHeight) {
804
+ // Move the content further up so that the bottom bar doesn't hide it
805
+ document.body.style.top = `${-(scrollPos.current + bottomBarHeight)}px`;
806
+ }
807
+ }), 300);
808
+ }
809
+ }, [
810
+ isOpen
811
+ ]);
812
+ const restorePositionSetting = React__default['default'].useCallback(()=>{
813
+ // All browsers on iOS will return true here.
814
+ if (!isSafari()) return;
815
+ if (previousBodyPosition !== null && !noBodyStyles) {
816
+ // Convert the position from "px" to Int
817
+ const y = -parseInt(document.body.style.top, 10);
818
+ const x = -parseInt(document.body.style.left, 10);
819
+ // Restore styles
820
+ Object.assign(document.body.style, previousBodyPosition);
821
+ window.requestAnimationFrame(()=>{
822
+ if (preventScrollRestoration && activeUrl !== window.location.href) {
823
+ setActiveUrl(window.location.href);
824
+ return;
825
+ }
826
+ window.scrollTo(x, y);
827
+ });
828
+ previousBodyPosition = null;
829
+ }
830
+ }, [
831
+ activeUrl
832
+ ]);
833
+ React__default['default'].useEffect(()=>{
834
+ function onScroll() {
835
+ scrollPos.current = window.scrollY;
836
+ }
837
+ onScroll();
838
+ window.addEventListener('scroll', onScroll);
839
+ return ()=>{
840
+ window.removeEventListener('scroll', onScroll);
841
+ };
842
+ }, []);
843
+ React__default['default'].useEffect(()=>{
844
+ if (!modal) return;
845
+ return ()=>{
846
+ if (typeof document === 'undefined') return;
847
+ // Another drawer is opened, safe to ignore the execution
848
+ const hasDrawerOpened = !!document.querySelector('[data-vaul-drawer]');
849
+ if (hasDrawerOpened) return;
850
+ restorePositionSetting();
851
+ };
852
+ }, [
853
+ modal,
854
+ restorePositionSetting
855
+ ]);
856
+ React__default['default'].useEffect(()=>{
857
+ if (nested || !hasBeenOpened) return;
858
+ // This is needed to force Safari toolbar to show **before** the drawer starts animating to prevent a gnarly shift from happening
859
+ if (isOpen) {
860
+ // avoid for standalone mode (PWA)
861
+ const isStandalone = window.matchMedia('(display-mode: standalone)').matches;
862
+ !isStandalone && setPositionFixed();
863
+ if (!modal) {
864
+ window.setTimeout(()=>{
865
+ restorePositionSetting();
866
+ }, 500);
867
+ }
868
+ } else {
869
+ restorePositionSetting();
870
+ }
871
+ }, [
872
+ isOpen,
873
+ hasBeenOpened,
874
+ activeUrl,
875
+ modal,
876
+ nested,
877
+ setPositionFixed,
878
+ restorePositionSetting
879
+ ]);
880
+ return {
881
+ restorePositionSetting
882
+ };
883
+ }
884
+
885
+ function Root({ open: openProp, onOpenChange, children, onDrag: onDragProp, onRelease: onReleaseProp, snapPoints, shouldScaleBackground = false, setBackgroundColorOnScale = true, closeThreshold = CLOSE_THRESHOLD, scrollLockTimeout = SCROLL_LOCK_TIMEOUT, dismissible = true, handleOnly = false, fadeFromIndex = snapPoints && snapPoints.length - 1, activeSnapPoint: activeSnapPointProp, setActiveSnapPoint: setActiveSnapPointProp, fixed, modal = true, onClose, nested, noBodyStyles = false, direction = 'bottom', defaultOpen = false, disablePreventScroll = true, snapToSequentialPoint = false, preventScrollRestoration = false, repositionInputs = true, onAnimationEnd, container, autoFocus = false }) {
886
+ var _drawerRef_current, _drawerRef_current1;
887
+ const [isOpen = false, setIsOpen] = useControllableState({
888
+ defaultProp: defaultOpen,
889
+ prop: openProp,
890
+ onChange: (o)=>{
891
+ onOpenChange == null ? void 0 : onOpenChange(o);
892
+ if (!o && !nested) {
893
+ restorePositionSetting();
894
+ }
895
+ setTimeout(()=>{
896
+ onAnimationEnd == null ? void 0 : onAnimationEnd(o);
897
+ }, TRANSITIONS.DURATION * 1000);
898
+ if (o && !modal) {
899
+ if (typeof window !== 'undefined') {
900
+ window.requestAnimationFrame(()=>{
901
+ document.body.style.pointerEvents = 'auto';
902
+ });
903
+ }
904
+ }
905
+ if (!o) {
906
+ // This will be removed when the exit animation ends (`500ms`)
907
+ document.body.style.pointerEvents = 'auto';
908
+ }
909
+ }
910
+ });
911
+ const [hasBeenOpened, setHasBeenOpened] = React__default['default'].useState(false);
912
+ const [isDragging, setIsDragging] = React__default['default'].useState(false);
913
+ const [justReleased, setJustReleased] = React__default['default'].useState(false);
914
+ const overlayRef = React__default['default'].useRef(null);
915
+ const openTime = React__default['default'].useRef(null);
916
+ const dragStartTime = React__default['default'].useRef(null);
917
+ const dragEndTime = React__default['default'].useRef(null);
918
+ const lastTimeDragPrevented = React__default['default'].useRef(null);
919
+ const isAllowedToDrag = React__default['default'].useRef(false);
920
+ const nestedOpenChangeTimer = React__default['default'].useRef(null);
921
+ const pointerStart = React__default['default'].useRef(0);
922
+ const keyboardIsOpen = React__default['default'].useRef(false);
923
+ const shouldAnimate = React__default['default'].useRef(!defaultOpen);
924
+ const previousDiffFromInitial = React__default['default'].useRef(0);
925
+ const drawerRef = React__default['default'].useRef(null);
926
+ const drawerHeightRef = React__default['default'].useRef(((_drawerRef_current = drawerRef.current) == null ? void 0 : _drawerRef_current.getBoundingClientRect().height) || 0);
927
+ const drawerWidthRef = React__default['default'].useRef(((_drawerRef_current1 = drawerRef.current) == null ? void 0 : _drawerRef_current1.getBoundingClientRect().width) || 0);
928
+ const initialDrawerHeight = React__default['default'].useRef(0);
929
+ const onSnapPointChange = React__default['default'].useCallback((activeSnapPointIndex)=>{
930
+ // Change openTime ref when we reach the last snap point to prevent dragging for 500ms incase it's scrollable.
931
+ if (snapPoints && activeSnapPointIndex === snapPointsOffset.length - 1) openTime.current = new Date();
932
+ }, []);
933
+ const { activeSnapPoint, activeSnapPointIndex, setActiveSnapPoint, onRelease: onReleaseSnapPoints, snapPointsOffset, onDrag: onDragSnapPoints, shouldFade, getPercentageDragged: getSnapPointsPercentageDragged } = useSnapPoints({
934
+ snapPoints,
935
+ activeSnapPointProp,
936
+ setActiveSnapPointProp,
937
+ drawerRef,
938
+ fadeFromIndex,
939
+ overlayRef,
940
+ onSnapPointChange,
941
+ direction,
942
+ container,
943
+ snapToSequentialPoint
944
+ });
945
+ usePreventScroll({
946
+ isDisabled: !isOpen || isDragging || !modal || justReleased || !hasBeenOpened || !repositionInputs || !disablePreventScroll
947
+ });
948
+ const { restorePositionSetting } = usePositionFixed({
949
+ isOpen,
950
+ modal,
951
+ nested: nested != null ? nested : false,
952
+ hasBeenOpened,
953
+ preventScrollRestoration,
954
+ noBodyStyles
955
+ });
956
+ function getScale() {
957
+ return (window.innerWidth - WINDOW_TOP_OFFSET) / window.innerWidth;
958
+ }
959
+ function onPress(event) {
960
+ var _drawerRef_current, _drawerRef_current1;
961
+ if (!dismissible && !snapPoints) return;
962
+ if (drawerRef.current && !drawerRef.current.contains(event.target)) return;
963
+ drawerHeightRef.current = ((_drawerRef_current = drawerRef.current) == null ? void 0 : _drawerRef_current.getBoundingClientRect().height) || 0;
964
+ drawerWidthRef.current = ((_drawerRef_current1 = drawerRef.current) == null ? void 0 : _drawerRef_current1.getBoundingClientRect().width) || 0;
965
+ setIsDragging(true);
966
+ dragStartTime.current = new Date();
967
+ // iOS doesn't trigger mouseUp after scrolling so we need to listen to touched in order to disallow dragging
968
+ if (isIOS()) {
969
+ window.addEventListener('touchend', ()=>isAllowedToDrag.current = false, {
970
+ once: true
971
+ });
972
+ }
973
+ // Ensure we maintain correct pointer capture even when going outside of the drawer
974
+ event.target.setPointerCapture(event.pointerId);
975
+ pointerStart.current = isVertical(direction) ? event.pageY : event.pageX;
976
+ }
977
+ function shouldDrag(el, isDraggingInDirection) {
978
+ var _window_getSelection;
979
+ let element = el;
980
+ const highlightedText = (_window_getSelection = window.getSelection()) == null ? void 0 : _window_getSelection.toString();
981
+ const swipeAmount = drawerRef.current ? getTranslate(drawerRef.current, direction) : null;
982
+ const date = new Date();
983
+ // Fixes https://github.com/emilkowalski/vaul/issues/483
984
+ if (element.tagName === 'SELECT') {
985
+ return false;
986
+ }
987
+ if (element.hasAttribute('data-vaul-no-drag') || element.closest('[data-vaul-no-drag]')) {
988
+ return false;
989
+ }
990
+ if (direction === 'right' || direction === 'left') {
991
+ return true;
992
+ }
993
+ // Allow scrolling when animating
994
+ if (openTime.current && date.getTime() - openTime.current.getTime() < 500) {
995
+ return false;
996
+ }
997
+ if (swipeAmount !== null) {
998
+ if (direction === 'bottom' ? swipeAmount > 0 : swipeAmount < 0) {
999
+ return true;
1000
+ }
1001
+ }
1002
+ // Don't drag if there's highlighted text
1003
+ if (highlightedText && highlightedText.length > 0) {
1004
+ return false;
1005
+ }
1006
+ // Disallow dragging if drawer was scrolled within `scrollLockTimeout`
1007
+ if (lastTimeDragPrevented.current && date.getTime() - lastTimeDragPrevented.current.getTime() < scrollLockTimeout && swipeAmount === 0) {
1008
+ lastTimeDragPrevented.current = date;
1009
+ return false;
1010
+ }
1011
+ if (isDraggingInDirection) {
1012
+ lastTimeDragPrevented.current = date;
1013
+ // We are dragging down so we should allow scrolling
1014
+ return false;
1015
+ }
1016
+ // Keep climbing up the DOM tree as long as there's a parent
1017
+ while(element){
1018
+ // Check if the element is scrollable
1019
+ if (element.scrollHeight > element.clientHeight) {
1020
+ if (element.scrollTop !== 0) {
1021
+ lastTimeDragPrevented.current = new Date();
1022
+ // The element is scrollable and not scrolled to the top, so don't drag
1023
+ return false;
1024
+ }
1025
+ if (element.getAttribute('role') === 'dialog') {
1026
+ return true;
1027
+ }
1028
+ }
1029
+ // Move up to the parent element
1030
+ element = element.parentNode;
1031
+ }
1032
+ // No scrollable parents not scrolled to the top found, so drag
1033
+ return true;
1034
+ }
1035
+ function onDrag(event) {
1036
+ if (!drawerRef.current) {
1037
+ return;
1038
+ }
1039
+ // We need to know how much of the drawer has been dragged in percentages so that we can transform background accordingly
1040
+ if (isDragging) {
1041
+ const directionMultiplier = direction === 'bottom' || direction === 'right' ? 1 : -1;
1042
+ const draggedDistance = (pointerStart.current - (isVertical(direction) ? event.pageY : event.pageX)) * directionMultiplier;
1043
+ const isDraggingInDirection = draggedDistance > 0;
1044
+ // Pre condition for disallowing dragging in the close direction.
1045
+ const noCloseSnapPointsPreCondition = snapPoints && !dismissible && !isDraggingInDirection;
1046
+ // Disallow dragging down to close when first snap point is the active one and dismissible prop is set to false.
1047
+ if (noCloseSnapPointsPreCondition && activeSnapPointIndex === 0) return;
1048
+ // We need to capture last time when drag with scroll was triggered and have a timeout between
1049
+ const absDraggedDistance = Math.abs(draggedDistance);
1050
+ const wrapper = document.querySelector('[data-vaul-drawer-wrapper]');
1051
+ const drawerDimension = direction === 'bottom' || direction === 'top' ? drawerHeightRef.current : drawerWidthRef.current;
1052
+ // Calculate the percentage dragged, where 1 is the closed position
1053
+ let percentageDragged = absDraggedDistance / drawerDimension;
1054
+ const snapPointPercentageDragged = getSnapPointsPercentageDragged(absDraggedDistance, isDraggingInDirection);
1055
+ if (snapPointPercentageDragged !== null) {
1056
+ percentageDragged = snapPointPercentageDragged;
1057
+ }
1058
+ // Disallow close dragging beyond the smallest snap point.
1059
+ if (noCloseSnapPointsPreCondition && percentageDragged >= 1) {
1060
+ return;
1061
+ }
1062
+ if (!isAllowedToDrag.current && !shouldDrag(event.target, isDraggingInDirection)) return;
1063
+ drawerRef.current.classList.add(DRAG_CLASS);
1064
+ // If shouldDrag gave true once after pressing down on the drawer, we set isAllowedToDrag to true and it will remain true until we let go, there's no reason to disable dragging mid way, ever, and that's the solution to it
1065
+ isAllowedToDrag.current = true;
1066
+ set(drawerRef.current, {
1067
+ transition: 'none'
1068
+ });
1069
+ set(overlayRef.current, {
1070
+ transition: 'none'
1071
+ });
1072
+ if (snapPoints) {
1073
+ onDragSnapPoints({
1074
+ draggedDistance
1075
+ });
1076
+ }
1077
+ // Run this only if snapPoints are not defined or if we are at the last snap point (highest one)
1078
+ if (isDraggingInDirection && !snapPoints) {
1079
+ const dampenedDraggedDistance = dampenValue(draggedDistance);
1080
+ const translateValue = Math.min(dampenedDraggedDistance * -1, 0) * directionMultiplier;
1081
+ set(drawerRef.current, {
1082
+ transform: isVertical(direction) ? `translate3d(0, ${translateValue}px, 0)` : `translate3d(${translateValue}px, 0, 0)`
1083
+ });
1084
+ return;
1085
+ }
1086
+ const opacityValue = 1 - percentageDragged;
1087
+ if (shouldFade || fadeFromIndex && activeSnapPointIndex === fadeFromIndex - 1) {
1088
+ onDragProp == null ? void 0 : onDragProp(event, percentageDragged);
1089
+ set(overlayRef.current, {
1090
+ opacity: `${opacityValue}`,
1091
+ transition: 'none'
1092
+ }, true);
1093
+ }
1094
+ if (wrapper && overlayRef.current && shouldScaleBackground) {
1095
+ // Calculate percentageDragged as a fraction (0 to 1)
1096
+ const scaleValue = Math.min(getScale() + percentageDragged * (1 - getScale()), 1);
1097
+ const borderRadiusValue = 8 - percentageDragged * 8;
1098
+ const translateValue = Math.max(0, 14 - percentageDragged * 14);
1099
+ set(wrapper, {
1100
+ borderRadius: `${borderRadiusValue}px`,
1101
+ transform: isVertical(direction) ? `scale(${scaleValue}) translate3d(0, ${translateValue}px, 0)` : `scale(${scaleValue}) translate3d(${translateValue}px, 0, 0)`,
1102
+ transition: 'none'
1103
+ }, true);
1104
+ }
1105
+ if (!snapPoints) {
1106
+ const translateValue = absDraggedDistance * directionMultiplier;
1107
+ set(drawerRef.current, {
1108
+ transform: isVertical(direction) ? `translate3d(0, ${translateValue}px, 0)` : `translate3d(${translateValue}px, 0, 0)`
1109
+ });
1110
+ }
1111
+ }
1112
+ }
1113
+ React__default['default'].useEffect(()=>{
1114
+ window.requestAnimationFrame(()=>{
1115
+ shouldAnimate.current = true;
1116
+ });
1117
+ }, []);
1118
+ React__default['default'].useEffect(()=>{
1119
+ var _window_visualViewport;
1120
+ function onVisualViewportChange() {
1121
+ if (!drawerRef.current || !repositionInputs) return;
1122
+ const focusedElement = document.activeElement;
1123
+ if (isInput(focusedElement) || keyboardIsOpen.current) {
1124
+ var _window_visualViewport;
1125
+ const visualViewportHeight = ((_window_visualViewport = window.visualViewport) == null ? void 0 : _window_visualViewport.height) || 0;
1126
+ const totalHeight = window.innerHeight;
1127
+ // This is the height of the keyboard
1128
+ let diffFromInitial = totalHeight - visualViewportHeight;
1129
+ const drawerHeight = drawerRef.current.getBoundingClientRect().height || 0;
1130
+ // Adjust drawer height only if it's tall enough
1131
+ const isTallEnough = drawerHeight > totalHeight * 0.8;
1132
+ if (!initialDrawerHeight.current) {
1133
+ initialDrawerHeight.current = drawerHeight;
1134
+ }
1135
+ const offsetFromTop = drawerRef.current.getBoundingClientRect().top;
1136
+ // visualViewport height may change due to somq e subtle changes to the keyboard. Checking if the height changed by 60 or more will make sure that they keyboard really changed its open state.
1137
+ if (Math.abs(previousDiffFromInitial.current - diffFromInitial) > 60) {
1138
+ keyboardIsOpen.current = !keyboardIsOpen.current;
1139
+ }
1140
+ if (snapPoints && snapPoints.length > 0 && snapPointsOffset && activeSnapPointIndex) {
1141
+ const activeSnapPointHeight = snapPointsOffset[activeSnapPointIndex] || 0;
1142
+ diffFromInitial += activeSnapPointHeight;
1143
+ }
1144
+ previousDiffFromInitial.current = diffFromInitial;
1145
+ // We don't have to change the height if the input is in view, when we are here we are in the opened keyboard state so we can correctly check if the input is in view
1146
+ if (drawerHeight > visualViewportHeight || keyboardIsOpen.current) {
1147
+ const height = drawerRef.current.getBoundingClientRect().height;
1148
+ let newDrawerHeight = height;
1149
+ if (height > visualViewportHeight) {
1150
+ newDrawerHeight = visualViewportHeight - (isTallEnough ? offsetFromTop : WINDOW_TOP_OFFSET);
1151
+ }
1152
+ // When fixed, don't move the drawer upwards if there's space, but rather only change it's height so it's fully scrollable when the keyboard is open
1153
+ if (fixed) {
1154
+ drawerRef.current.style.height = `${height - Math.max(diffFromInitial, 0)}px`;
1155
+ } else {
1156
+ drawerRef.current.style.height = `${Math.max(newDrawerHeight, visualViewportHeight - offsetFromTop)}px`;
1157
+ }
1158
+ } else if (!isMobileFirefox()) {
1159
+ drawerRef.current.style.height = `${initialDrawerHeight.current}px`;
1160
+ }
1161
+ if (snapPoints && snapPoints.length > 0 && !keyboardIsOpen.current) {
1162
+ drawerRef.current.style.bottom = `0px`;
1163
+ } else {
1164
+ // Negative bottom value would never make sense
1165
+ drawerRef.current.style.bottom = `${Math.max(diffFromInitial, 0)}px`;
1166
+ }
1167
+ }
1168
+ }
1169
+ (_window_visualViewport = window.visualViewport) == null ? void 0 : _window_visualViewport.addEventListener('resize', onVisualViewportChange);
1170
+ return ()=>{
1171
+ var _window_visualViewport;
1172
+ return (_window_visualViewport = window.visualViewport) == null ? void 0 : _window_visualViewport.removeEventListener('resize', onVisualViewportChange);
1173
+ };
1174
+ }, [
1175
+ activeSnapPointIndex,
1176
+ snapPoints,
1177
+ snapPointsOffset
1178
+ ]);
1179
+ function closeDrawer(fromWithin) {
1180
+ cancelDrag();
1181
+ onClose == null ? void 0 : onClose();
1182
+ if (!fromWithin) {
1183
+ setIsOpen(false);
1184
+ }
1185
+ setTimeout(()=>{
1186
+ if (snapPoints) {
1187
+ setActiveSnapPoint(snapPoints[0]);
1188
+ }
1189
+ }, TRANSITIONS.DURATION * 1000); // seconds to ms
1190
+ }
1191
+ function resetDrawer() {
1192
+ if (!drawerRef.current) return;
1193
+ const wrapper = document.querySelector('[data-vaul-drawer-wrapper]');
1194
+ const currentSwipeAmount = getTranslate(drawerRef.current, direction);
1195
+ set(drawerRef.current, {
1196
+ transform: 'translate3d(0, 0, 0)',
1197
+ transition: `transform ${TRANSITIONS.DURATION}s cubic-bezier(${TRANSITIONS.EASE.join(',')})`
1198
+ });
1199
+ set(overlayRef.current, {
1200
+ transition: `opacity ${TRANSITIONS.DURATION}s cubic-bezier(${TRANSITIONS.EASE.join(',')})`,
1201
+ opacity: '1'
1202
+ });
1203
+ // Don't reset background if swiped upwards
1204
+ if (shouldScaleBackground && currentSwipeAmount && currentSwipeAmount > 0 && isOpen) {
1205
+ set(wrapper, {
1206
+ borderRadius: `${BORDER_RADIUS}px`,
1207
+ overflow: 'hidden',
1208
+ ...isVertical(direction) ? {
1209
+ transform: `scale(${getScale()}) translate3d(0, calc(env(safe-area-inset-top) + 14px), 0)`,
1210
+ transformOrigin: 'top'
1211
+ } : {
1212
+ transform: `scale(${getScale()}) translate3d(calc(env(safe-area-inset-top) + 14px), 0, 0)`,
1213
+ transformOrigin: 'left'
1214
+ },
1215
+ transitionProperty: 'transform, border-radius',
1216
+ transitionDuration: `${TRANSITIONS.DURATION}s`,
1217
+ transitionTimingFunction: `cubic-bezier(${TRANSITIONS.EASE.join(',')})`
1218
+ }, true);
1219
+ }
1220
+ }
1221
+ function cancelDrag() {
1222
+ if (!isDragging || !drawerRef.current) return;
1223
+ drawerRef.current.classList.remove(DRAG_CLASS);
1224
+ isAllowedToDrag.current = false;
1225
+ setIsDragging(false);
1226
+ dragEndTime.current = new Date();
1227
+ }
1228
+ function onRelease(event) {
1229
+ if (!isDragging || !drawerRef.current) return;
1230
+ drawerRef.current.classList.remove(DRAG_CLASS);
1231
+ isAllowedToDrag.current = false;
1232
+ setIsDragging(false);
1233
+ dragEndTime.current = new Date();
1234
+ const swipeAmount = getTranslate(drawerRef.current, direction);
1235
+ if (!event || !shouldDrag(event.target, false) || !swipeAmount || Number.isNaN(swipeAmount)) return;
1236
+ if (dragStartTime.current === null) return;
1237
+ const timeTaken = dragEndTime.current.getTime() - dragStartTime.current.getTime();
1238
+ const distMoved = pointerStart.current - (isVertical(direction) ? event.pageY : event.pageX);
1239
+ const velocity = Math.abs(distMoved) / timeTaken;
1240
+ if (velocity > 0.05) {
1241
+ // `justReleased` is needed to prevent the drawer from focusing on an input when the drag ends, as it's not the intent most of the time.
1242
+ setJustReleased(true);
1243
+ setTimeout(()=>{
1244
+ setJustReleased(false);
1245
+ }, 200);
1246
+ }
1247
+ if (snapPoints) {
1248
+ const directionMultiplier = direction === 'bottom' || direction === 'right' ? 1 : -1;
1249
+ onReleaseSnapPoints({
1250
+ draggedDistance: distMoved * directionMultiplier,
1251
+ closeDrawer,
1252
+ velocity,
1253
+ dismissible
1254
+ });
1255
+ onReleaseProp == null ? void 0 : onReleaseProp(event, true);
1256
+ return;
1257
+ }
1258
+ // Moved upwards, don't do anything
1259
+ if (direction === 'bottom' || direction === 'right' ? distMoved > 0 : distMoved < 0) {
1260
+ resetDrawer();
1261
+ onReleaseProp == null ? void 0 : onReleaseProp(event, true);
1262
+ return;
1263
+ }
1264
+ if (velocity > VELOCITY_THRESHOLD) {
1265
+ closeDrawer();
1266
+ onReleaseProp == null ? void 0 : onReleaseProp(event, false);
1267
+ return;
1268
+ }
1269
+ var _drawerRef_current_getBoundingClientRect_height;
1270
+ const visibleDrawerHeight = Math.min((_drawerRef_current_getBoundingClientRect_height = drawerRef.current.getBoundingClientRect().height) != null ? _drawerRef_current_getBoundingClientRect_height : 0, window.innerHeight);
1271
+ var _drawerRef_current_getBoundingClientRect_width;
1272
+ const visibleDrawerWidth = Math.min((_drawerRef_current_getBoundingClientRect_width = drawerRef.current.getBoundingClientRect().width) != null ? _drawerRef_current_getBoundingClientRect_width : 0, window.innerWidth);
1273
+ const isHorizontalSwipe = direction === 'left' || direction === 'right';
1274
+ if (Math.abs(swipeAmount) >= (isHorizontalSwipe ? visibleDrawerWidth : visibleDrawerHeight) * closeThreshold) {
1275
+ closeDrawer();
1276
+ onReleaseProp == null ? void 0 : onReleaseProp(event, false);
1277
+ return;
1278
+ }
1279
+ onReleaseProp == null ? void 0 : onReleaseProp(event, true);
1280
+ resetDrawer();
1281
+ }
1282
+ React__default['default'].useEffect(()=>{
1283
+ // Trigger enter animation without using CSS animation
1284
+ if (isOpen) {
1285
+ set(document.documentElement, {
1286
+ scrollBehavior: 'auto'
1287
+ });
1288
+ openTime.current = new Date();
1289
+ }
1290
+ return ()=>{
1291
+ reset(document.documentElement, 'scrollBehavior');
1292
+ };
1293
+ }, [
1294
+ isOpen
1295
+ ]);
1296
+ function onNestedOpenChange(o) {
1297
+ const scale = o ? (window.innerWidth - NESTED_DISPLACEMENT) / window.innerWidth : 1;
1298
+ const initialTranslate = o ? -NESTED_DISPLACEMENT : 0;
1299
+ if (nestedOpenChangeTimer.current) {
1300
+ window.clearTimeout(nestedOpenChangeTimer.current);
1301
+ }
1302
+ set(drawerRef.current, {
1303
+ transition: `transform ${TRANSITIONS.DURATION}s cubic-bezier(${TRANSITIONS.EASE.join(',')})`,
1304
+ transform: isVertical(direction) ? `scale(${scale}) translate3d(0, ${initialTranslate}px, 0)` : `scale(${scale}) translate3d(${initialTranslate}, 0, 0)`
1305
+ });
1306
+ if (!o && drawerRef.current) {
1307
+ nestedOpenChangeTimer.current = setTimeout(()=>{
1308
+ const translateValue = getTranslate(drawerRef.current, direction);
1309
+ set(drawerRef.current, {
1310
+ transition: 'none',
1311
+ transform: isVertical(direction) ? `translate3d(0, ${translateValue}px, 0)` : `translate3d(${translateValue}px, 0, 0)`
1312
+ });
1313
+ }, 500);
1314
+ }
1315
+ }
1316
+ function onNestedDrag(_event, percentageDragged) {
1317
+ if (percentageDragged < 0) return;
1318
+ const initialScale = (window.innerWidth - NESTED_DISPLACEMENT) / window.innerWidth;
1319
+ const newScale = initialScale + percentageDragged * (1 - initialScale);
1320
+ const newTranslate = -NESTED_DISPLACEMENT + percentageDragged * NESTED_DISPLACEMENT;
1321
+ set(drawerRef.current, {
1322
+ transform: isVertical(direction) ? `scale(${newScale}) translate3d(0, ${newTranslate}px, 0)` : `scale(${newScale}) translate3d(${newTranslate}px, 0, 0)`,
1323
+ transition: 'none'
1324
+ });
1325
+ }
1326
+ function onNestedRelease(_event, o) {
1327
+ const dim = isVertical(direction) ? window.innerHeight : window.innerWidth;
1328
+ const scale = o ? (dim - NESTED_DISPLACEMENT) / dim : 1;
1329
+ const translate = o ? -NESTED_DISPLACEMENT : 0;
1330
+ if (o) {
1331
+ set(drawerRef.current, {
1332
+ transition: `transform ${TRANSITIONS.DURATION}s cubic-bezier(${TRANSITIONS.EASE.join(',')})`,
1333
+ transform: isVertical(direction) ? `scale(${scale}) translate3d(0, ${translate}px, 0)` : `scale(${scale}) translate3d(${translate}px, 0, 0)`
1334
+ });
1335
+ }
1336
+ }
1337
+ React__default['default'].useEffect(()=>{
1338
+ if (!modal) {
1339
+ // Need to do this manually unfortunately
1340
+ window.requestAnimationFrame(()=>{
1341
+ document.body.style.pointerEvents = 'auto';
1342
+ });
1343
+ }
1344
+ }, [
1345
+ modal
1346
+ ]);
1347
+ return /*#__PURE__*/ React__default['default'].createElement(index.Root, {
1348
+ defaultOpen: defaultOpen,
1349
+ onOpenChange: (open)=>{
1350
+ if (!dismissible && !open) return;
1351
+ if (open) {
1352
+ setHasBeenOpened(true);
1353
+ } else {
1354
+ closeDrawer(true);
1355
+ }
1356
+ setIsOpen(open);
1357
+ },
1358
+ open: isOpen
1359
+ }, /*#__PURE__*/ React__default['default'].createElement(DrawerContext.Provider, {
1360
+ value: {
1361
+ activeSnapPoint,
1362
+ snapPoints,
1363
+ setActiveSnapPoint,
1364
+ drawerRef,
1365
+ overlayRef,
1366
+ onOpenChange,
1367
+ onPress,
1368
+ onRelease,
1369
+ onDrag,
1370
+ dismissible,
1371
+ shouldAnimate,
1372
+ handleOnly,
1373
+ isOpen,
1374
+ isDragging,
1375
+ shouldFade,
1376
+ closeDrawer,
1377
+ onNestedDrag,
1378
+ onNestedOpenChange,
1379
+ onNestedRelease,
1380
+ keyboardIsOpen,
1381
+ modal,
1382
+ snapPointsOffset,
1383
+ activeSnapPointIndex,
1384
+ direction,
1385
+ shouldScaleBackground,
1386
+ setBackgroundColorOnScale,
1387
+ noBodyStyles,
1388
+ container,
1389
+ autoFocus
1390
+ }
1391
+ }, children));
1392
+ }
1393
+ const Overlay = /*#__PURE__*/ React__default['default'].forwardRef(function({ ...rest }, ref) {
1394
+ const { overlayRef, snapPoints, onRelease, shouldFade, isOpen, modal, shouldAnimate } = useDrawerContext();
1395
+ const composedRef = useComposedRefs(ref, overlayRef);
1396
+ const hasSnapPoints = snapPoints && snapPoints.length > 0;
1397
+ // Overlay is the component that is locking scroll, removing it will unlock the scroll without having to dig into Radix's Dialog library
1398
+ if (!modal) {
1399
+ return null;
1400
+ }
1401
+ const onMouseUp = React__default['default'].useCallback((event)=>onRelease(event), [
1402
+ onRelease
1403
+ ]);
1404
+ return /*#__PURE__*/ React__default['default'].createElement(index.Overlay, {
1405
+ onMouseUp: onMouseUp,
1406
+ ref: composedRef,
1407
+ "data-vaul-overlay": "",
1408
+ "data-vaul-snap-points": isOpen && hasSnapPoints ? 'true' : 'false',
1409
+ "data-vaul-snap-points-overlay": isOpen && shouldFade ? 'true' : 'false',
1410
+ "data-vaul-animate": (shouldAnimate == null ? void 0 : shouldAnimate.current) ? 'true' : 'false',
1411
+ ...rest
1412
+ });
1413
+ });
1414
+ Overlay.displayName = 'Drawer.Overlay';
1415
+ const Content = /*#__PURE__*/ React__default['default'].forwardRef(function({ onPointerDownOutside, style, onOpenAutoFocus, ...rest }, ref) {
1416
+ const { drawerRef, onPress, onRelease, onDrag, keyboardIsOpen, snapPointsOffset, activeSnapPointIndex, modal, isOpen, direction, snapPoints, container, handleOnly, shouldAnimate, autoFocus } = useDrawerContext();
1417
+ // Needed to use transition instead of animations
1418
+ const [delayedSnapPoints, setDelayedSnapPoints] = React__default['default'].useState(false);
1419
+ const composedRef = useComposedRefs(ref, drawerRef);
1420
+ const pointerStartRef = React__default['default'].useRef(null);
1421
+ const lastKnownPointerEventRef = React__default['default'].useRef(null);
1422
+ const wasBeyondThePointRef = React__default['default'].useRef(false);
1423
+ const hasSnapPoints = snapPoints && snapPoints.length > 0;
1424
+ useScaleBackground();
1425
+ const isDeltaInDirection = (delta, direction, threshold = 0)=>{
1426
+ if (wasBeyondThePointRef.current) return true;
1427
+ const deltaY = Math.abs(delta.y);
1428
+ const deltaX = Math.abs(delta.x);
1429
+ const isDeltaX = deltaX > deltaY;
1430
+ const dFactor = [
1431
+ 'bottom',
1432
+ 'right'
1433
+ ].includes(direction) ? 1 : -1;
1434
+ if (direction === 'left' || direction === 'right') {
1435
+ const isReverseDirection = delta.x * dFactor < 0;
1436
+ if (!isReverseDirection && deltaX >= 0 && deltaX <= threshold) {
1437
+ return isDeltaX;
1438
+ }
1439
+ } else {
1440
+ const isReverseDirection = delta.y * dFactor < 0;
1441
+ if (!isReverseDirection && deltaY >= 0 && deltaY <= threshold) {
1442
+ return !isDeltaX;
1443
+ }
1444
+ }
1445
+ wasBeyondThePointRef.current = true;
1446
+ return true;
1447
+ };
1448
+ React__default['default'].useEffect(()=>{
1449
+ if (hasSnapPoints) {
1450
+ window.requestAnimationFrame(()=>{
1451
+ setDelayedSnapPoints(true);
1452
+ });
1453
+ }
1454
+ }, []);
1455
+ function handleOnPointerUp(event) {
1456
+ pointerStartRef.current = null;
1457
+ wasBeyondThePointRef.current = false;
1458
+ onRelease(event);
1459
+ }
1460
+ return /*#__PURE__*/ React__default['default'].createElement(index.Content, {
1461
+ "data-vaul-drawer-direction": direction,
1462
+ "data-vaul-drawer": "",
1463
+ "data-vaul-delayed-snap-points": delayedSnapPoints ? 'true' : 'false',
1464
+ "data-vaul-snap-points": isOpen && hasSnapPoints ? 'true' : 'false',
1465
+ "data-vaul-custom-container": container ? 'true' : 'false',
1466
+ "data-vaul-animate": (shouldAnimate == null ? void 0 : shouldAnimate.current) ? 'true' : 'false',
1467
+ ...rest,
1468
+ ref: composedRef,
1469
+ style: snapPointsOffset && snapPointsOffset.length > 0 ? {
1470
+ '--snap-point-height': `${snapPointsOffset[activeSnapPointIndex != null ? activeSnapPointIndex : 0]}px`,
1471
+ ...style
1472
+ } : style,
1473
+ onPointerDown: (event)=>{
1474
+ if (handleOnly) return;
1475
+ rest.onPointerDown == null ? void 0 : rest.onPointerDown.call(rest, event);
1476
+ pointerStartRef.current = {
1477
+ x: event.pageX,
1478
+ y: event.pageY
1479
+ };
1480
+ onPress(event);
1481
+ },
1482
+ onOpenAutoFocus: (e)=>{
1483
+ onOpenAutoFocus == null ? void 0 : onOpenAutoFocus(e);
1484
+ if (!autoFocus) {
1485
+ e.preventDefault();
1486
+ }
1487
+ },
1488
+ onPointerDownOutside: (e)=>{
1489
+ onPointerDownOutside == null ? void 0 : onPointerDownOutside(e);
1490
+ if (!modal || e.defaultPrevented) {
1491
+ e.preventDefault();
1492
+ return;
1493
+ }
1494
+ if (keyboardIsOpen.current) {
1495
+ keyboardIsOpen.current = false;
1496
+ }
1497
+ },
1498
+ onFocusOutside: (e)=>{
1499
+ if (!modal) {
1500
+ e.preventDefault();
1501
+ return;
1502
+ }
1503
+ },
1504
+ onPointerMove: (event)=>{
1505
+ lastKnownPointerEventRef.current = event;
1506
+ if (handleOnly) return;
1507
+ rest.onPointerMove == null ? void 0 : rest.onPointerMove.call(rest, event);
1508
+ if (!pointerStartRef.current) return;
1509
+ const yPosition = event.pageY - pointerStartRef.current.y;
1510
+ const xPosition = event.pageX - pointerStartRef.current.x;
1511
+ const swipeStartThreshold = event.pointerType === 'touch' ? 10 : 2;
1512
+ const delta = {
1513
+ x: xPosition,
1514
+ y: yPosition
1515
+ };
1516
+ const isAllowedToSwipe = isDeltaInDirection(delta, direction, swipeStartThreshold);
1517
+ if (isAllowedToSwipe) onDrag(event);
1518
+ else if (Math.abs(xPosition) > swipeStartThreshold || Math.abs(yPosition) > swipeStartThreshold) {
1519
+ pointerStartRef.current = null;
1520
+ }
1521
+ },
1522
+ onPointerUp: (event)=>{
1523
+ rest.onPointerUp == null ? void 0 : rest.onPointerUp.call(rest, event);
1524
+ pointerStartRef.current = null;
1525
+ wasBeyondThePointRef.current = false;
1526
+ onRelease(event);
1527
+ },
1528
+ onPointerOut: (event)=>{
1529
+ rest.onPointerOut == null ? void 0 : rest.onPointerOut.call(rest, event);
1530
+ handleOnPointerUp(lastKnownPointerEventRef.current);
1531
+ },
1532
+ onContextMenu: (event)=>{
1533
+ rest.onContextMenu == null ? void 0 : rest.onContextMenu.call(rest, event);
1534
+ if (lastKnownPointerEventRef.current) {
1535
+ handleOnPointerUp(lastKnownPointerEventRef.current);
1536
+ }
1537
+ }
1538
+ });
1539
+ });
1540
+ Content.displayName = 'Drawer.Content';
1541
+ const LONG_HANDLE_PRESS_TIMEOUT = 250;
1542
+ const DOUBLE_TAP_TIMEOUT = 120;
1543
+ const Handle = /*#__PURE__*/ React__default['default'].forwardRef(function({ preventCycle = false, children, ...rest }, ref) {
1544
+ const { closeDrawer, isDragging, snapPoints, activeSnapPoint, setActiveSnapPoint, dismissible, handleOnly, isOpen, onPress, onDrag } = useDrawerContext();
1545
+ const closeTimeoutIdRef = React__default['default'].useRef(null);
1546
+ const shouldCancelInteractionRef = React__default['default'].useRef(false);
1547
+ function handleStartCycle() {
1548
+ // Stop if this is the second click of a double click
1549
+ if (shouldCancelInteractionRef.current) {
1550
+ handleCancelInteraction();
1551
+ return;
1552
+ }
1553
+ window.setTimeout(()=>{
1554
+ handleCycleSnapPoints();
1555
+ }, DOUBLE_TAP_TIMEOUT);
1556
+ }
1557
+ function handleCycleSnapPoints() {
1558
+ // Prevent accidental taps while resizing drawer
1559
+ if (isDragging || preventCycle || shouldCancelInteractionRef.current) {
1560
+ handleCancelInteraction();
1561
+ return;
1562
+ }
1563
+ // Make sure to clear the timeout id if the user releases the handle before the cancel timeout
1564
+ handleCancelInteraction();
1565
+ if (!snapPoints || snapPoints.length === 0) {
1566
+ if (!dismissible) {
1567
+ closeDrawer();
1568
+ }
1569
+ return;
1570
+ }
1571
+ const isLastSnapPoint = activeSnapPoint === snapPoints[snapPoints.length - 1];
1572
+ if (isLastSnapPoint && dismissible) {
1573
+ closeDrawer();
1574
+ return;
1575
+ }
1576
+ const currentSnapIndex = snapPoints.findIndex((point)=>point === activeSnapPoint);
1577
+ if (currentSnapIndex === -1) return; // activeSnapPoint not found in snapPoints
1578
+ const nextSnapPoint = snapPoints[currentSnapIndex + 1];
1579
+ setActiveSnapPoint(nextSnapPoint);
1580
+ }
1581
+ function handleStartInteraction() {
1582
+ closeTimeoutIdRef.current = window.setTimeout(()=>{
1583
+ // Cancel click interaction on a long press
1584
+ shouldCancelInteractionRef.current = true;
1585
+ }, LONG_HANDLE_PRESS_TIMEOUT);
1586
+ }
1587
+ function handleCancelInteraction() {
1588
+ if (closeTimeoutIdRef.current) {
1589
+ window.clearTimeout(closeTimeoutIdRef.current);
1590
+ }
1591
+ shouldCancelInteractionRef.current = false;
1592
+ }
1593
+ return /*#__PURE__*/ React__default['default'].createElement("div", {
1594
+ onClick: handleStartCycle,
1595
+ onPointerCancel: handleCancelInteraction,
1596
+ onPointerDown: (e)=>{
1597
+ if (handleOnly) onPress(e);
1598
+ handleStartInteraction();
1599
+ },
1600
+ onPointerMove: (e)=>{
1601
+ if (handleOnly) onDrag(e);
1602
+ },
1603
+ // onPointerUp is already handled by the content component
1604
+ ref: ref,
1605
+ "data-vaul-drawer-visible": isOpen ? 'true' : 'false',
1606
+ "data-vaul-handle": "",
1607
+ "aria-hidden": "true",
1608
+ ...rest
1609
+ }, /*#__PURE__*/ React__default['default'].createElement("span", {
1610
+ "data-vaul-handle-hitarea": "",
1611
+ "aria-hidden": "true"
1612
+ }, children));
1613
+ });
1614
+ Handle.displayName = 'Drawer.Handle';
1615
+ function NestedRoot({ onDrag, onOpenChange, ...rest }) {
1616
+ const { onNestedDrag, onNestedOpenChange, onNestedRelease } = useDrawerContext();
1617
+ if (!onNestedDrag) {
1618
+ throw new Error('Drawer.NestedRoot must be placed in another drawer');
1619
+ }
1620
+ return /*#__PURE__*/ React__default['default'].createElement(Root, {
1621
+ nested: true,
1622
+ onClose: ()=>{
1623
+ onNestedOpenChange(false);
1624
+ },
1625
+ onDrag: (e, p)=>{
1626
+ onNestedDrag(e, p);
1627
+ onDrag == null ? void 0 : onDrag(e, p);
1628
+ },
1629
+ onOpenChange: (o)=>{
1630
+ if (o) {
1631
+ onNestedOpenChange(o);
1632
+ }
1633
+ },
1634
+ onRelease: onNestedRelease,
1635
+ ...rest
1636
+ });
1637
+ }
1638
+ function Portal(props) {
1639
+ const context = useDrawerContext();
1640
+ const { container = context.container, ...portalProps } = props;
1641
+ return /*#__PURE__*/ React__default['default'].createElement(index.Portal, {
1642
+ container: container,
1643
+ ...portalProps
1644
+ });
1645
+ }
1646
+ const Drawer = {
1647
+ Root,
1648
+ NestedRoot,
1649
+ Content,
1650
+ Overlay,
1651
+ Trigger: index.Trigger,
1652
+ Portal,
1653
+ Handle,
1654
+ Close: index.Close,
1655
+ Title: index.Title,
1656
+ Description: index.Description
1657
+ };
1658
+
1659
+ exports.Content = Content;
1660
+ exports.Drawer = Drawer;
1661
+ exports.Handle = Handle;
1662
+ exports.NestedRoot = NestedRoot;
1663
+ exports.Overlay = Overlay;
1664
+ exports.Portal = Portal;
1665
+ exports.Root = Root;
1666
+ //# sourceMappingURL=index.mjs.js.map