ingeniuscliq-core 0.4.19 → 0.4.21

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 (279) hide show
  1. package/dist/components/common/carousel/CustomCarousel.d.ts +1 -1
  2. package/dist/components/common/carousel/CustomCarousel.d.ts.map +1 -1
  3. package/dist/components/common/carousel/CustomCarouselSection.d.ts +1 -1
  4. package/dist/components/common/carousel/CustomCarouselSection.d.ts.map +1 -1
  5. package/dist/components/common/form/FormCheckbox.d.ts +1 -1
  6. package/dist/components/common/form/FormCheckbox.d.ts.map +1 -1
  7. package/dist/components/common/form/FormInput.d.ts +1 -1
  8. package/dist/components/common/form/FormInput.d.ts.map +1 -1
  9. package/dist/components/common/form/FormSelect.d.ts +1 -1
  10. package/dist/components/common/form/FormSelect.d.ts.map +1 -1
  11. package/dist/components/common/form/FormTextArea.d.ts +1 -1
  12. package/dist/components/common/form/FormTextArea.d.ts.map +1 -1
  13. package/dist/components/common/form/FormWrapper.d.ts +1 -1
  14. package/dist/components/common/form/FormWrapper.d.ts.map +1 -1
  15. package/dist/components/common/logo/Logo.d.ts +1 -1
  16. package/dist/components/common/logo/Logo.d.ts.map +1 -1
  17. package/dist/components/common/pagination/CustomPagination.d.ts +1 -1
  18. package/dist/components/common/pagination/CustomPagination.d.ts.map +1 -1
  19. package/dist/components/common/select/CustomSelect.d.ts +1 -1
  20. package/dist/components/common/select/CustomSelect.d.ts.map +1 -1
  21. package/dist/components/common/spinner/Spinner.d.ts +1 -1
  22. package/dist/components/common/spinner/Spinner.d.ts.map +1 -1
  23. package/dist/components/common/stepper/Stepper.d.ts +1 -1
  24. package/dist/components/common/stepper/Stepper.d.ts.map +1 -1
  25. package/dist/components/common/stepper/Stepper.tsx +1 -1
  26. package/dist/components/layouts/CoreBaseLayout.d.ts +1 -1
  27. package/dist/components/layouts/CoreBaseLayout.d.ts.map +1 -1
  28. package/dist/components/templates/CoreHomeLayout.d.ts +1 -1
  29. package/dist/components/templates/CoreHomeLayout.d.ts.map +1 -1
  30. package/dist/components/templates/CorePreviewLayout.d.ts +1 -1
  31. package/dist/components/templates/CorePreviewLayout.d.ts.map +1 -1
  32. package/dist/components/ui/accordion.tsx +9 -9
  33. package/dist/components/ui/alert-dialog.d.ts +2 -2
  34. package/dist/components/ui/alert-dialog.tsx +16 -16
  35. package/dist/components/ui/alert.d.ts +3 -3
  36. package/dist/components/ui/alert.d.ts.map +1 -1
  37. package/dist/components/ui/alert.tsx +1 -1
  38. package/dist/components/ui/avatar.tsx +7 -7
  39. package/dist/components/ui/badge.d.ts +4 -4
  40. package/dist/components/ui/badge.d.ts.map +1 -1
  41. package/dist/components/ui/badge.tsx +1 -1
  42. package/dist/components/ui/breadcrumb.d.ts +2 -2
  43. package/dist/components/ui/breadcrumb.tsx +3 -4
  44. package/dist/components/ui/button.d.ts +4 -4
  45. package/dist/components/ui/button.d.ts.map +1 -1
  46. package/dist/components/ui/button.tsx +2 -2
  47. package/dist/components/ui/carousel.tsx +2 -3
  48. package/dist/components/ui/checkbox.tsx +5 -5
  49. package/dist/components/ui/dialog.d.ts +2 -2
  50. package/dist/components/ui/dialog.tsx +15 -15
  51. package/dist/components/ui/dropdown-menu.d.ts +1 -1
  52. package/dist/components/ui/dropdown-menu.tsx +27 -29
  53. package/dist/components/ui/form.d.ts +1 -1
  54. package/dist/components/ui/form.d.ts.map +1 -1
  55. package/dist/components/ui/form.tsx +2 -2
  56. package/dist/components/ui/label.d.ts +1 -1
  57. package/dist/components/ui/label.d.ts.map +1 -1
  58. package/dist/components/ui/label.tsx +4 -4
  59. package/dist/components/ui/pagination.d.ts +5 -5
  60. package/dist/components/ui/pagination.tsx +2 -4
  61. package/dist/components/ui/popover.tsx +7 -7
  62. package/dist/components/ui/radio-group.tsx +7 -7
  63. package/dist/components/ui/select.tsx +25 -27
  64. package/dist/components/ui/separator.tsx +3 -3
  65. package/dist/components/ui/sheet.d.ts +5 -5
  66. package/dist/components/ui/sheet.d.ts.map +1 -1
  67. package/dist/components/ui/sheet.tsx +16 -16
  68. package/dist/components/ui/skeleton.d.ts +1 -1
  69. package/dist/components/ui/skeleton.d.ts.map +1 -1
  70. package/dist/components/ui/slider.tsx +6 -6
  71. package/dist/components/ui/stepper.tsx +4 -4
  72. package/dist/components/ui/switch.tsx +4 -4
  73. package/dist/components/ui/tabs.tsx +9 -9
  74. package/dist/components/ui/tooltip.tsx +6 -6
  75. package/dist/helpers/axiosGlobal.js +1 -2
  76. package/dist/hooks/useLanguage.js +2 -5
  77. package/dist/hooks/useNotification.js +1 -1
  78. package/dist/i18n/config.js +1 -5
  79. package/dist/lib/utils.js +1 -1
  80. package/dist/modules/CoreAuth/classes/CoreAuthBuilder.d.ts +2 -2
  81. package/dist/modules/CoreAuth/classes/CoreAuthBuilder.js +1 -1
  82. package/dist/modules/CoreAuth/context/AuthContext.d.ts +2 -2
  83. package/dist/modules/CoreAuth/context/AuthContext.d.ts.map +1 -1
  84. package/dist/modules/CoreAuth/hooks/useAuth.d.ts +3 -3
  85. package/dist/modules/CoreAuth/index.js +1 -0
  86. package/dist/modules/CoreAuth/stores/authStore.d.ts +2 -2
  87. package/dist/modules/CoreCustomization/classes/CoreCustomizationBuilder.d.ts +8 -8
  88. package/dist/modules/CoreCustomization/classes/CoreCustomizationBuilder.d.ts.map +1 -1
  89. package/dist/modules/CoreCustomization/classes/CoreCustomizationBuilder.js +30 -16
  90. package/dist/modules/CoreCustomization/index.js +1 -0
  91. package/dist/modules/CoreOrder/classes/CoreOrderBuilder.d.ts.map +1 -1
  92. package/dist/modules/CoreOrder/classes/CoreOrderBuilder.js +15 -8
  93. package/dist/modules/CoreOrder/index.js +1 -0
  94. package/dist/modules/CorePayForm/classes/CorePayFormBuilder.d.ts +2 -2
  95. package/dist/modules/CorePayForm/classes/CorePayFormBuilder.d.ts.map +1 -1
  96. package/dist/modules/CorePayForm/classes/CorePayFormBuilder.js +15 -8
  97. package/dist/modules/CorePayForm/index.js +1 -0
  98. package/dist/modules/CoreProduct/classes/CoreProductBuilder.d.ts +8 -8
  99. package/dist/modules/CoreProduct/classes/CoreProductBuilder.d.ts.map +1 -1
  100. package/dist/modules/CoreProduct/classes/CoreProductBuilder.js +34 -13
  101. package/dist/modules/CoreProduct/index.js +1 -0
  102. package/dist/modules/CoreShipment/classes/CoreShipmentBuilder.d.ts +6 -6
  103. package/dist/modules/CoreShipment/classes/CoreShipmentBuilder.d.ts.map +1 -1
  104. package/dist/modules/CoreShipment/classes/CoreShipmentBuilder.js +34 -13
  105. package/dist/modules/CoreShipment/index.js +1 -0
  106. package/dist/modules/CoreShopCart/classes/CoreShopCartBuilder.d.ts +4 -4
  107. package/dist/modules/CoreShopCart/classes/CoreShopCartBuilder.d.ts.map +1 -1
  108. package/dist/modules/CoreShopCart/classes/CoreShopCartBuilder.js +12 -5
  109. package/package.json +21 -13
  110. package/src/commands/common/constants.js +10 -0
  111. package/src/commands/helpers/index.js +15 -0
  112. package/src/commands/helpers/strings.js +4 -0
  113. package/src/commands/templates/locale.js +14 -0
  114. package/src/commands/templates/service.js +12 -0
  115. package/src/commands/templates/type.js +10 -0
  116. package/README.md +0 -417
  117. package/dist/_virtual/index.js +0 -5
  118. package/dist/_virtual/index2.js +0 -3
  119. package/dist/_virtual/use-sync-external-store-shim.development.js +0 -3
  120. package/dist/_virtual/use-sync-external-store-shim.production.js +0 -3
  121. package/dist/node_modules/@floating-ui/core/dist/floating-ui.core.js +0 -814
  122. package/dist/node_modules/@floating-ui/dom/dist/floating-ui.dom.js +0 -751
  123. package/dist/node_modules/@floating-ui/react-dom/dist/floating-ui.react-dom.js +0 -350
  124. package/dist/node_modules/@floating-ui/utils/dist/floating-ui.utils.dom.js +0 -161
  125. package/dist/node_modules/@floating-ui/utils/dist/floating-ui.utils.js +0 -137
  126. package/dist/node_modules/@radix-ui/number/dist/index.js +0 -6
  127. package/dist/node_modules/@radix-ui/primitive/dist/index.js +0 -11
  128. package/dist/node_modules/@radix-ui/react-accordion/dist/index.js +0 -305
  129. package/dist/node_modules/@radix-ui/react-alert-dialog/dist/index.js +0 -147
  130. package/dist/node_modules/@radix-ui/react-arrow/dist/index.js +0 -25
  131. package/dist/node_modules/@radix-ui/react-avatar/dist/index.js +0 -118
  132. package/dist/node_modules/@radix-ui/react-checkbox/dist/index.js +0 -270
  133. package/dist/node_modules/@radix-ui/react-collapsible/dist/index.js +0 -145
  134. package/dist/node_modules/@radix-ui/react-collection/dist/index.js +0 -70
  135. package/dist/node_modules/@radix-ui/react-compose-refs/dist/index.js +0 -39
  136. package/dist/node_modules/@radix-ui/react-context/dist/index.js +0 -79
  137. package/dist/node_modules/@radix-ui/react-dialog/dist/index.js +0 -321
  138. package/dist/node_modules/@radix-ui/react-direction/dist/index.js +0 -11
  139. package/dist/node_modules/@radix-ui/react-dismissable-layer/dist/index.js +0 -211
  140. package/dist/node_modules/@radix-ui/react-dropdown-menu/dist/index.js +0 -267
  141. package/dist/node_modules/@radix-ui/react-focus-guards/dist/index.js +0 -29
  142. package/dist/node_modules/@radix-ui/react-focus-scope/dist/index.js +0 -207
  143. package/dist/node_modules/@radix-ui/react-id/dist/index.js +0 -15
  144. package/dist/node_modules/@radix-ui/react-label/dist/index.js +0 -24
  145. package/dist/node_modules/@radix-ui/react-menu/dist/index.js +0 -834
  146. package/dist/node_modules/@radix-ui/react-popover/dist/index.js +0 -299
  147. package/dist/node_modules/@radix-ui/react-popper/dist/index.js +0 -283
  148. package/dist/node_modules/@radix-ui/react-portal/dist/index.js +0 -17
  149. package/dist/node_modules/@radix-ui/react-presence/dist/index.js +0 -130
  150. package/dist/node_modules/@radix-ui/react-primitive/dist/index.js +0 -43
  151. package/dist/node_modules/@radix-ui/react-radio-group/dist/index.js +0 -282
  152. package/dist/node_modules/@radix-ui/react-roving-focus/dist/index.js +0 -223
  153. package/dist/node_modules/@radix-ui/react-select/dist/index.js +0 -1156
  154. package/dist/node_modules/@radix-ui/react-separator/dist/index.js +0 -30
  155. package/dist/node_modules/@radix-ui/react-slider/dist/index.js +0 -554
  156. package/dist/node_modules/@radix-ui/react-slot/dist/index.js +0 -99
  157. package/dist/node_modules/@radix-ui/react-switch/dist/index.js +0 -152
  158. package/dist/node_modules/@radix-ui/react-tabs/dist/index.js +0 -187
  159. package/dist/node_modules/@radix-ui/react-tooltip/dist/index.js +0 -482
  160. package/dist/node_modules/@radix-ui/react-use-callback-ref/dist/index.js +0 -12
  161. package/dist/node_modules/@radix-ui/react-use-controllable-state/dist/index.js +0 -70
  162. package/dist/node_modules/@radix-ui/react-use-escape-keydown/dist/index.js +0 -18
  163. package/dist/node_modules/@radix-ui/react-use-is-hydrated/dist/index.js +0 -16
  164. package/dist/node_modules/@radix-ui/react-use-layout-effect/dist/index.js +0 -7
  165. package/dist/node_modules/@radix-ui/react-use-previous/dist/index.js +0 -15
  166. package/dist/node_modules/@radix-ui/react-use-size/dist/index.js +0 -40
  167. package/dist/node_modules/@radix-ui/react-visually-hidden/dist/index.js +0 -35
  168. package/dist/node_modules/@stepperize/core/dist/index.js +0 -3
  169. package/dist/node_modules/@stepperize/react/dist/index.js +0 -6
  170. package/dist/node_modules/aria-hidden/dist/es2015/index.js +0 -137
  171. package/dist/node_modules/axios/index.js +0 -25
  172. package/dist/node_modules/axios/lib/adapters/adapters.js +0 -81
  173. package/dist/node_modules/axios/lib/adapters/fetch.js +0 -229
  174. package/dist/node_modules/axios/lib/adapters/xhr.js +0 -199
  175. package/dist/node_modules/axios/lib/axios.js +0 -86
  176. package/dist/node_modules/axios/lib/cancel/CancelToken.js +0 -133
  177. package/dist/node_modules/axios/lib/cancel/CanceledError.js +0 -23
  178. package/dist/node_modules/axios/lib/cancel/isCancel.js +0 -5
  179. package/dist/node_modules/axios/lib/core/Axios.js +0 -238
  180. package/dist/node_modules/axios/lib/core/AxiosError.js +0 -101
  181. package/dist/node_modules/axios/lib/core/AxiosHeaders.js +0 -312
  182. package/dist/node_modules/axios/lib/core/InterceptorManager.js +0 -69
  183. package/dist/node_modules/axios/lib/core/buildFullPath.js +0 -22
  184. package/dist/node_modules/axios/lib/core/dispatchRequest.js +0 -81
  185. package/dist/node_modules/axios/lib/core/mergeConfig.js +0 -106
  186. package/dist/node_modules/axios/lib/core/settle.js +0 -27
  187. package/dist/node_modules/axios/lib/core/transformData.js +0 -28
  188. package/dist/node_modules/axios/lib/defaults/index.js +0 -159
  189. package/dist/node_modules/axios/lib/defaults/transitional.js +0 -7
  190. package/dist/node_modules/axios/lib/env/data.js +0 -3
  191. package/dist/node_modules/axios/lib/helpers/AxiosURLSearchParams.js +0 -56
  192. package/dist/node_modules/axios/lib/helpers/HttpStatusCode.js +0 -71
  193. package/dist/node_modules/axios/lib/helpers/bind.js +0 -7
  194. package/dist/node_modules/axios/lib/helpers/buildURL.js +0 -69
  195. package/dist/node_modules/axios/lib/helpers/combineURLs.js +0 -15
  196. package/dist/node_modules/axios/lib/helpers/composeSignals.js +0 -48
  197. package/dist/node_modules/axios/lib/helpers/cookies.js +0 -43
  198. package/dist/node_modules/axios/lib/helpers/formDataToJSON.js +0 -93
  199. package/dist/node_modules/axios/lib/helpers/isAbsoluteURL.js +0 -15
  200. package/dist/node_modules/axios/lib/helpers/isAxiosError.js +0 -14
  201. package/dist/node_modules/axios/lib/helpers/isURLSameOrigin.js +0 -16
  202. package/dist/node_modules/axios/lib/helpers/null.js +0 -4
  203. package/dist/node_modules/axios/lib/helpers/parseHeaders.js +0 -55
  204. package/dist/node_modules/axios/lib/helpers/parseProtocol.js +0 -6
  205. package/dist/node_modules/axios/lib/helpers/progressEventReducer.js +0 -46
  206. package/dist/node_modules/axios/lib/helpers/resolveConfig.js +0 -58
  207. package/dist/node_modules/axios/lib/helpers/speedometer.js +0 -53
  208. package/dist/node_modules/axios/lib/helpers/spread.js +0 -28
  209. package/dist/node_modules/axios/lib/helpers/throttle.js +0 -44
  210. package/dist/node_modules/axios/lib/helpers/toFormData.js +0 -219
  211. package/dist/node_modules/axios/lib/helpers/toURLEncodedForm.js +0 -19
  212. package/dist/node_modules/axios/lib/helpers/trackStream.js +0 -88
  213. package/dist/node_modules/axios/lib/helpers/validator.js +0 -99
  214. package/dist/node_modules/axios/lib/platform/browser/classes/Blob.js +0 -3
  215. package/dist/node_modules/axios/lib/platform/browser/classes/FormData.js +0 -3
  216. package/dist/node_modules/axios/lib/platform/browser/classes/URLSearchParams.js +0 -5
  217. package/dist/node_modules/axios/lib/platform/browser/index.js +0 -15
  218. package/dist/node_modules/axios/lib/platform/common/utils.js +0 -45
  219. package/dist/node_modules/axios/lib/platform/index.js +0 -9
  220. package/dist/node_modules/axios/lib/utils.js +0 -780
  221. package/dist/node_modules/class-variance-authority/dist/index.js +0 -44
  222. package/dist/node_modules/clsx/dist/clsx.js +0 -3
  223. package/dist/node_modules/embla-carousel/esm/embla-carousel.esm.js +0 -1669
  224. package/dist/node_modules/embla-carousel-react/esm/embla-carousel-react.esm.js +0 -37
  225. package/dist/node_modules/embla-carousel-reactive-utils/esm/embla-carousel-reactive-utils.esm.js +0 -38
  226. package/dist/node_modules/get-nonce/dist/es2015/index.js +0 -8
  227. package/dist/node_modules/lucide-react/dist/esm/Icon.js +0 -43
  228. package/dist/node_modules/lucide-react/dist/esm/createLucideIcon.js +0 -30
  229. package/dist/node_modules/lucide-react/dist/esm/defaultAttributes.js +0 -20
  230. package/dist/node_modules/lucide-react/dist/esm/icons/arrow-left.js +0 -17
  231. package/dist/node_modules/lucide-react/dist/esm/icons/arrow-right.js +0 -17
  232. package/dist/node_modules/lucide-react/dist/esm/icons/check.js +0 -14
  233. package/dist/node_modules/lucide-react/dist/esm/icons/chevron-down.js +0 -14
  234. package/dist/node_modules/lucide-react/dist/esm/icons/chevron-left.js +0 -14
  235. package/dist/node_modules/lucide-react/dist/esm/icons/chevron-right.js +0 -14
  236. package/dist/node_modules/lucide-react/dist/esm/icons/chevron-up.js +0 -14
  237. package/dist/node_modules/lucide-react/dist/esm/icons/circle.js +0 -14
  238. package/dist/node_modules/lucide-react/dist/esm/icons/ellipsis.js +0 -18
  239. package/dist/node_modules/lucide-react/dist/esm/icons/x.js +0 -17
  240. package/dist/node_modules/lucide-react/dist/esm/shared/src/utils.js +0 -28
  241. package/dist/node_modules/react-hook-form/dist/index.esm.js +0 -560
  242. package/dist/node_modules/react-i18next/dist/es/IcuTransUtils/htmlEntityDecoder.js +0 -210
  243. package/dist/node_modules/react-i18next/dist/es/context.js +0 -18
  244. package/dist/node_modules/react-i18next/dist/es/defaults.js +0 -22
  245. package/dist/node_modules/react-i18next/dist/es/i18nInstance.js +0 -7
  246. package/dist/node_modules/react-i18next/dist/es/initReactI18next.js +0 -12
  247. package/dist/node_modules/react-i18next/dist/es/unescape.js +0 -27
  248. package/dist/node_modules/react-i18next/dist/es/useTranslation.js +0 -157
  249. package/dist/node_modules/react-i18next/dist/es/utils.js +0 -63
  250. package/dist/node_modules/react-remove-scroll/dist/es2015/Combination.js +0 -9
  251. package/dist/node_modules/react-remove-scroll/dist/es2015/SideEffect.js +0 -167
  252. package/dist/node_modules/react-remove-scroll/dist/es2015/UI.js +0 -38
  253. package/dist/node_modules/react-remove-scroll/dist/es2015/aggresiveCapture.js +0 -21
  254. package/dist/node_modules/react-remove-scroll/dist/es2015/handleScroll.js +0 -110
  255. package/dist/node_modules/react-remove-scroll/dist/es2015/medium.js +0 -5
  256. package/dist/node_modules/react-remove-scroll/dist/es2015/sidecar.js +0 -7
  257. package/dist/node_modules/react-remove-scroll-bar/dist/es2015/component.js +0 -56
  258. package/dist/node_modules/react-remove-scroll-bar/dist/es2015/constants.js +0 -10
  259. package/dist/node_modules/react-remove-scroll-bar/dist/es2015/utils.js +0 -31
  260. package/dist/node_modules/react-style-singleton/dist/es2015/component.js +0 -19
  261. package/dist/node_modules/react-style-singleton/dist/es2015/hook.js +0 -25
  262. package/dist/node_modules/react-style-singleton/dist/es2015/singleton.js +0 -51
  263. package/dist/node_modules/sonner/dist/index.js +0 -299
  264. package/dist/node_modules/tslib/tslib.es6.js +0 -56
  265. package/dist/node_modules/use-callback-ref/dist/es2015/assignRef.js +0 -24
  266. package/dist/node_modules/use-callback-ref/dist/es2015/useMergeRef.js +0 -48
  267. package/dist/node_modules/use-callback-ref/dist/es2015/useRef.js +0 -42
  268. package/dist/node_modules/use-sidecar/dist/es2015/exports.js +0 -21
  269. package/dist/node_modules/use-sidecar/dist/es2015/medium.js +0 -77
  270. package/dist/node_modules/use-sync-external-store/cjs/use-sync-external-store-shim.development.js +0 -106
  271. package/dist/node_modules/use-sync-external-store/cjs/use-sync-external-store-shim.production.js +0 -77
  272. package/dist/node_modules/use-sync-external-store/shim/index.js +0 -19
  273. package/dist/node_modules/zustand/esm/react.js +0 -22
  274. package/dist/node_modules/zustand/esm/vanilla.js +0 -24
  275. /package/src/{core/commands → commands}/create-core-module.js +0 -0
  276. /package/src/{core/commands → commands}/create-module.js +0 -0
  277. /package/src/{core/commands → commands}/create-template.js +0 -0
  278. /package/src/{core/commands → commands}/rollback-core-module.js +0 -0
  279. /package/src/{core/commands → commands}/rollback-module.js +0 -0
@@ -1,834 +0,0 @@
1
- import * as React from 'react';
2
- import { composeEventHandlers } from '../../primitive/dist/index.js';
3
- import { createCollection } from '../../react-collection/dist/index.js';
4
- import { composeRefs, useComposedRefs } from '../../react-compose-refs/dist/index.js';
5
- import { createContextScope } from '../../react-context/dist/index.js';
6
- import { useDirection } from '../../react-direction/dist/index.js';
7
- import { DismissableLayer } from '../../react-dismissable-layer/dist/index.js';
8
- import { useFocusGuards } from '../../react-focus-guards/dist/index.js';
9
- import { FocusScope } from '../../react-focus-scope/dist/index.js';
10
- import { useId } from '../../react-id/dist/index.js';
11
- import { createPopperScope, Anchor, Content, Root as Root2, Arrow } from '../../react-popper/dist/index.js';
12
- import { Portal as Portal$1 } from '../../react-portal/dist/index.js';
13
- import { Presence } from '../../react-presence/dist/index.js';
14
- import { Primitive, dispatchDiscreteCustomEvent } from '../../react-primitive/dist/index.js';
15
- import { createRovingFocusGroupScope, Item, Root } from '../../react-roving-focus/dist/index.js';
16
- import { createSlot } from '../../react-slot/dist/index.js';
17
- import { useCallbackRef } from '../../react-use-callback-ref/dist/index.js';
18
- import { hideOthers } from '../../../aria-hidden/dist/es2015/index.js';
19
- import ReactRemoveScroll from '../../../react-remove-scroll/dist/es2015/Combination.js';
20
- import { jsx } from 'react/jsx-runtime';
21
-
22
- var SELECTION_KEYS = ["Enter", " "];
23
- var FIRST_KEYS = ["ArrowDown", "PageUp", "Home"];
24
- var LAST_KEYS = ["ArrowUp", "PageDown", "End"];
25
- var FIRST_LAST_KEYS = [...FIRST_KEYS, ...LAST_KEYS];
26
- var SUB_OPEN_KEYS = {
27
- ltr: [...SELECTION_KEYS, "ArrowRight"],
28
- rtl: [...SELECTION_KEYS, "ArrowLeft"]
29
- };
30
- var SUB_CLOSE_KEYS = {
31
- ltr: ["ArrowLeft"],
32
- rtl: ["ArrowRight"]
33
- };
34
- var MENU_NAME = "Menu";
35
- var [Collection, useCollection, createCollectionScope] = createCollection(MENU_NAME);
36
- var [createMenuContext, createMenuScope] = createContextScope(MENU_NAME, [
37
- createCollectionScope,
38
- createPopperScope,
39
- createRovingFocusGroupScope
40
- ]);
41
- var usePopperScope = createPopperScope();
42
- var useRovingFocusGroupScope = createRovingFocusGroupScope();
43
- var [MenuProvider, useMenuContext] = createMenuContext(MENU_NAME);
44
- var [MenuRootProvider, useMenuRootContext] = createMenuContext(MENU_NAME);
45
- var Menu = (props) => {
46
- const { __scopeMenu, open = false, children, dir, onOpenChange, modal = true } = props;
47
- const popperScope = usePopperScope(__scopeMenu);
48
- const [content, setContent] = React.useState(null);
49
- const isUsingKeyboardRef = React.useRef(false);
50
- const handleOpenChange = useCallbackRef(onOpenChange);
51
- const direction = useDirection(dir);
52
- React.useEffect(() => {
53
- const handleKeyDown = () => {
54
- isUsingKeyboardRef.current = true;
55
- document.addEventListener("pointerdown", handlePointer, { capture: true, once: true });
56
- document.addEventListener("pointermove", handlePointer, { capture: true, once: true });
57
- };
58
- const handlePointer = () => isUsingKeyboardRef.current = false;
59
- document.addEventListener("keydown", handleKeyDown, { capture: true });
60
- return () => {
61
- document.removeEventListener("keydown", handleKeyDown, { capture: true });
62
- document.removeEventListener("pointerdown", handlePointer, { capture: true });
63
- document.removeEventListener("pointermove", handlePointer, { capture: true });
64
- };
65
- }, []);
66
- return /* @__PURE__ */ jsx(Root2, { ...popperScope, children: /* @__PURE__ */ jsx(
67
- MenuProvider,
68
- {
69
- scope: __scopeMenu,
70
- open,
71
- onOpenChange: handleOpenChange,
72
- content,
73
- onContentChange: setContent,
74
- children: /* @__PURE__ */ jsx(
75
- MenuRootProvider,
76
- {
77
- scope: __scopeMenu,
78
- onClose: React.useCallback(() => handleOpenChange(false), [handleOpenChange]),
79
- isUsingKeyboardRef,
80
- dir: direction,
81
- modal,
82
- children
83
- }
84
- )
85
- }
86
- ) });
87
- };
88
- Menu.displayName = MENU_NAME;
89
- var ANCHOR_NAME = "MenuAnchor";
90
- var MenuAnchor = React.forwardRef(
91
- (props, forwardedRef) => {
92
- const { __scopeMenu, ...anchorProps } = props;
93
- const popperScope = usePopperScope(__scopeMenu);
94
- return /* @__PURE__ */ jsx(Anchor, { ...popperScope, ...anchorProps, ref: forwardedRef });
95
- }
96
- );
97
- MenuAnchor.displayName = ANCHOR_NAME;
98
- var PORTAL_NAME = "MenuPortal";
99
- var [PortalProvider, usePortalContext] = createMenuContext(PORTAL_NAME, {
100
- forceMount: void 0
101
- });
102
- var MenuPortal = (props) => {
103
- const { __scopeMenu, forceMount, children, container } = props;
104
- const context = useMenuContext(PORTAL_NAME, __scopeMenu);
105
- return /* @__PURE__ */ jsx(PortalProvider, { scope: __scopeMenu, forceMount, children: /* @__PURE__ */ jsx(Presence, { present: forceMount || context.open, children: /* @__PURE__ */ jsx(Portal$1, { asChild: true, container, children }) }) });
106
- };
107
- MenuPortal.displayName = PORTAL_NAME;
108
- var CONTENT_NAME = "MenuContent";
109
- var [MenuContentProvider, useMenuContentContext] = createMenuContext(CONTENT_NAME);
110
- var MenuContent = React.forwardRef(
111
- (props, forwardedRef) => {
112
- const portalContext = usePortalContext(CONTENT_NAME, props.__scopeMenu);
113
- const { forceMount = portalContext.forceMount, ...contentProps } = props;
114
- const context = useMenuContext(CONTENT_NAME, props.__scopeMenu);
115
- const rootContext = useMenuRootContext(CONTENT_NAME, props.__scopeMenu);
116
- return /* @__PURE__ */ jsx(Collection.Provider, { scope: props.__scopeMenu, children: /* @__PURE__ */ jsx(Presence, { present: forceMount || context.open, children: /* @__PURE__ */ jsx(Collection.Slot, { scope: props.__scopeMenu, children: rootContext.modal ? /* @__PURE__ */ jsx(MenuRootContentModal, { ...contentProps, ref: forwardedRef }) : /* @__PURE__ */ jsx(MenuRootContentNonModal, { ...contentProps, ref: forwardedRef }) }) }) });
117
- }
118
- );
119
- var MenuRootContentModal = React.forwardRef(
120
- (props, forwardedRef) => {
121
- const context = useMenuContext(CONTENT_NAME, props.__scopeMenu);
122
- const ref = React.useRef(null);
123
- const composedRefs = useComposedRefs(forwardedRef, ref);
124
- React.useEffect(() => {
125
- const content = ref.current;
126
- if (content) return hideOthers(content);
127
- }, []);
128
- return /* @__PURE__ */ jsx(
129
- MenuContentImpl,
130
- {
131
- ...props,
132
- ref: composedRefs,
133
- trapFocus: context.open,
134
- disableOutsidePointerEvents: context.open,
135
- disableOutsideScroll: true,
136
- onFocusOutside: composeEventHandlers(
137
- props.onFocusOutside,
138
- (event) => event.preventDefault(),
139
- { checkForDefaultPrevented: false }
140
- ),
141
- onDismiss: () => context.onOpenChange(false)
142
- }
143
- );
144
- }
145
- );
146
- var MenuRootContentNonModal = React.forwardRef((props, forwardedRef) => {
147
- const context = useMenuContext(CONTENT_NAME, props.__scopeMenu);
148
- return /* @__PURE__ */ jsx(
149
- MenuContentImpl,
150
- {
151
- ...props,
152
- ref: forwardedRef,
153
- trapFocus: false,
154
- disableOutsidePointerEvents: false,
155
- disableOutsideScroll: false,
156
- onDismiss: () => context.onOpenChange(false)
157
- }
158
- );
159
- });
160
- var Slot = createSlot("MenuContent.ScrollLock");
161
- var MenuContentImpl = React.forwardRef(
162
- (props, forwardedRef) => {
163
- const {
164
- __scopeMenu,
165
- loop = false,
166
- trapFocus,
167
- onOpenAutoFocus,
168
- onCloseAutoFocus,
169
- disableOutsidePointerEvents,
170
- onEntryFocus,
171
- onEscapeKeyDown,
172
- onPointerDownOutside,
173
- onFocusOutside,
174
- onInteractOutside,
175
- onDismiss,
176
- disableOutsideScroll,
177
- ...contentProps
178
- } = props;
179
- const context = useMenuContext(CONTENT_NAME, __scopeMenu);
180
- const rootContext = useMenuRootContext(CONTENT_NAME, __scopeMenu);
181
- const popperScope = usePopperScope(__scopeMenu);
182
- const rovingFocusGroupScope = useRovingFocusGroupScope(__scopeMenu);
183
- const getItems = useCollection(__scopeMenu);
184
- const [currentItemId, setCurrentItemId] = React.useState(null);
185
- const contentRef = React.useRef(null);
186
- const composedRefs = useComposedRefs(forwardedRef, contentRef, context.onContentChange);
187
- const timerRef = React.useRef(0);
188
- const searchRef = React.useRef("");
189
- const pointerGraceTimerRef = React.useRef(0);
190
- const pointerGraceIntentRef = React.useRef(null);
191
- const pointerDirRef = React.useRef("right");
192
- const lastPointerXRef = React.useRef(0);
193
- const ScrollLockWrapper = disableOutsideScroll ? ReactRemoveScroll : React.Fragment;
194
- const scrollLockWrapperProps = disableOutsideScroll ? { as: Slot, allowPinchZoom: true } : void 0;
195
- const handleTypeaheadSearch = (key) => {
196
- const search = searchRef.current + key;
197
- const items = getItems().filter((item) => !item.disabled);
198
- const currentItem = document.activeElement;
199
- const currentMatch = items.find((item) => item.ref.current === currentItem)?.textValue;
200
- const values = items.map((item) => item.textValue);
201
- const nextMatch = getNextMatch(values, search, currentMatch);
202
- const newItem = items.find((item) => item.textValue === nextMatch)?.ref.current;
203
- (function updateSearch(value) {
204
- searchRef.current = value;
205
- window.clearTimeout(timerRef.current);
206
- if (value !== "") timerRef.current = window.setTimeout(() => updateSearch(""), 1e3);
207
- })(search);
208
- if (newItem) {
209
- setTimeout(() => newItem.focus());
210
- }
211
- };
212
- React.useEffect(() => {
213
- return () => window.clearTimeout(timerRef.current);
214
- }, []);
215
- useFocusGuards();
216
- const isPointerMovingToSubmenu = React.useCallback((event) => {
217
- const isMovingTowards = pointerDirRef.current === pointerGraceIntentRef.current?.side;
218
- return isMovingTowards && isPointerInGraceArea(event, pointerGraceIntentRef.current?.area);
219
- }, []);
220
- return /* @__PURE__ */ jsx(
221
- MenuContentProvider,
222
- {
223
- scope: __scopeMenu,
224
- searchRef,
225
- onItemEnter: React.useCallback(
226
- (event) => {
227
- if (isPointerMovingToSubmenu(event)) event.preventDefault();
228
- },
229
- [isPointerMovingToSubmenu]
230
- ),
231
- onItemLeave: React.useCallback(
232
- (event) => {
233
- if (isPointerMovingToSubmenu(event)) return;
234
- contentRef.current?.focus();
235
- setCurrentItemId(null);
236
- },
237
- [isPointerMovingToSubmenu]
238
- ),
239
- onTriggerLeave: React.useCallback(
240
- (event) => {
241
- if (isPointerMovingToSubmenu(event)) event.preventDefault();
242
- },
243
- [isPointerMovingToSubmenu]
244
- ),
245
- pointerGraceTimerRef,
246
- onPointerGraceIntentChange: React.useCallback((intent) => {
247
- pointerGraceIntentRef.current = intent;
248
- }, []),
249
- children: /* @__PURE__ */ jsx(ScrollLockWrapper, { ...scrollLockWrapperProps, children: /* @__PURE__ */ jsx(
250
- FocusScope,
251
- {
252
- asChild: true,
253
- trapped: trapFocus,
254
- onMountAutoFocus: composeEventHandlers(onOpenAutoFocus, (event) => {
255
- event.preventDefault();
256
- contentRef.current?.focus({ preventScroll: true });
257
- }),
258
- onUnmountAutoFocus: onCloseAutoFocus,
259
- children: /* @__PURE__ */ jsx(
260
- DismissableLayer,
261
- {
262
- asChild: true,
263
- disableOutsidePointerEvents,
264
- onEscapeKeyDown,
265
- onPointerDownOutside,
266
- onFocusOutside,
267
- onInteractOutside,
268
- onDismiss,
269
- children: /* @__PURE__ */ jsx(
270
- Root,
271
- {
272
- asChild: true,
273
- ...rovingFocusGroupScope,
274
- dir: rootContext.dir,
275
- orientation: "vertical",
276
- loop,
277
- currentTabStopId: currentItemId,
278
- onCurrentTabStopIdChange: setCurrentItemId,
279
- onEntryFocus: composeEventHandlers(onEntryFocus, (event) => {
280
- if (!rootContext.isUsingKeyboardRef.current) event.preventDefault();
281
- }),
282
- preventScrollOnEntryFocus: true,
283
- children: /* @__PURE__ */ jsx(
284
- Content,
285
- {
286
- role: "menu",
287
- "aria-orientation": "vertical",
288
- "data-state": getOpenState(context.open),
289
- "data-radix-menu-content": "",
290
- dir: rootContext.dir,
291
- ...popperScope,
292
- ...contentProps,
293
- ref: composedRefs,
294
- style: { outline: "none", ...contentProps.style },
295
- onKeyDown: composeEventHandlers(contentProps.onKeyDown, (event) => {
296
- const target = event.target;
297
- const isKeyDownInside = target.closest("[data-radix-menu-content]") === event.currentTarget;
298
- const isModifierKey = event.ctrlKey || event.altKey || event.metaKey;
299
- const isCharacterKey = event.key.length === 1;
300
- if (isKeyDownInside) {
301
- if (event.key === "Tab") event.preventDefault();
302
- if (!isModifierKey && isCharacterKey) handleTypeaheadSearch(event.key);
303
- }
304
- const content = contentRef.current;
305
- if (event.target !== content) return;
306
- if (!FIRST_LAST_KEYS.includes(event.key)) return;
307
- event.preventDefault();
308
- const items = getItems().filter((item) => !item.disabled);
309
- const candidateNodes = items.map((item) => item.ref.current);
310
- if (LAST_KEYS.includes(event.key)) candidateNodes.reverse();
311
- focusFirst(candidateNodes);
312
- }),
313
- onBlur: composeEventHandlers(props.onBlur, (event) => {
314
- if (!event.currentTarget.contains(event.target)) {
315
- window.clearTimeout(timerRef.current);
316
- searchRef.current = "";
317
- }
318
- }),
319
- onPointerMove: composeEventHandlers(
320
- props.onPointerMove,
321
- whenMouse((event) => {
322
- const target = event.target;
323
- const pointerXHasChanged = lastPointerXRef.current !== event.clientX;
324
- if (event.currentTarget.contains(target) && pointerXHasChanged) {
325
- const newDir = event.clientX > lastPointerXRef.current ? "right" : "left";
326
- pointerDirRef.current = newDir;
327
- lastPointerXRef.current = event.clientX;
328
- }
329
- })
330
- )
331
- }
332
- )
333
- }
334
- )
335
- }
336
- )
337
- }
338
- ) })
339
- }
340
- );
341
- }
342
- );
343
- MenuContent.displayName = CONTENT_NAME;
344
- var GROUP_NAME = "MenuGroup";
345
- var MenuGroup = React.forwardRef(
346
- (props, forwardedRef) => {
347
- const { __scopeMenu, ...groupProps } = props;
348
- return /* @__PURE__ */ jsx(Primitive.div, { role: "group", ...groupProps, ref: forwardedRef });
349
- }
350
- );
351
- MenuGroup.displayName = GROUP_NAME;
352
- var LABEL_NAME = "MenuLabel";
353
- var MenuLabel = React.forwardRef(
354
- (props, forwardedRef) => {
355
- const { __scopeMenu, ...labelProps } = props;
356
- return /* @__PURE__ */ jsx(Primitive.div, { ...labelProps, ref: forwardedRef });
357
- }
358
- );
359
- MenuLabel.displayName = LABEL_NAME;
360
- var ITEM_NAME = "MenuItem";
361
- var ITEM_SELECT = "menu.itemSelect";
362
- var MenuItem = React.forwardRef(
363
- (props, forwardedRef) => {
364
- const { disabled = false, onSelect, ...itemProps } = props;
365
- const ref = React.useRef(null);
366
- const rootContext = useMenuRootContext(ITEM_NAME, props.__scopeMenu);
367
- const contentContext = useMenuContentContext(ITEM_NAME, props.__scopeMenu);
368
- const composedRefs = useComposedRefs(forwardedRef, ref);
369
- const isPointerDownRef = React.useRef(false);
370
- const handleSelect = () => {
371
- const menuItem = ref.current;
372
- if (!disabled && menuItem) {
373
- const itemSelectEvent = new CustomEvent(ITEM_SELECT, { bubbles: true, cancelable: true });
374
- menuItem.addEventListener(ITEM_SELECT, (event) => onSelect?.(event), { once: true });
375
- dispatchDiscreteCustomEvent(menuItem, itemSelectEvent);
376
- if (itemSelectEvent.defaultPrevented) {
377
- isPointerDownRef.current = false;
378
- } else {
379
- rootContext.onClose();
380
- }
381
- }
382
- };
383
- return /* @__PURE__ */ jsx(
384
- MenuItemImpl,
385
- {
386
- ...itemProps,
387
- ref: composedRefs,
388
- disabled,
389
- onClick: composeEventHandlers(props.onClick, handleSelect),
390
- onPointerDown: (event) => {
391
- props.onPointerDown?.(event);
392
- isPointerDownRef.current = true;
393
- },
394
- onPointerUp: composeEventHandlers(props.onPointerUp, (event) => {
395
- if (!isPointerDownRef.current) event.currentTarget?.click();
396
- }),
397
- onKeyDown: composeEventHandlers(props.onKeyDown, (event) => {
398
- const isTypingAhead = contentContext.searchRef.current !== "";
399
- if (disabled || isTypingAhead && event.key === " ") return;
400
- if (SELECTION_KEYS.includes(event.key)) {
401
- event.currentTarget.click();
402
- event.preventDefault();
403
- }
404
- })
405
- }
406
- );
407
- }
408
- );
409
- MenuItem.displayName = ITEM_NAME;
410
- var MenuItemImpl = React.forwardRef(
411
- (props, forwardedRef) => {
412
- const { __scopeMenu, disabled = false, textValue, ...itemProps } = props;
413
- const contentContext = useMenuContentContext(ITEM_NAME, __scopeMenu);
414
- const rovingFocusGroupScope = useRovingFocusGroupScope(__scopeMenu);
415
- const ref = React.useRef(null);
416
- const composedRefs = useComposedRefs(forwardedRef, ref);
417
- const [isFocused, setIsFocused] = React.useState(false);
418
- const [textContent, setTextContent] = React.useState("");
419
- React.useEffect(() => {
420
- const menuItem = ref.current;
421
- if (menuItem) {
422
- setTextContent((menuItem.textContent ?? "").trim());
423
- }
424
- }, [itemProps.children]);
425
- return /* @__PURE__ */ jsx(
426
- Collection.ItemSlot,
427
- {
428
- scope: __scopeMenu,
429
- disabled,
430
- textValue: textValue ?? textContent,
431
- children: /* @__PURE__ */ jsx(Item, { asChild: true, ...rovingFocusGroupScope, focusable: !disabled, children: /* @__PURE__ */ jsx(
432
- Primitive.div,
433
- {
434
- role: "menuitem",
435
- "data-highlighted": isFocused ? "" : void 0,
436
- "aria-disabled": disabled || void 0,
437
- "data-disabled": disabled ? "" : void 0,
438
- ...itemProps,
439
- ref: composedRefs,
440
- onPointerMove: composeEventHandlers(
441
- props.onPointerMove,
442
- whenMouse((event) => {
443
- if (disabled) {
444
- contentContext.onItemLeave(event);
445
- } else {
446
- contentContext.onItemEnter(event);
447
- if (!event.defaultPrevented) {
448
- const item = event.currentTarget;
449
- item.focus({ preventScroll: true });
450
- }
451
- }
452
- })
453
- ),
454
- onPointerLeave: composeEventHandlers(
455
- props.onPointerLeave,
456
- whenMouse((event) => contentContext.onItemLeave(event))
457
- ),
458
- onFocus: composeEventHandlers(props.onFocus, () => setIsFocused(true)),
459
- onBlur: composeEventHandlers(props.onBlur, () => setIsFocused(false))
460
- }
461
- ) })
462
- }
463
- );
464
- }
465
- );
466
- var CHECKBOX_ITEM_NAME = "MenuCheckboxItem";
467
- var MenuCheckboxItem = React.forwardRef(
468
- (props, forwardedRef) => {
469
- const { checked = false, onCheckedChange, ...checkboxItemProps } = props;
470
- return /* @__PURE__ */ jsx(ItemIndicatorProvider, { scope: props.__scopeMenu, checked, children: /* @__PURE__ */ jsx(
471
- MenuItem,
472
- {
473
- role: "menuitemcheckbox",
474
- "aria-checked": isIndeterminate(checked) ? "mixed" : checked,
475
- ...checkboxItemProps,
476
- ref: forwardedRef,
477
- "data-state": getCheckedState(checked),
478
- onSelect: composeEventHandlers(
479
- checkboxItemProps.onSelect,
480
- () => onCheckedChange?.(isIndeterminate(checked) ? true : !checked),
481
- { checkForDefaultPrevented: false }
482
- )
483
- }
484
- ) });
485
- }
486
- );
487
- MenuCheckboxItem.displayName = CHECKBOX_ITEM_NAME;
488
- var RADIO_GROUP_NAME = "MenuRadioGroup";
489
- var [RadioGroupProvider, useRadioGroupContext] = createMenuContext(
490
- RADIO_GROUP_NAME,
491
- { value: void 0, onValueChange: () => {
492
- } }
493
- );
494
- var MenuRadioGroup = React.forwardRef(
495
- (props, forwardedRef) => {
496
- const { value, onValueChange, ...groupProps } = props;
497
- const handleValueChange = useCallbackRef(onValueChange);
498
- return /* @__PURE__ */ jsx(RadioGroupProvider, { scope: props.__scopeMenu, value, onValueChange: handleValueChange, children: /* @__PURE__ */ jsx(MenuGroup, { ...groupProps, ref: forwardedRef }) });
499
- }
500
- );
501
- MenuRadioGroup.displayName = RADIO_GROUP_NAME;
502
- var RADIO_ITEM_NAME = "MenuRadioItem";
503
- var MenuRadioItem = React.forwardRef(
504
- (props, forwardedRef) => {
505
- const { value, ...radioItemProps } = props;
506
- const context = useRadioGroupContext(RADIO_ITEM_NAME, props.__scopeMenu);
507
- const checked = value === context.value;
508
- return /* @__PURE__ */ jsx(ItemIndicatorProvider, { scope: props.__scopeMenu, checked, children: /* @__PURE__ */ jsx(
509
- MenuItem,
510
- {
511
- role: "menuitemradio",
512
- "aria-checked": checked,
513
- ...radioItemProps,
514
- ref: forwardedRef,
515
- "data-state": getCheckedState(checked),
516
- onSelect: composeEventHandlers(
517
- radioItemProps.onSelect,
518
- () => context.onValueChange?.(value),
519
- { checkForDefaultPrevented: false }
520
- )
521
- }
522
- ) });
523
- }
524
- );
525
- MenuRadioItem.displayName = RADIO_ITEM_NAME;
526
- var ITEM_INDICATOR_NAME = "MenuItemIndicator";
527
- var [ItemIndicatorProvider, useItemIndicatorContext] = createMenuContext(
528
- ITEM_INDICATOR_NAME,
529
- { checked: false }
530
- );
531
- var MenuItemIndicator = React.forwardRef(
532
- (props, forwardedRef) => {
533
- const { __scopeMenu, forceMount, ...itemIndicatorProps } = props;
534
- const indicatorContext = useItemIndicatorContext(ITEM_INDICATOR_NAME, __scopeMenu);
535
- return /* @__PURE__ */ jsx(
536
- Presence,
537
- {
538
- present: forceMount || isIndeterminate(indicatorContext.checked) || indicatorContext.checked === true,
539
- children: /* @__PURE__ */ jsx(
540
- Primitive.span,
541
- {
542
- ...itemIndicatorProps,
543
- ref: forwardedRef,
544
- "data-state": getCheckedState(indicatorContext.checked)
545
- }
546
- )
547
- }
548
- );
549
- }
550
- );
551
- MenuItemIndicator.displayName = ITEM_INDICATOR_NAME;
552
- var SEPARATOR_NAME = "MenuSeparator";
553
- var MenuSeparator = React.forwardRef(
554
- (props, forwardedRef) => {
555
- const { __scopeMenu, ...separatorProps } = props;
556
- return /* @__PURE__ */ jsx(
557
- Primitive.div,
558
- {
559
- role: "separator",
560
- "aria-orientation": "horizontal",
561
- ...separatorProps,
562
- ref: forwardedRef
563
- }
564
- );
565
- }
566
- );
567
- MenuSeparator.displayName = SEPARATOR_NAME;
568
- var ARROW_NAME = "MenuArrow";
569
- var MenuArrow = React.forwardRef(
570
- (props, forwardedRef) => {
571
- const { __scopeMenu, ...arrowProps } = props;
572
- const popperScope = usePopperScope(__scopeMenu);
573
- return /* @__PURE__ */ jsx(Arrow, { ...popperScope, ...arrowProps, ref: forwardedRef });
574
- }
575
- );
576
- MenuArrow.displayName = ARROW_NAME;
577
- var SUB_NAME = "MenuSub";
578
- var [MenuSubProvider, useMenuSubContext] = createMenuContext(SUB_NAME);
579
- var MenuSub = (props) => {
580
- const { __scopeMenu, children, open = false, onOpenChange } = props;
581
- const parentMenuContext = useMenuContext(SUB_NAME, __scopeMenu);
582
- const popperScope = usePopperScope(__scopeMenu);
583
- const [trigger, setTrigger] = React.useState(null);
584
- const [content, setContent] = React.useState(null);
585
- const handleOpenChange = useCallbackRef(onOpenChange);
586
- React.useEffect(() => {
587
- if (parentMenuContext.open === false) handleOpenChange(false);
588
- return () => handleOpenChange(false);
589
- }, [parentMenuContext.open, handleOpenChange]);
590
- return /* @__PURE__ */ jsx(Root2, { ...popperScope, children: /* @__PURE__ */ jsx(
591
- MenuProvider,
592
- {
593
- scope: __scopeMenu,
594
- open,
595
- onOpenChange: handleOpenChange,
596
- content,
597
- onContentChange: setContent,
598
- children: /* @__PURE__ */ jsx(
599
- MenuSubProvider,
600
- {
601
- scope: __scopeMenu,
602
- contentId: useId(),
603
- triggerId: useId(),
604
- trigger,
605
- onTriggerChange: setTrigger,
606
- children
607
- }
608
- )
609
- }
610
- ) });
611
- };
612
- MenuSub.displayName = SUB_NAME;
613
- var SUB_TRIGGER_NAME = "MenuSubTrigger";
614
- var MenuSubTrigger = React.forwardRef(
615
- (props, forwardedRef) => {
616
- const context = useMenuContext(SUB_TRIGGER_NAME, props.__scopeMenu);
617
- const rootContext = useMenuRootContext(SUB_TRIGGER_NAME, props.__scopeMenu);
618
- const subContext = useMenuSubContext(SUB_TRIGGER_NAME, props.__scopeMenu);
619
- const contentContext = useMenuContentContext(SUB_TRIGGER_NAME, props.__scopeMenu);
620
- const openTimerRef = React.useRef(null);
621
- const { pointerGraceTimerRef, onPointerGraceIntentChange } = contentContext;
622
- const scope = { __scopeMenu: props.__scopeMenu };
623
- const clearOpenTimer = React.useCallback(() => {
624
- if (openTimerRef.current) window.clearTimeout(openTimerRef.current);
625
- openTimerRef.current = null;
626
- }, []);
627
- React.useEffect(() => clearOpenTimer, [clearOpenTimer]);
628
- React.useEffect(() => {
629
- const pointerGraceTimer = pointerGraceTimerRef.current;
630
- return () => {
631
- window.clearTimeout(pointerGraceTimer);
632
- onPointerGraceIntentChange(null);
633
- };
634
- }, [pointerGraceTimerRef, onPointerGraceIntentChange]);
635
- return /* @__PURE__ */ jsx(MenuAnchor, { asChild: true, ...scope, children: /* @__PURE__ */ jsx(
636
- MenuItemImpl,
637
- {
638
- id: subContext.triggerId,
639
- "aria-haspopup": "menu",
640
- "aria-expanded": context.open,
641
- "aria-controls": subContext.contentId,
642
- "data-state": getOpenState(context.open),
643
- ...props,
644
- ref: composeRefs(forwardedRef, subContext.onTriggerChange),
645
- onClick: (event) => {
646
- props.onClick?.(event);
647
- if (props.disabled || event.defaultPrevented) return;
648
- event.currentTarget.focus();
649
- if (!context.open) context.onOpenChange(true);
650
- },
651
- onPointerMove: composeEventHandlers(
652
- props.onPointerMove,
653
- whenMouse((event) => {
654
- contentContext.onItemEnter(event);
655
- if (event.defaultPrevented) return;
656
- if (!props.disabled && !context.open && !openTimerRef.current) {
657
- contentContext.onPointerGraceIntentChange(null);
658
- openTimerRef.current = window.setTimeout(() => {
659
- context.onOpenChange(true);
660
- clearOpenTimer();
661
- }, 100);
662
- }
663
- })
664
- ),
665
- onPointerLeave: composeEventHandlers(
666
- props.onPointerLeave,
667
- whenMouse((event) => {
668
- clearOpenTimer();
669
- const contentRect = context.content?.getBoundingClientRect();
670
- if (contentRect) {
671
- const side = context.content?.dataset.side;
672
- const rightSide = side === "right";
673
- const bleed = rightSide ? -5 : 5;
674
- const contentNearEdge = contentRect[rightSide ? "left" : "right"];
675
- const contentFarEdge = contentRect[rightSide ? "right" : "left"];
676
- contentContext.onPointerGraceIntentChange({
677
- area: [
678
- // Apply a bleed on clientX to ensure that our exit point is
679
- // consistently within polygon bounds
680
- { x: event.clientX + bleed, y: event.clientY },
681
- { x: contentNearEdge, y: contentRect.top },
682
- { x: contentFarEdge, y: contentRect.top },
683
- { x: contentFarEdge, y: contentRect.bottom },
684
- { x: contentNearEdge, y: contentRect.bottom }
685
- ],
686
- side
687
- });
688
- window.clearTimeout(pointerGraceTimerRef.current);
689
- pointerGraceTimerRef.current = window.setTimeout(
690
- () => contentContext.onPointerGraceIntentChange(null),
691
- 300
692
- );
693
- } else {
694
- contentContext.onTriggerLeave(event);
695
- if (event.defaultPrevented) return;
696
- contentContext.onPointerGraceIntentChange(null);
697
- }
698
- })
699
- ),
700
- onKeyDown: composeEventHandlers(props.onKeyDown, (event) => {
701
- const isTypingAhead = contentContext.searchRef.current !== "";
702
- if (props.disabled || isTypingAhead && event.key === " ") return;
703
- if (SUB_OPEN_KEYS[rootContext.dir].includes(event.key)) {
704
- context.onOpenChange(true);
705
- context.content?.focus();
706
- event.preventDefault();
707
- }
708
- })
709
- }
710
- ) });
711
- }
712
- );
713
- MenuSubTrigger.displayName = SUB_TRIGGER_NAME;
714
- var SUB_CONTENT_NAME = "MenuSubContent";
715
- var MenuSubContent = React.forwardRef(
716
- (props, forwardedRef) => {
717
- const portalContext = usePortalContext(CONTENT_NAME, props.__scopeMenu);
718
- const { forceMount = portalContext.forceMount, ...subContentProps } = props;
719
- const context = useMenuContext(CONTENT_NAME, props.__scopeMenu);
720
- const rootContext = useMenuRootContext(CONTENT_NAME, props.__scopeMenu);
721
- const subContext = useMenuSubContext(SUB_CONTENT_NAME, props.__scopeMenu);
722
- const ref = React.useRef(null);
723
- const composedRefs = useComposedRefs(forwardedRef, ref);
724
- return /* @__PURE__ */ jsx(Collection.Provider, { scope: props.__scopeMenu, children: /* @__PURE__ */ jsx(Presence, { present: forceMount || context.open, children: /* @__PURE__ */ jsx(Collection.Slot, { scope: props.__scopeMenu, children: /* @__PURE__ */ jsx(
725
- MenuContentImpl,
726
- {
727
- id: subContext.contentId,
728
- "aria-labelledby": subContext.triggerId,
729
- ...subContentProps,
730
- ref: composedRefs,
731
- align: "start",
732
- side: rootContext.dir === "rtl" ? "left" : "right",
733
- disableOutsidePointerEvents: false,
734
- disableOutsideScroll: false,
735
- trapFocus: false,
736
- onOpenAutoFocus: (event) => {
737
- if (rootContext.isUsingKeyboardRef.current) ref.current?.focus();
738
- event.preventDefault();
739
- },
740
- onCloseAutoFocus: (event) => event.preventDefault(),
741
- onFocusOutside: composeEventHandlers(props.onFocusOutside, (event) => {
742
- if (event.target !== subContext.trigger) context.onOpenChange(false);
743
- }),
744
- onEscapeKeyDown: composeEventHandlers(props.onEscapeKeyDown, (event) => {
745
- rootContext.onClose();
746
- event.preventDefault();
747
- }),
748
- onKeyDown: composeEventHandlers(props.onKeyDown, (event) => {
749
- const isKeyDownInside = event.currentTarget.contains(event.target);
750
- const isCloseKey = SUB_CLOSE_KEYS[rootContext.dir].includes(event.key);
751
- if (isKeyDownInside && isCloseKey) {
752
- context.onOpenChange(false);
753
- subContext.trigger?.focus();
754
- event.preventDefault();
755
- }
756
- })
757
- }
758
- ) }) }) });
759
- }
760
- );
761
- MenuSubContent.displayName = SUB_CONTENT_NAME;
762
- function getOpenState(open) {
763
- return open ? "open" : "closed";
764
- }
765
- function isIndeterminate(checked) {
766
- return checked === "indeterminate";
767
- }
768
- function getCheckedState(checked) {
769
- return isIndeterminate(checked) ? "indeterminate" : checked ? "checked" : "unchecked";
770
- }
771
- function focusFirst(candidates) {
772
- const PREVIOUSLY_FOCUSED_ELEMENT = document.activeElement;
773
- for (const candidate of candidates) {
774
- if (candidate === PREVIOUSLY_FOCUSED_ELEMENT) return;
775
- candidate.focus();
776
- if (document.activeElement !== PREVIOUSLY_FOCUSED_ELEMENT) return;
777
- }
778
- }
779
- function wrapArray(array, startIndex) {
780
- return array.map((_, index) => array[(startIndex + index) % array.length]);
781
- }
782
- function getNextMatch(values, search, currentMatch) {
783
- const isRepeated = search.length > 1 && Array.from(search).every((char) => char === search[0]);
784
- const normalizedSearch = isRepeated ? search[0] : search;
785
- const currentMatchIndex = currentMatch ? values.indexOf(currentMatch) : -1;
786
- let wrappedValues = wrapArray(values, Math.max(currentMatchIndex, 0));
787
- const excludeCurrentMatch = normalizedSearch.length === 1;
788
- if (excludeCurrentMatch) wrappedValues = wrappedValues.filter((v) => v !== currentMatch);
789
- const nextMatch = wrappedValues.find(
790
- (value) => value.toLowerCase().startsWith(normalizedSearch.toLowerCase())
791
- );
792
- return nextMatch !== currentMatch ? nextMatch : void 0;
793
- }
794
- function isPointInPolygon(point, polygon) {
795
- const { x, y } = point;
796
- let inside = false;
797
- for (let i = 0, j = polygon.length - 1; i < polygon.length; j = i++) {
798
- const ii = polygon[i];
799
- const jj = polygon[j];
800
- const xi = ii.x;
801
- const yi = ii.y;
802
- const xj = jj.x;
803
- const yj = jj.y;
804
- const intersect = yi > y !== yj > y && x < (xj - xi) * (y - yi) / (yj - yi) + xi;
805
- if (intersect) inside = !inside;
806
- }
807
- return inside;
808
- }
809
- function isPointerInGraceArea(event, area) {
810
- if (!area) return false;
811
- const cursorPos = { x: event.clientX, y: event.clientY };
812
- return isPointInPolygon(cursorPos, area);
813
- }
814
- function whenMouse(handler) {
815
- return (event) => event.pointerType === "mouse" ? handler(event) : void 0;
816
- }
817
- var Root3 = Menu;
818
- var Anchor2 = MenuAnchor;
819
- var Portal = MenuPortal;
820
- var Content2 = MenuContent;
821
- var Group = MenuGroup;
822
- var Label = MenuLabel;
823
- var Item2 = MenuItem;
824
- var CheckboxItem = MenuCheckboxItem;
825
- var RadioGroup = MenuRadioGroup;
826
- var RadioItem = MenuRadioItem;
827
- var ItemIndicator = MenuItemIndicator;
828
- var Separator = MenuSeparator;
829
- var Arrow2 = MenuArrow;
830
- var Sub = MenuSub;
831
- var SubTrigger = MenuSubTrigger;
832
- var SubContent = MenuSubContent;
833
-
834
- export { Anchor2 as Anchor, Arrow2 as Arrow, CheckboxItem, Content2 as Content, Group, Item2 as Item, ItemIndicator, Label, Menu, MenuAnchor, MenuArrow, MenuCheckboxItem, MenuContent, MenuGroup, MenuItem, MenuItemIndicator, MenuLabel, MenuPortal, MenuRadioGroup, MenuRadioItem, MenuSeparator, MenuSub, MenuSubContent, MenuSubTrigger, Portal, RadioGroup, RadioItem, Root3 as Root, Separator, Sub, SubContent, SubTrigger, createMenuScope };