@pixpilot/shadcn-ui 0.4.1 → 0.4.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (231) hide show
  1. package/dist/AbsoluteFill.d.ts +2 -2
  2. package/dist/Alert.cjs +8 -7
  3. package/dist/Alert.js +12 -12
  4. package/dist/Button.d.cts +1 -1
  5. package/dist/ContentCard.d.cts +1 -1
  6. package/dist/DatePicker.d.cts +1 -1
  7. package/dist/DatePicker.d.ts +2 -2
  8. package/dist/Select.d.cts +1 -1
  9. package/dist/_virtual/rolldown_runtime.cjs +0 -19
  10. package/dist/confirmation-dialog/ConfirmationDialog.cjs +2 -3
  11. package/dist/confirmation-dialog/ConfirmationDialog.js +3 -4
  12. package/dist/confirmation-dialog/index.cjs +0 -1
  13. package/dist/file-upload/FileUpload.d.ts +2 -2
  14. package/dist/file-upload/FileUploadListItem.cjs +1 -2
  15. package/dist/file-upload/FileUploadListItem.js +2 -3
  16. package/dist/file-upload/hooks/index.cjs +0 -1
  17. package/dist/file-upload/hooks/use-file-error.cjs +3 -3
  18. package/dist/file-upload/hooks/use-file-error.js +2 -3
  19. package/dist/file-upload/hooks/use-file-upload-progress-callbacks.cjs +3 -3
  20. package/dist/file-upload/hooks/use-file-upload-progress-callbacks.js +2 -3
  21. package/dist/file-upload/index.cjs +0 -1
  22. package/dist/file-upload/utils/create-placeholder-file.cjs +0 -1
  23. package/dist/file-upload/utils/get-file-key.cjs +0 -1
  24. package/dist/file-upload/utils/get-file-meta.cjs +0 -1
  25. package/dist/file-upload/utils/is-file-equal.cjs +0 -1
  26. package/dist/file-upload/utils/merge-file-metadata.cjs +0 -1
  27. package/dist/file-upload-inline/FileUploadInline.d.ts +2 -2
  28. package/dist/file-upload-inline/FileUploadInlineItem.cjs +1 -3
  29. package/dist/file-upload-inline/FileUploadInlineItem.js +2 -4
  30. package/dist/file-upload-inline/defaults.cjs +0 -1
  31. package/dist/file-upload-inline/index.cjs +0 -1
  32. package/dist/file-upload-inline/utils.cjs +0 -1
  33. package/dist/hooks/index.cjs +0 -1
  34. package/dist/icon-selector/IconPicker.cjs +1 -1
  35. package/dist/icon-selector/IconPicker.d.cts +0 -1
  36. package/dist/icon-selector/IconPicker.d.ts +0 -1
  37. package/dist/icon-selector/IconPicker.js +1 -1
  38. package/dist/icon-selector/constants.cjs +0 -1
  39. package/dist/icon-selector/index.cjs +0 -1
  40. package/dist/icon-selector/index.d.cts +2 -2
  41. package/dist/icon-selector/index.d.ts +2 -2
  42. package/dist/icon-selector/utils/is-valid-provider.cjs +0 -1
  43. package/dist/index.d.cts +2 -2
  44. package/dist/index.d.ts +2 -2
  45. package/dist/node_modules/.pnpm/clsx@2.1.1/node_modules/clsx/dist/clsx.cjs +0 -1
  46. package/dist/node_modules/.pnpm/tailwind-merge@3.4.0/node_modules/tailwind-merge/dist/bundle-mjs.cjs +0 -1
  47. package/dist/packages/shadcn/src/lib/utils.cjs +0 -1
  48. package/dist/pagination/index.cjs +0 -1
  49. package/dist/rich-text-editor/index.cjs +0 -1
  50. package/dist/spinner/index.cjs +0 -1
  51. package/dist/spinner/styles.cjs +0 -1
  52. package/dist/toast/AlertToast.js +2 -2
  53. package/dist/toast/index.cjs +0 -1
  54. package/package.json +4 -4
  55. package/dist/_virtual/rolldown_runtime.js +0 -43
  56. package/dist/node_modules/.pnpm/@diceui_shared@0.12.0_@floating-ui_react@0.27.16_react-dom@19.2.0_react@19.2.0__react@1_2c51ffe880f01dd537d5b6a13313daf4/node_modules/@diceui/shared/dist/index.cjs +0 -558
  57. package/dist/node_modules/.pnpm/@diceui_shared@0.12.0_@floating-ui_react@0.27.16_react-dom@19.2.0_react@19.2.0__react@1_2c51ffe880f01dd537d5b6a13313daf4/node_modules/@diceui/shared/dist/index.js +0 -555
  58. package/dist/node_modules/.pnpm/@diceui_tags-input@0.7.2_@floating-ui_react@0.27.16_react-dom@19.2.0_react@19.2.0__reac_e193dc2ff0d426ed009417f8d89778fd/node_modules/@diceui/tags-input/dist/index.cjs +0 -566
  59. package/dist/node_modules/.pnpm/@diceui_tags-input@0.7.2_@floating-ui_react@0.27.16_react-dom@19.2.0_react@19.2.0__reac_e193dc2ff0d426ed009417f8d89778fd/node_modules/@diceui/tags-input/dist/index.js +0 -565
  60. package/dist/node_modules/.pnpm/@floating-ui_core@1.7.3/node_modules/@floating-ui/core/dist/floating-ui.core.cjs +0 -695
  61. package/dist/node_modules/.pnpm/@floating-ui_core@1.7.3/node_modules/@floating-ui/core/dist/floating-ui.core.js +0 -679
  62. package/dist/node_modules/.pnpm/@floating-ui_dom@1.7.4/node_modules/@floating-ui/dom/dist/floating-ui.dom.cjs +0 -521
  63. package/dist/node_modules/.pnpm/@floating-ui_dom@1.7.4/node_modules/@floating-ui/dom/dist/floating-ui.dom.js +0 -503
  64. package/dist/node_modules/.pnpm/@floating-ui_react-dom@2.1.6_react-dom@19.2.0_react@19.2.0__react@19.2.0/node_modules/@floating-ui/react-dom/dist/floating-ui.react-dom.cjs +0 -282
  65. package/dist/node_modules/.pnpm/@floating-ui_react-dom@2.1.6_react-dom@19.2.0_react@19.2.0__react@19.2.0/node_modules/@floating-ui/react-dom/dist/floating-ui.react-dom.js +0 -266
  66. package/dist/node_modules/.pnpm/@floating-ui_react@0.27.16_react-dom@19.2.0_react@19.2.0__react@19.2.0/node_modules/@floating-ui/react/dist/floating-ui.react.esm.cjs +0 -3767
  67. package/dist/node_modules/.pnpm/@floating-ui_react@0.27.16_react-dom@19.2.0_react@19.2.0__react@19.2.0/node_modules/@floating-ui/react/dist/floating-ui.react.esm.js +0 -3747
  68. package/dist/node_modules/.pnpm/@floating-ui_react@0.27.16_react-dom@19.2.0_react@19.2.0__react@19.2.0/node_modules/@floating-ui/react/dist/floating-ui.react.utils.cjs +0 -426
  69. package/dist/node_modules/.pnpm/@floating-ui_react@0.27.16_react-dom@19.2.0_react@19.2.0__react@19.2.0/node_modules/@floating-ui/react/dist/floating-ui.react.utils.js +0 -379
  70. package/dist/node_modules/.pnpm/@floating-ui_utils@0.2.10/node_modules/@floating-ui/utils/dist/floating-ui.utils.cjs +0 -165
  71. package/dist/node_modules/.pnpm/@floating-ui_utils@0.2.10/node_modules/@floating-ui/utils/dist/floating-ui.utils.dom.cjs +0 -175
  72. package/dist/node_modules/.pnpm/@floating-ui_utils@0.2.10/node_modules/@floating-ui/utils/dist/floating-ui.utils.dom.js +0 -151
  73. package/dist/node_modules/.pnpm/@floating-ui_utils@0.2.10/node_modules/@floating-ui/utils/dist/floating-ui.utils.js +0 -138
  74. package/dist/node_modules/.pnpm/@radix-ui_primitive@1.1.3/node_modules/@radix-ui/primitive/dist/index.cjs +0 -13
  75. package/dist/node_modules/.pnpm/@radix-ui_primitive@1.1.3/node_modules/@radix-ui/primitive/dist/index.js +0 -11
  76. package/dist/node_modules/.pnpm/@radix-ui_react-compose-refs@1.1.2_@types_react@19.2.6_react@19.2.0/node_modules/@radix-ui/react-compose-refs/dist/index.cjs +0 -33
  77. package/dist/node_modules/.pnpm/@radix-ui_react-compose-refs@1.1.2_@types_react@19.2.6_react@19.2.0/node_modules/@radix-ui/react-compose-refs/dist/index.js +0 -30
  78. package/dist/node_modules/.pnpm/@radix-ui_react-context@1.1.2_@types_react@19.2.6_react@19.2.0/node_modules/@radix-ui/react-context/dist/index.cjs +0 -92
  79. package/dist/node_modules/.pnpm/@radix-ui_react-context@1.1.2_@types_react@19.2.6_react@19.2.0/node_modules/@radix-ui/react-context/dist/index.js +0 -88
  80. package/dist/node_modules/.pnpm/@radix-ui_react-dialog@1.1.15_@types_react-dom@19.2.3_@types_react@19.2.6__@types_react_4f1d9653b0e2175502748f45fd432185/node_modules/@radix-ui/react-dialog/dist/index.cjs +0 -310
  81. package/dist/node_modules/.pnpm/@radix-ui_react-dialog@1.1.15_@types_react-dom@19.2.3_@types_react@19.2.6__@types_react_4f1d9653b0e2175502748f45fd432185/node_modules/@radix-ui/react-dialog/dist/index.js +0 -299
  82. package/dist/node_modules/.pnpm/@radix-ui_react-dismissable-layer@1.1.11_@types_react-dom@19.2.3_@types_react@19.2.6__@_9ee1db7daf927866cf505b31d40047ad/node_modules/@radix-ui/react-dismissable-layer/dist/index.cjs +0 -190
  83. package/dist/node_modules/.pnpm/@radix-ui_react-dismissable-layer@1.1.11_@types_react-dom@19.2.3_@types_react@19.2.6__@_9ee1db7daf927866cf505b31d40047ad/node_modules/@radix-ui/react-dismissable-layer/dist/index.js +0 -187
  84. package/dist/node_modules/.pnpm/@radix-ui_react-focus-guards@1.1.3_@types_react@19.2.6_react@19.2.0/node_modules/@radix-ui/react-focus-guards/dist/index.cjs +0 -34
  85. package/dist/node_modules/.pnpm/@radix-ui_react-focus-guards@1.1.3_@types_react@19.2.6_react@19.2.0/node_modules/@radix-ui/react-focus-guards/dist/index.js +0 -32
  86. package/dist/node_modules/.pnpm/@radix-ui_react-focus-scope@1.1.7_@types_react-dom@19.2.3_@types_react@19.2.6__@types_r_0a31b7f987af9482d13505312e1a1be9/node_modules/@radix-ui/react-focus-scope/dist/index.cjs +0 -203
  87. package/dist/node_modules/.pnpm/@radix-ui_react-focus-scope@1.1.7_@types_react-dom@19.2.3_@types_react@19.2.6__@types_r_0a31b7f987af9482d13505312e1a1be9/node_modules/@radix-ui/react-focus-scope/dist/index.js +0 -200
  88. package/dist/node_modules/.pnpm/@radix-ui_react-id@1.1.1_@types_react@19.2.6_react@19.2.0/node_modules/@radix-ui/react-id/dist/index.cjs +0 -18
  89. package/dist/node_modules/.pnpm/@radix-ui_react-id@1.1.1_@types_react@19.2.6_react@19.2.0/node_modules/@radix-ui/react-id/dist/index.js +0 -16
  90. package/dist/node_modules/.pnpm/@radix-ui_react-portal@1.1.9_@types_react-dom@19.2.3_@types_react@19.2.6__@types_react@_1bb4e0f97f86496802d28a2e74e2a8b9/node_modules/@radix-ui/react-portal/dist/index.cjs +0 -29
  91. package/dist/node_modules/.pnpm/@radix-ui_react-portal@1.1.9_@types_react-dom@19.2.3_@types_react@19.2.6__@types_react@_1bb4e0f97f86496802d28a2e74e2a8b9/node_modules/@radix-ui/react-portal/dist/index.js +0 -25
  92. package/dist/node_modules/.pnpm/@radix-ui_react-presence@1.1.5_@types_react-dom@19.2.3_@types_react@19.2.6__@types_reac_90f8e5c12233caef3399d5fd66452a13/node_modules/@radix-ui/react-presence/dist/index.cjs +0 -110
  93. package/dist/node_modules/.pnpm/@radix-ui_react-presence@1.1.5_@types_react-dom@19.2.3_@types_react@19.2.6__@types_reac_90f8e5c12233caef3399d5fd66452a13/node_modules/@radix-ui/react-presence/dist/index.js +0 -108
  94. package/dist/node_modules/.pnpm/@radix-ui_react-primitive@2.1.3_@types_react-dom@19.2.3_@types_react@19.2.6__@types_rea_a92a69cb1cb39305138539e4fa72f596/node_modules/@radix-ui/react-primitive/dist/index.cjs +0 -52
  95. package/dist/node_modules/.pnpm/@radix-ui_react-primitive@2.1.3_@types_react-dom@19.2.3_@types_react@19.2.6__@types_rea_a92a69cb1cb39305138539e4fa72f596/node_modules/@radix-ui/react-primitive/dist/index.js +0 -47
  96. package/dist/node_modules/.pnpm/@radix-ui_react-slot@1.2.3_@types_react@19.2.6_react@19.2.0/node_modules/@radix-ui/react-slot/dist/index.cjs +0 -92
  97. package/dist/node_modules/.pnpm/@radix-ui_react-slot@1.2.3_@types_react@19.2.6_react@19.2.0/node_modules/@radix-ui/react-slot/dist/index.js +0 -89
  98. package/dist/node_modules/.pnpm/@radix-ui_react-slot@1.2.4_@types_react@19.2.6_react@19.2.0/node_modules/@radix-ui/react-slot/dist/index.cjs +0 -103
  99. package/dist/node_modules/.pnpm/@radix-ui_react-slot@1.2.4_@types_react@19.2.6_react@19.2.0/node_modules/@radix-ui/react-slot/dist/index.js +0 -100
  100. package/dist/node_modules/.pnpm/@radix-ui_react-use-callback-ref@1.1.1_@types_react@19.2.6_react@19.2.0/node_modules/@radix-ui/react-use-callback-ref/dist/index.cjs +0 -15
  101. package/dist/node_modules/.pnpm/@radix-ui_react-use-callback-ref@1.1.1_@types_react@19.2.6_react@19.2.0/node_modules/@radix-ui/react-use-callback-ref/dist/index.js +0 -13
  102. package/dist/node_modules/.pnpm/@radix-ui_react-use-controllable-state@1.2.2_@types_react@19.2.6_react@19.2.0/node_modules/@radix-ui/react-use-controllable-state/dist/index.cjs +0 -64
  103. package/dist/node_modules/.pnpm/@radix-ui_react-use-controllable-state@1.2.2_@types_react@19.2.6_react@19.2.0/node_modules/@radix-ui/react-use-controllable-state/dist/index.js +0 -62
  104. package/dist/node_modules/.pnpm/@radix-ui_react-use-escape-keydown@1.1.1_@types_react@19.2.6_react@19.2.0/node_modules/@radix-ui/react-use-escape-keydown/dist/index.cjs +0 -19
  105. package/dist/node_modules/.pnpm/@radix-ui_react-use-escape-keydown@1.1.1_@types_react@19.2.6_react@19.2.0/node_modules/@radix-ui/react-use-escape-keydown/dist/index.js +0 -17
  106. package/dist/node_modules/.pnpm/@radix-ui_react-use-layout-effect@1.1.1_@types_react@19.2.6_react@19.2.0/node_modules/@radix-ui/react-use-layout-effect/dist/index.cjs +0 -9
  107. package/dist/node_modules/.pnpm/@radix-ui_react-use-layout-effect@1.1.1_@types_react@19.2.6_react@19.2.0/node_modules/@radix-ui/react-use-layout-effect/dist/index.js +0 -7
  108. package/dist/node_modules/.pnpm/aria-hidden@1.2.6/node_modules/aria-hidden/dist/es2015/index.js +0 -108
  109. package/dist/node_modules/.pnpm/aria-hidden@1.2.6/node_modules/aria-hidden/dist/es5/index.cjs +0 -155
  110. package/dist/node_modules/.pnpm/detect-node-es@1.1.0/node_modules/detect-node-es/es5/node.cjs +0 -14
  111. package/dist/node_modules/.pnpm/get-nonce@1.0.1/node_modules/get-nonce/dist/es2015/index.js +0 -9
  112. package/dist/node_modules/.pnpm/get-nonce@1.0.1/node_modules/get-nonce/dist/es5/index.cjs +0 -22
  113. package/dist/node_modules/.pnpm/react-remove-scroll-bar@2.3.8_@types_react@19.2.6_react@19.2.0/node_modules/react-remove-scroll-bar/dist/es2015/component.js +0 -46
  114. package/dist/node_modules/.pnpm/react-remove-scroll-bar@2.3.8_@types_react@19.2.6_react@19.2.0/node_modules/react-remove-scroll-bar/dist/es2015/constants.js +0 -12
  115. package/dist/node_modules/.pnpm/react-remove-scroll-bar@2.3.8_@types_react@19.2.6_react@19.2.0/node_modules/react-remove-scroll-bar/dist/es2015/index.js +0 -3
  116. package/dist/node_modules/.pnpm/react-remove-scroll-bar@2.3.8_@types_react@19.2.6_react@19.2.0/node_modules/react-remove-scroll-bar/dist/es2015/utils.js +0 -37
  117. package/dist/node_modules/.pnpm/react-remove-scroll-bar@2.3.8_@types_react@19.2.6_react@19.2.0/node_modules/react-remove-scroll-bar/dist/es5/component.cjs +0 -61
  118. package/dist/node_modules/.pnpm/react-remove-scroll-bar@2.3.8_@types_react@19.2.6_react@19.2.0/node_modules/react-remove-scroll-bar/dist/es5/constants.cjs +0 -23
  119. package/dist/node_modules/.pnpm/react-remove-scroll-bar@2.3.8_@types_react@19.2.6_react@19.2.0/node_modules/react-remove-scroll-bar/dist/es5/index.cjs +0 -57
  120. package/dist/node_modules/.pnpm/react-remove-scroll-bar@2.3.8_@types_react@19.2.6_react@19.2.0/node_modules/react-remove-scroll-bar/dist/es5/utils.cjs +0 -49
  121. package/dist/node_modules/.pnpm/react-remove-scroll@2.7.1_@types_react@19.2.6_react@19.2.0/node_modules/react-remove-scroll/dist/es2015/Combination.js +0 -17
  122. package/dist/node_modules/.pnpm/react-remove-scroll@2.7.1_@types_react@19.2.6_react@19.2.0/node_modules/react-remove-scroll/dist/es2015/SideEffect.js +0 -163
  123. package/dist/node_modules/.pnpm/react-remove-scroll@2.7.1_@types_react@19.2.6_react@19.2.0/node_modules/react-remove-scroll/dist/es2015/UI.js +0 -64
  124. package/dist/node_modules/.pnpm/react-remove-scroll@2.7.1_@types_react@19.2.6_react@19.2.0/node_modules/react-remove-scroll/dist/es2015/aggresiveCapture.js +0 -16
  125. package/dist/node_modules/.pnpm/react-remove-scroll@2.7.1_@types_react@19.2.6_react@19.2.0/node_modules/react-remove-scroll/dist/es2015/handleScroll.js +0 -85
  126. package/dist/node_modules/.pnpm/react-remove-scroll@2.7.1_@types_react@19.2.6_react@19.2.0/node_modules/react-remove-scroll/dist/es2015/medium.js +0 -7
  127. package/dist/node_modules/.pnpm/react-remove-scroll@2.7.1_@types_react@19.2.6_react@19.2.0/node_modules/react-remove-scroll/dist/es2015/sidecar.js +0 -9
  128. package/dist/node_modules/.pnpm/react-remove-scroll@2.7.1_@types_react@19.2.6_react@19.2.0/node_modules/react-remove-scroll/dist/es5/Combination.cjs +0 -29
  129. package/dist/node_modules/.pnpm/react-remove-scroll@2.7.1_@types_react@19.2.6_react@19.2.0/node_modules/react-remove-scroll/dist/es5/SideEffect.cjs +0 -179
  130. package/dist/node_modules/.pnpm/react-remove-scroll@2.7.1_@types_react@19.2.6_react@19.2.0/node_modules/react-remove-scroll/dist/es5/UI.cjs +0 -79
  131. package/dist/node_modules/.pnpm/react-remove-scroll@2.7.1_@types_react@19.2.6_react@19.2.0/node_modules/react-remove-scroll/dist/es5/aggresiveCapture.cjs +0 -27
  132. package/dist/node_modules/.pnpm/react-remove-scroll@2.7.1_@types_react@19.2.6_react@19.2.0/node_modules/react-remove-scroll/dist/es5/handleScroll.cjs +0 -98
  133. package/dist/node_modules/.pnpm/react-remove-scroll@2.7.1_@types_react@19.2.6_react@19.2.0/node_modules/react-remove-scroll/dist/es5/index.cjs +0 -19
  134. package/dist/node_modules/.pnpm/react-remove-scroll@2.7.1_@types_react@19.2.6_react@19.2.0/node_modules/react-remove-scroll/dist/es5/medium.cjs +0 -18
  135. package/dist/node_modules/.pnpm/react-remove-scroll@2.7.1_@types_react@19.2.6_react@19.2.0/node_modules/react-remove-scroll/dist/es5/sidecar.cjs +0 -21
  136. package/dist/node_modules/.pnpm/react-style-singleton@2.2.3_@types_react@19.2.6_react@19.2.0/node_modules/react-style-singleton/dist/es2015/component.js +0 -21
  137. package/dist/node_modules/.pnpm/react-style-singleton@2.2.3_@types_react@19.2.6_react@19.2.0/node_modules/react-style-singleton/dist/es2015/hook.js +0 -27
  138. package/dist/node_modules/.pnpm/react-style-singleton@2.2.3_@types_react@19.2.6_react@19.2.0/node_modules/react-style-singleton/dist/es2015/index.js +0 -3
  139. package/dist/node_modules/.pnpm/react-style-singleton@2.2.3_@types_react@19.2.6_react@19.2.0/node_modules/react-style-singleton/dist/es2015/singleton.js +0 -43
  140. package/dist/node_modules/.pnpm/react-style-singleton@2.2.3_@types_react@19.2.6_react@19.2.0/node_modules/react-style-singleton/dist/es5/component.cjs +0 -33
  141. package/dist/node_modules/.pnpm/react-style-singleton@2.2.3_@types_react@19.2.6_react@19.2.0/node_modules/react-style-singleton/dist/es5/hook.cjs +0 -40
  142. package/dist/node_modules/.pnpm/react-style-singleton@2.2.3_@types_react@19.2.6_react@19.2.0/node_modules/react-style-singleton/dist/es5/index.cjs +0 -39
  143. package/dist/node_modules/.pnpm/react-style-singleton@2.2.3_@types_react@19.2.6_react@19.2.0/node_modules/react-style-singleton/dist/es5/singleton.cjs +0 -55
  144. package/dist/node_modules/.pnpm/tabbable@6.3.0/node_modules/tabbable/dist/index.cjs +0 -347
  145. package/dist/node_modules/.pnpm/tabbable@6.3.0/node_modules/tabbable/dist/index.esm.js +0 -268
  146. package/dist/node_modules/.pnpm/tslib@2.8.1/node_modules/tslib/tslib.es6.cjs +0 -557
  147. package/dist/node_modules/.pnpm/tslib@2.8.1/node_modules/tslib/tslib.es6.js +0 -31
  148. package/dist/node_modules/.pnpm/use-callback-ref@1.3.3_@types_react@19.2.6_react@19.2.0/node_modules/use-callback-ref/dist/es2015/assignRef.js +0 -22
  149. package/dist/node_modules/.pnpm/use-callback-ref@1.3.3_@types_react@19.2.6_react@19.2.0/node_modules/use-callback-ref/dist/es2015/useMergeRef.js +0 -47
  150. package/dist/node_modules/.pnpm/use-callback-ref@1.3.3_@types_react@19.2.6_react@19.2.0/node_modules/use-callback-ref/dist/es2015/useRef.js +0 -42
  151. package/dist/node_modules/.pnpm/use-callback-ref@1.3.3_@types_react@19.2.6_react@19.2.0/node_modules/use-callback-ref/dist/es5/assignRef.cjs +0 -34
  152. package/dist/node_modules/.pnpm/use-callback-ref@1.3.3_@types_react@19.2.6_react@19.2.0/node_modules/use-callback-ref/dist/es5/createRef.cjs +0 -39
  153. package/dist/node_modules/.pnpm/use-callback-ref@1.3.3_@types_react@19.2.6_react@19.2.0/node_modules/use-callback-ref/dist/es5/index.cjs +0 -85
  154. package/dist/node_modules/.pnpm/use-callback-ref@1.3.3_@types_react@19.2.6_react@19.2.0/node_modules/use-callback-ref/dist/es5/mergeRef.cjs +0 -40
  155. package/dist/node_modules/.pnpm/use-callback-ref@1.3.3_@types_react@19.2.6_react@19.2.0/node_modules/use-callback-ref/dist/es5/refToCallback.cjs +0 -59
  156. package/dist/node_modules/.pnpm/use-callback-ref@1.3.3_@types_react@19.2.6_react@19.2.0/node_modules/use-callback-ref/dist/es5/transformRef.cjs +0 -34
  157. package/dist/node_modules/.pnpm/use-callback-ref@1.3.3_@types_react@19.2.6_react@19.2.0/node_modules/use-callback-ref/dist/es5/useMergeRef.cjs +0 -61
  158. package/dist/node_modules/.pnpm/use-callback-ref@1.3.3_@types_react@19.2.6_react@19.2.0/node_modules/use-callback-ref/dist/es5/useRef.cjs +0 -53
  159. package/dist/node_modules/.pnpm/use-callback-ref@1.3.3_@types_react@19.2.6_react@19.2.0/node_modules/use-callback-ref/dist/es5/useTransformRef.cjs +0 -38
  160. package/dist/node_modules/.pnpm/use-sidecar@1.1.3_@types_react@19.2.6_react@19.2.0/node_modules/use-sidecar/dist/es2015/exports.js +0 -19
  161. package/dist/node_modules/.pnpm/use-sidecar@1.1.3_@types_react@19.2.6_react@19.2.0/node_modules/use-sidecar/dist/es2015/medium.js +0 -84
  162. package/dist/node_modules/.pnpm/use-sidecar@1.1.3_@types_react@19.2.6_react@19.2.0/node_modules/use-sidecar/dist/es5/config.cjs +0 -22
  163. package/dist/node_modules/.pnpm/use-sidecar@1.1.3_@types_react@19.2.6_react@19.2.0/node_modules/use-sidecar/dist/es5/env.cjs +0 -21
  164. package/dist/node_modules/.pnpm/use-sidecar@1.1.3_@types_react@19.2.6_react@19.2.0/node_modules/use-sidecar/dist/es5/exports.cjs +0 -31
  165. package/dist/node_modules/.pnpm/use-sidecar@1.1.3_@types_react@19.2.6_react@19.2.0/node_modules/use-sidecar/dist/es5/hoc.cjs +0 -31
  166. package/dist/node_modules/.pnpm/use-sidecar@1.1.3_@types_react@19.2.6_react@19.2.0/node_modules/use-sidecar/dist/es5/hook.cjs +0 -60
  167. package/dist/node_modules/.pnpm/use-sidecar@1.1.3_@types_react@19.2.6_react@19.2.0/node_modules/use-sidecar/dist/es5/index.cjs +0 -69
  168. package/dist/node_modules/.pnpm/use-sidecar@1.1.3_@types_react@19.2.6_react@19.2.0/node_modules/use-sidecar/dist/es5/medium.cjs +0 -101
  169. package/dist/node_modules/.pnpm/use-sidecar@1.1.3_@types_react@19.2.6_react@19.2.0/node_modules/use-sidecar/dist/es5/renderProp.cjs +0 -58
  170. package/dist/packages/shadcn/src/components/index.cjs +0 -6
  171. package/dist/packages/shadcn/src/components/index.js +0 -5
  172. package/dist/packages/shadcn/src/components/ui/OrContinueWithSeparator.cjs +0 -6
  173. package/dist/packages/shadcn/src/components/ui/OrContinueWithSeparator.js +0 -3
  174. package/dist/packages/shadcn/src/components/ui/alert-dialog.cjs +0 -10
  175. package/dist/packages/shadcn/src/components/ui/alert-dialog.js +0 -6
  176. package/dist/packages/shadcn/src/components/ui/alert.cjs +0 -44
  177. package/dist/packages/shadcn/src/components/ui/alert.js +0 -38
  178. package/dist/packages/shadcn/src/components/ui/avatar.cjs +0 -5
  179. package/dist/packages/shadcn/src/components/ui/avatar.js +0 -2
  180. package/dist/packages/shadcn/src/components/ui/badge.cjs +0 -20
  181. package/dist/packages/shadcn/src/components/ui/badge.js +0 -16
  182. package/dist/packages/shadcn/src/components/ui/button.cjs +0 -50
  183. package/dist/packages/shadcn/src/components/ui/button.js +0 -45
  184. package/dist/packages/shadcn/src/components/ui/calendar.cjs +0 -8
  185. package/dist/packages/shadcn/src/components/ui/calendar.js +0 -4
  186. package/dist/packages/shadcn/src/components/ui/card.cjs +0 -5
  187. package/dist/packages/shadcn/src/components/ui/card.js +0 -2
  188. package/dist/packages/shadcn/src/components/ui/checkbox.cjs +0 -10
  189. package/dist/packages/shadcn/src/components/ui/checkbox.js +0 -6
  190. package/dist/packages/shadcn/src/components/ui/command.cjs +0 -11
  191. package/dist/packages/shadcn/src/components/ui/command.js +0 -7
  192. package/dist/packages/shadcn/src/components/ui/dialog.cjs +0 -93
  193. package/dist/packages/shadcn/src/components/ui/dialog.js +0 -81
  194. package/dist/packages/shadcn/src/components/ui/dropdown-menu.cjs +0 -7
  195. package/dist/packages/shadcn/src/components/ui/dropdown-menu.js +0 -3
  196. package/dist/packages/shadcn/src/components/ui/file-upload.cjs +0 -49
  197. package/dist/packages/shadcn/src/components/ui/file-upload.js +0 -45
  198. package/dist/packages/shadcn/src/components/ui/form.cjs +0 -12
  199. package/dist/packages/shadcn/src/components/ui/form.js +0 -9
  200. package/dist/packages/shadcn/src/components/ui/index.cjs +0 -30
  201. package/dist/packages/shadcn/src/components/ui/index.js +0 -29
  202. package/dist/packages/shadcn/src/components/ui/input.cjs +0 -5
  203. package/dist/packages/shadcn/src/components/ui/input.js +0 -2
  204. package/dist/packages/shadcn/src/components/ui/label.cjs +0 -5
  205. package/dist/packages/shadcn/src/components/ui/label.js +0 -2
  206. package/dist/packages/shadcn/src/components/ui/pagination.cjs +0 -9
  207. package/dist/packages/shadcn/src/components/ui/pagination.js +0 -4
  208. package/dist/packages/shadcn/src/components/ui/popover.cjs +0 -5
  209. package/dist/packages/shadcn/src/components/ui/popover.js +0 -2
  210. package/dist/packages/shadcn/src/components/ui/radio-group.cjs +0 -7
  211. package/dist/packages/shadcn/src/components/ui/radio-group.js +0 -3
  212. package/dist/packages/shadcn/src/components/ui/select.cjs +0 -10
  213. package/dist/packages/shadcn/src/components/ui/select.js +0 -6
  214. package/dist/packages/shadcn/src/components/ui/separator.cjs +0 -5
  215. package/dist/packages/shadcn/src/components/ui/separator.js +0 -2
  216. package/dist/packages/shadcn/src/components/ui/shadcn-io/tags/index.cjs +0 -26
  217. package/dist/packages/shadcn/src/components/ui/shadcn-io/tags/index.js +0 -22
  218. package/dist/packages/shadcn/src/components/ui/shadcn-io/tags-input-inline/index.cjs +0 -6
  219. package/dist/packages/shadcn/src/components/ui/shadcn-io/tags-input-inline/index.js +0 -3
  220. package/dist/packages/shadcn/src/components/ui/sheet.cjs +0 -7
  221. package/dist/packages/shadcn/src/components/ui/sheet.js +0 -3
  222. package/dist/packages/shadcn/src/components/ui/slider.cjs +0 -5
  223. package/dist/packages/shadcn/src/components/ui/slider.js +0 -2
  224. package/dist/packages/shadcn/src/components/ui/switch.cjs +0 -8
  225. package/dist/packages/shadcn/src/components/ui/switch.js +0 -5
  226. package/dist/packages/shadcn/src/components/ui/tabs.cjs +0 -5
  227. package/dist/packages/shadcn/src/components/ui/tabs.js +0 -2
  228. package/dist/packages/shadcn/src/components/ui/textarea.cjs +0 -5
  229. package/dist/packages/shadcn/src/components/ui/textarea.js +0 -2
  230. package/dist/packages/shadcn/src/components/ui/tooltip.cjs +0 -5
  231. package/dist/packages/shadcn/src/components/ui/tooltip.js +0 -2
@@ -1,3767 +0,0 @@
1
- const require_rolldown_runtime = require('../../../../../../../_virtual/rolldown_runtime.cjs');
2
- const require_floating_ui_utils = require('../../../../../@floating-ui_utils@0.2.10/node_modules/@floating-ui/utils/dist/floating-ui.utils.cjs');
3
- const require_floating_ui_utils_dom = require('../../../../../@floating-ui_utils@0.2.10/node_modules/@floating-ui/utils/dist/floating-ui.utils.dom.cjs');
4
- const require_floating_ui_dom = require('../../../../../@floating-ui_dom@1.7.4/node_modules/@floating-ui/dom/dist/floating-ui.dom.cjs');
5
- const require_floating_ui_react_dom = require('../../../../../@floating-ui_react-dom@2.1.6_react-dom@19.2.0_react@19.2.0__react@19.2.0/node_modules/@floating-ui/react-dom/dist/floating-ui.react-dom.cjs');
6
- const require_index = require('../../../../../tabbable@6.3.0/node_modules/tabbable/dist/index.cjs');
7
- const require_floating_ui_react_utils = require('./floating-ui.react.utils.cjs');
8
- let react = require("react");
9
- react = require_rolldown_runtime.__toESM(react);
10
- let react_jsx_runtime = require("react/jsx-runtime");
11
- react_jsx_runtime = require_rolldown_runtime.__toESM(react_jsx_runtime);
12
- let react_dom = require("react-dom");
13
- react_dom = require_rolldown_runtime.__toESM(react_dom);
14
-
15
- //#region ../../node_modules/.pnpm/@floating-ui+react@0.27.16_react-dom@19.2.0_react@19.2.0__react@19.2.0/node_modules/@floating-ui/react/dist/floating-ui.react.esm.js
16
- var floating_ui_react_esm_exports = /* @__PURE__ */ require_rolldown_runtime.__export({
17
- Composite: () => Composite,
18
- CompositeItem: () => CompositeItem,
19
- FloatingArrow: () => FloatingArrow,
20
- FloatingDelayGroup: () => FloatingDelayGroup,
21
- FloatingFocusManager: () => FloatingFocusManager,
22
- FloatingList: () => FloatingList,
23
- FloatingNode: () => FloatingNode,
24
- FloatingOverlay: () => FloatingOverlay,
25
- FloatingPortal: () => FloatingPortal,
26
- FloatingTree: () => FloatingTree,
27
- NextFloatingDelayGroup: () => NextFloatingDelayGroup,
28
- arrow: () => require_floating_ui_react_dom.arrow,
29
- autoPlacement: () => require_floating_ui_react_dom.autoPlacement,
30
- autoUpdate: () => require_floating_ui_dom.autoUpdate,
31
- computePosition: () => require_floating_ui_dom.computePosition,
32
- detectOverflow: () => require_floating_ui_dom.detectOverflow,
33
- flip: () => require_floating_ui_react_dom.flip,
34
- getOverflowAncestors: () => require_floating_ui_utils_dom.getOverflowAncestors,
35
- hide: () => require_floating_ui_react_dom.hide,
36
- inline: () => require_floating_ui_react_dom.inline,
37
- inner: () => inner,
38
- limitShift: () => require_floating_ui_react_dom.limitShift,
39
- offset: () => require_floating_ui_react_dom.offset,
40
- platform: () => require_floating_ui_dom.platform,
41
- safePolygon: () => safePolygon,
42
- shift: () => require_floating_ui_react_dom.shift,
43
- size: () => require_floating_ui_react_dom.size,
44
- useClick: () => useClick,
45
- useClientPoint: () => useClientPoint,
46
- useDelayGroup: () => useDelayGroup,
47
- useDelayGroupContext: () => useDelayGroupContext,
48
- useDismiss: () => useDismiss,
49
- useFloating: () => useFloating$1,
50
- useFloatingNodeId: () => useFloatingNodeId,
51
- useFloatingParentNodeId: () => useFloatingParentNodeId,
52
- useFloatingPortalNode: () => useFloatingPortalNode,
53
- useFloatingRootContext: () => useFloatingRootContext,
54
- useFloatingTree: () => useFloatingTree,
55
- useFocus: () => useFocus,
56
- useHover: () => useHover,
57
- useId: () => useId,
58
- useInnerOffset: () => useInnerOffset,
59
- useInteractions: () => useInteractions,
60
- useListItem: () => useListItem,
61
- useListNavigation: () => useListNavigation,
62
- useMergeRefs: () => useMergeRefs,
63
- useNextDelayGroup: () => useNextDelayGroup,
64
- useRole: () => useRole,
65
- useTransitionStatus: () => useTransitionStatus,
66
- useTransitionStyles: () => useTransitionStyles,
67
- useTypeahead: () => useTypeahead
68
- });
69
- /**
70
- * Merges an array of refs into a single memoized callback ref or `null`.
71
- * @see https://floating-ui.com/docs/react-utils#usemergerefs
72
- */
73
- function useMergeRefs(refs) {
74
- const cleanupRef = react.useRef(void 0);
75
- const refEffect = react.useCallback((instance) => {
76
- const cleanups = refs.map((ref) => {
77
- if (ref == null) return;
78
- if (typeof ref === "function") {
79
- const refCallback = ref;
80
- const refCleanup = refCallback(instance);
81
- return typeof refCleanup === "function" ? refCleanup : () => {
82
- refCallback(null);
83
- };
84
- }
85
- ref.current = instance;
86
- return () => {
87
- ref.current = null;
88
- };
89
- });
90
- return () => {
91
- cleanups.forEach((refCleanup) => refCleanup == null ? void 0 : refCleanup());
92
- };
93
- }, refs);
94
- return react.useMemo(() => {
95
- if (refs.every((ref) => ref == null)) return null;
96
- return (value) => {
97
- if (cleanupRef.current) {
98
- cleanupRef.current();
99
- cleanupRef.current = void 0;
100
- }
101
- if (value != null) cleanupRef.current = refEffect(value);
102
- };
103
- }, refs);
104
- }
105
- function sortByDocumentPosition(a, b) {
106
- const position = a.compareDocumentPosition(b);
107
- if (position & Node.DOCUMENT_POSITION_FOLLOWING || position & Node.DOCUMENT_POSITION_CONTAINED_BY) return -1;
108
- if (position & Node.DOCUMENT_POSITION_PRECEDING || position & Node.DOCUMENT_POSITION_CONTAINS) return 1;
109
- return 0;
110
- }
111
- /**
112
- * Provides context for a list of items within the floating element.
113
- * @see https://floating-ui.com/docs/FloatingList
114
- */
115
- function FloatingList(props) {
116
- const { children, elementsRef, labelsRef } = props;
117
- const [nodes, setNodes] = react.useState(() => /* @__PURE__ */ new Set());
118
- const register = react.useCallback((node) => {
119
- setNodes((prevSet) => new Set(prevSet).add(node));
120
- }, []);
121
- const unregister = react.useCallback((node) => {
122
- setNodes((prevSet) => {
123
- const set = new Set(prevSet);
124
- set.delete(node);
125
- return set;
126
- });
127
- }, []);
128
- const map = react.useMemo(() => {
129
- const newMap = /* @__PURE__ */ new Map();
130
- Array.from(nodes.keys()).sort(sortByDocumentPosition).forEach((node, index$1) => {
131
- newMap.set(node, index$1);
132
- });
133
- return newMap;
134
- }, [nodes]);
135
- return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(FloatingListContext.Provider, {
136
- value: react.useMemo(() => ({
137
- register,
138
- unregister,
139
- map,
140
- elementsRef,
141
- labelsRef
142
- }), [
143
- register,
144
- unregister,
145
- map,
146
- elementsRef,
147
- labelsRef
148
- ]),
149
- children
150
- });
151
- }
152
- /**
153
- * Used to register a list item and its index (DOM position) in the
154
- * `FloatingList`.
155
- * @see https://floating-ui.com/docs/FloatingList#uselistitem
156
- */
157
- function useListItem(props) {
158
- if (props === void 0) props = {};
159
- const { label } = props;
160
- const { register, unregister, map, elementsRef, labelsRef } = react.useContext(FloatingListContext);
161
- const [index$1, setIndex] = react.useState(null);
162
- const componentRef = react.useRef(null);
163
- const ref = react.useCallback((node) => {
164
- componentRef.current = node;
165
- if (index$1 !== null) {
166
- elementsRef.current[index$1] = node;
167
- if (labelsRef) {
168
- var _node$textContent;
169
- const isLabelDefined = label !== void 0;
170
- labelsRef.current[index$1] = isLabelDefined ? label : (_node$textContent = node == null ? void 0 : node.textContent) != null ? _node$textContent : null;
171
- }
172
- }
173
- }, [
174
- index$1,
175
- elementsRef,
176
- labelsRef,
177
- label
178
- ]);
179
- require_floating_ui_react_utils.index(() => {
180
- const node = componentRef.current;
181
- if (node) {
182
- register(node);
183
- return () => {
184
- unregister(node);
185
- };
186
- }
187
- }, [register, unregister]);
188
- require_floating_ui_react_utils.index(() => {
189
- const index$2 = componentRef.current ? map.get(componentRef.current) : null;
190
- if (index$2 != null) setIndex(index$2);
191
- }, [map]);
192
- return react.useMemo(() => ({
193
- ref,
194
- index: index$1 == null ? -1 : index$1
195
- }), [index$1, ref]);
196
- }
197
- function renderJsx(render, computedProps) {
198
- if (typeof render === "function") return render(computedProps);
199
- if (render) return /* @__PURE__ */ react.cloneElement(render, computedProps);
200
- return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", { ...computedProps });
201
- }
202
- function useFloatingId() {
203
- const [id, setId] = react.useState(() => serverHandoffComplete ? genId() : void 0);
204
- require_floating_ui_react_utils.index(() => {
205
- if (id == null) setId(genId());
206
- }, []);
207
- react.useEffect(() => {
208
- serverHandoffComplete = true;
209
- }, []);
210
- return id;
211
- }
212
- function warn() {
213
- var _devMessageSet;
214
- for (var _len = arguments.length, messages = new Array(_len), _key = 0; _key < _len; _key++) messages[_key] = arguments[_key];
215
- const message = "Floating UI: " + messages.join(" ");
216
- if (!((_devMessageSet = devMessageSet) != null && _devMessageSet.has(message))) {
217
- var _devMessageSet2;
218
- (_devMessageSet2 = devMessageSet) == null || _devMessageSet2.add(message);
219
- console.warn(message);
220
- }
221
- }
222
- function error() {
223
- var _devMessageSet3;
224
- for (var _len2 = arguments.length, messages = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) messages[_key2] = arguments[_key2];
225
- const message = "Floating UI: " + messages.join(" ");
226
- if (!((_devMessageSet3 = devMessageSet) != null && _devMessageSet3.has(message))) {
227
- var _devMessageSet4;
228
- (_devMessageSet4 = devMessageSet) == null || _devMessageSet4.add(message);
229
- console.error(message);
230
- }
231
- }
232
- function createEventEmitter() {
233
- const map = /* @__PURE__ */ new Map();
234
- return {
235
- emit(event, data) {
236
- var _map$get;
237
- (_map$get = map.get(event)) == null || _map$get.forEach((listener) => listener(data));
238
- },
239
- on(event, listener) {
240
- if (!map.has(event)) map.set(event, /* @__PURE__ */ new Set());
241
- map.get(event).add(listener);
242
- },
243
- off(event, listener) {
244
- var _map$get2;
245
- (_map$get2 = map.get(event)) == null || _map$get2.delete(listener);
246
- }
247
- };
248
- }
249
- /**
250
- * Registers a node into the `FloatingTree`, returning its id.
251
- * @see https://floating-ui.com/docs/FloatingTree
252
- */
253
- function useFloatingNodeId(customParentId) {
254
- const id = useId();
255
- const tree = useFloatingTree();
256
- const reactParentId = useFloatingParentNodeId();
257
- const parentId = customParentId || reactParentId;
258
- require_floating_ui_react_utils.index(() => {
259
- if (!id) return;
260
- const node = {
261
- id,
262
- parentId
263
- };
264
- tree?.addNode(node);
265
- return () => {
266
- tree?.removeNode(node);
267
- };
268
- }, [
269
- tree,
270
- id,
271
- parentId
272
- ]);
273
- return id;
274
- }
275
- /**
276
- * Provides parent node context for nested floating elements.
277
- * @see https://floating-ui.com/docs/FloatingTree
278
- */
279
- function FloatingNode(props) {
280
- const { children, id } = props;
281
- const parentId = useFloatingParentNodeId();
282
- return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(FloatingNodeContext.Provider, {
283
- value: react.useMemo(() => ({
284
- id,
285
- parentId
286
- }), [id, parentId]),
287
- children
288
- });
289
- }
290
- /**
291
- * Provides context for nested floating elements when they are not children of
292
- * each other on the DOM.
293
- * This is not necessary in all cases, except when there must be explicit communication between parent and child floating elements. It is necessary for:
294
- * - The `bubbles` option in the `useDismiss()` Hook
295
- * - Nested virtual list navigation
296
- * - Nested floating elements that each open on hover
297
- * - Custom communication between parent and child floating elements
298
- * @see https://floating-ui.com/docs/FloatingTree
299
- */
300
- function FloatingTree(props) {
301
- const { children } = props;
302
- const nodesRef = react.useRef([]);
303
- const addNode = react.useCallback((node) => {
304
- nodesRef.current = [...nodesRef.current, node];
305
- }, []);
306
- const removeNode = react.useCallback((node) => {
307
- nodesRef.current = nodesRef.current.filter((n) => n !== node);
308
- }, []);
309
- const [events] = react.useState(() => createEventEmitter());
310
- return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(FloatingTreeContext.Provider, {
311
- value: react.useMemo(() => ({
312
- nodesRef,
313
- addNode,
314
- removeNode,
315
- events
316
- }), [
317
- addNode,
318
- removeNode,
319
- events
320
- ]),
321
- children
322
- });
323
- }
324
- function createAttribute(name) {
325
- return "data-floating-ui-" + name;
326
- }
327
- function clearTimeoutIfSet(timeoutRef) {
328
- if (timeoutRef.current !== -1) {
329
- clearTimeout(timeoutRef.current);
330
- timeoutRef.current = -1;
331
- }
332
- }
333
- function getDelay(value, prop, pointerType) {
334
- if (pointerType && !require_floating_ui_react_utils.isMouseLikePointerType(pointerType)) return 0;
335
- if (typeof value === "number") return value;
336
- if (typeof value === "function") {
337
- const result = value();
338
- if (typeof result === "number") return result;
339
- return result == null ? void 0 : result[prop];
340
- }
341
- return value == null ? void 0 : value[prop];
342
- }
343
- function getRestMs(value) {
344
- if (typeof value === "function") return value();
345
- return value;
346
- }
347
- /**
348
- * Opens the floating element while hovering over the reference element, like
349
- * CSS `:hover`.
350
- * @see https://floating-ui.com/docs/useHover
351
- */
352
- function useHover(context, props) {
353
- if (props === void 0) props = {};
354
- const { open, onOpenChange, dataRef, events, elements } = context;
355
- const { enabled = true, delay = 0, handleClose = null, mouseOnly = false, restMs = 0, move = true } = props;
356
- const tree = useFloatingTree();
357
- const parentId = useFloatingParentNodeId();
358
- const handleCloseRef = require_floating_ui_react_utils.useLatestRef(handleClose);
359
- const delayRef = require_floating_ui_react_utils.useLatestRef(delay);
360
- const openRef = require_floating_ui_react_utils.useLatestRef(open);
361
- const restMsRef = require_floating_ui_react_utils.useLatestRef(restMs);
362
- const pointerTypeRef = react.useRef();
363
- const timeoutRef = react.useRef(-1);
364
- const handlerRef = react.useRef();
365
- const restTimeoutRef = react.useRef(-1);
366
- const blockMouseMoveRef = react.useRef(true);
367
- const performedPointerEventsMutationRef = react.useRef(false);
368
- const unbindMouseMoveRef = react.useRef(() => {});
369
- const restTimeoutPendingRef = react.useRef(false);
370
- const isHoverOpen = require_floating_ui_react_utils.useEffectEvent(() => {
371
- var _dataRef$current$open;
372
- const type = (_dataRef$current$open = dataRef.current.openEvent) == null ? void 0 : _dataRef$current$open.type;
373
- return (type == null ? void 0 : type.includes("mouse")) && type !== "mousedown";
374
- });
375
- react.useEffect(() => {
376
- if (!enabled) return;
377
- function onOpenChange$1(_ref) {
378
- let { open: open$1 } = _ref;
379
- if (!open$1) {
380
- clearTimeoutIfSet(timeoutRef);
381
- clearTimeoutIfSet(restTimeoutRef);
382
- blockMouseMoveRef.current = true;
383
- restTimeoutPendingRef.current = false;
384
- }
385
- }
386
- events.on("openchange", onOpenChange$1);
387
- return () => {
388
- events.off("openchange", onOpenChange$1);
389
- };
390
- }, [enabled, events]);
391
- react.useEffect(() => {
392
- if (!enabled) return;
393
- if (!handleCloseRef.current) return;
394
- if (!open) return;
395
- function onLeave(event) {
396
- if (isHoverOpen()) onOpenChange(false, event, "hover");
397
- }
398
- const html = require_floating_ui_react_utils.getDocument(elements.floating).documentElement;
399
- html.addEventListener("mouseleave", onLeave);
400
- return () => {
401
- html.removeEventListener("mouseleave", onLeave);
402
- };
403
- }, [
404
- elements.floating,
405
- open,
406
- onOpenChange,
407
- enabled,
408
- handleCloseRef,
409
- isHoverOpen
410
- ]);
411
- const closeWithDelay = react.useCallback(function(event, runElseBranch, reason) {
412
- if (runElseBranch === void 0) runElseBranch = true;
413
- if (reason === void 0) reason = "hover";
414
- const closeDelay = getDelay(delayRef.current, "close", pointerTypeRef.current);
415
- if (closeDelay && !handlerRef.current) {
416
- clearTimeoutIfSet(timeoutRef);
417
- timeoutRef.current = window.setTimeout(() => onOpenChange(false, event, reason), closeDelay);
418
- } else if (runElseBranch) {
419
- clearTimeoutIfSet(timeoutRef);
420
- onOpenChange(false, event, reason);
421
- }
422
- }, [delayRef, onOpenChange]);
423
- const cleanupMouseMoveHandler = require_floating_ui_react_utils.useEffectEvent(() => {
424
- unbindMouseMoveRef.current();
425
- handlerRef.current = void 0;
426
- });
427
- const clearPointerEvents = require_floating_ui_react_utils.useEffectEvent(() => {
428
- if (performedPointerEventsMutationRef.current) {
429
- const body = require_floating_ui_react_utils.getDocument(elements.floating).body;
430
- body.style.pointerEvents = "";
431
- body.removeAttribute(safePolygonIdentifier);
432
- performedPointerEventsMutationRef.current = false;
433
- }
434
- });
435
- const isClickLikeOpenEvent = require_floating_ui_react_utils.useEffectEvent(() => {
436
- return dataRef.current.openEvent ? ["click", "mousedown"].includes(dataRef.current.openEvent.type) : false;
437
- });
438
- react.useEffect(() => {
439
- if (!enabled) return;
440
- function onReferenceMouseEnter(event) {
441
- clearTimeoutIfSet(timeoutRef);
442
- blockMouseMoveRef.current = false;
443
- if (mouseOnly && !require_floating_ui_react_utils.isMouseLikePointerType(pointerTypeRef.current) || getRestMs(restMsRef.current) > 0 && !getDelay(delayRef.current, "open")) return;
444
- const openDelay = getDelay(delayRef.current, "open", pointerTypeRef.current);
445
- if (openDelay) timeoutRef.current = window.setTimeout(() => {
446
- if (!openRef.current) onOpenChange(true, event, "hover");
447
- }, openDelay);
448
- else if (!open) onOpenChange(true, event, "hover");
449
- }
450
- function onReferenceMouseLeave(event) {
451
- if (isClickLikeOpenEvent()) {
452
- clearPointerEvents();
453
- return;
454
- }
455
- unbindMouseMoveRef.current();
456
- const doc = require_floating_ui_react_utils.getDocument(elements.floating);
457
- clearTimeoutIfSet(restTimeoutRef);
458
- restTimeoutPendingRef.current = false;
459
- if (handleCloseRef.current && dataRef.current.floatingContext) {
460
- if (!open) clearTimeoutIfSet(timeoutRef);
461
- handlerRef.current = handleCloseRef.current({
462
- ...dataRef.current.floatingContext,
463
- tree,
464
- x: event.clientX,
465
- y: event.clientY,
466
- onClose() {
467
- clearPointerEvents();
468
- cleanupMouseMoveHandler();
469
- if (!isClickLikeOpenEvent()) closeWithDelay(event, true, "safe-polygon");
470
- }
471
- });
472
- const handler = handlerRef.current;
473
- doc.addEventListener("mousemove", handler);
474
- unbindMouseMoveRef.current = () => {
475
- doc.removeEventListener("mousemove", handler);
476
- };
477
- return;
478
- }
479
- if (pointerTypeRef.current === "touch" ? !require_floating_ui_react_utils.contains(elements.floating, event.relatedTarget) : true) closeWithDelay(event);
480
- }
481
- function onScrollMouseLeave(event) {
482
- if (isClickLikeOpenEvent()) return;
483
- if (!dataRef.current.floatingContext) return;
484
- handleCloseRef.current == null || handleCloseRef.current({
485
- ...dataRef.current.floatingContext,
486
- tree,
487
- x: event.clientX,
488
- y: event.clientY,
489
- onClose() {
490
- clearPointerEvents();
491
- cleanupMouseMoveHandler();
492
- if (!isClickLikeOpenEvent()) closeWithDelay(event);
493
- }
494
- })(event);
495
- }
496
- function onFloatingMouseEnter() {
497
- clearTimeoutIfSet(timeoutRef);
498
- }
499
- function onFloatingMouseLeave(event) {
500
- if (!isClickLikeOpenEvent()) closeWithDelay(event, false);
501
- }
502
- if (require_floating_ui_utils_dom.isElement(elements.domReference)) {
503
- const reference$1 = elements.domReference;
504
- const floating = elements.floating;
505
- if (open) reference$1.addEventListener("mouseleave", onScrollMouseLeave);
506
- if (move) reference$1.addEventListener("mousemove", onReferenceMouseEnter, { once: true });
507
- reference$1.addEventListener("mouseenter", onReferenceMouseEnter);
508
- reference$1.addEventListener("mouseleave", onReferenceMouseLeave);
509
- if (floating) {
510
- floating.addEventListener("mouseleave", onScrollMouseLeave);
511
- floating.addEventListener("mouseenter", onFloatingMouseEnter);
512
- floating.addEventListener("mouseleave", onFloatingMouseLeave);
513
- }
514
- return () => {
515
- if (open) reference$1.removeEventListener("mouseleave", onScrollMouseLeave);
516
- if (move) reference$1.removeEventListener("mousemove", onReferenceMouseEnter);
517
- reference$1.removeEventListener("mouseenter", onReferenceMouseEnter);
518
- reference$1.removeEventListener("mouseleave", onReferenceMouseLeave);
519
- if (floating) {
520
- floating.removeEventListener("mouseleave", onScrollMouseLeave);
521
- floating.removeEventListener("mouseenter", onFloatingMouseEnter);
522
- floating.removeEventListener("mouseleave", onFloatingMouseLeave);
523
- }
524
- };
525
- }
526
- }, [
527
- elements,
528
- enabled,
529
- context,
530
- mouseOnly,
531
- move,
532
- closeWithDelay,
533
- cleanupMouseMoveHandler,
534
- clearPointerEvents,
535
- onOpenChange,
536
- open,
537
- openRef,
538
- tree,
539
- delayRef,
540
- handleCloseRef,
541
- dataRef,
542
- isClickLikeOpenEvent,
543
- restMsRef
544
- ]);
545
- require_floating_ui_react_utils.index(() => {
546
- var _handleCloseRef$curre;
547
- if (!enabled) return;
548
- if (open && (_handleCloseRef$curre = handleCloseRef.current) != null && (_handleCloseRef$curre = _handleCloseRef$curre.__options) != null && _handleCloseRef$curre.blockPointerEvents && isHoverOpen()) {
549
- performedPointerEventsMutationRef.current = true;
550
- const floatingEl = elements.floating;
551
- if (require_floating_ui_utils_dom.isElement(elements.domReference) && floatingEl) {
552
- var _tree$nodesRef$curren;
553
- const body = require_floating_ui_react_utils.getDocument(elements.floating).body;
554
- body.setAttribute(safePolygonIdentifier, "");
555
- const ref = elements.domReference;
556
- const parentFloating = tree == null || (_tree$nodesRef$curren = tree.nodesRef.current.find((node) => node.id === parentId)) == null || (_tree$nodesRef$curren = _tree$nodesRef$curren.context) == null ? void 0 : _tree$nodesRef$curren.elements.floating;
557
- if (parentFloating) parentFloating.style.pointerEvents = "";
558
- body.style.pointerEvents = "none";
559
- ref.style.pointerEvents = "auto";
560
- floatingEl.style.pointerEvents = "auto";
561
- return () => {
562
- body.style.pointerEvents = "";
563
- ref.style.pointerEvents = "";
564
- floatingEl.style.pointerEvents = "";
565
- };
566
- }
567
- }
568
- }, [
569
- enabled,
570
- open,
571
- parentId,
572
- elements,
573
- tree,
574
- handleCloseRef,
575
- isHoverOpen
576
- ]);
577
- require_floating_ui_react_utils.index(() => {
578
- if (!open) {
579
- pointerTypeRef.current = void 0;
580
- restTimeoutPendingRef.current = false;
581
- cleanupMouseMoveHandler();
582
- clearPointerEvents();
583
- }
584
- }, [
585
- open,
586
- cleanupMouseMoveHandler,
587
- clearPointerEvents
588
- ]);
589
- react.useEffect(() => {
590
- return () => {
591
- cleanupMouseMoveHandler();
592
- clearTimeoutIfSet(timeoutRef);
593
- clearTimeoutIfSet(restTimeoutRef);
594
- clearPointerEvents();
595
- };
596
- }, [
597
- enabled,
598
- elements.domReference,
599
- cleanupMouseMoveHandler,
600
- clearPointerEvents
601
- ]);
602
- const reference = react.useMemo(() => {
603
- function setPointerRef(event) {
604
- pointerTypeRef.current = event.pointerType;
605
- }
606
- return {
607
- onPointerDown: setPointerRef,
608
- onPointerEnter: setPointerRef,
609
- onMouseMove(event) {
610
- const { nativeEvent } = event;
611
- function handleMouseMove() {
612
- if (!blockMouseMoveRef.current && !openRef.current) onOpenChange(true, nativeEvent, "hover");
613
- }
614
- if (mouseOnly && !require_floating_ui_react_utils.isMouseLikePointerType(pointerTypeRef.current)) return;
615
- if (open || getRestMs(restMsRef.current) === 0) return;
616
- if (restTimeoutPendingRef.current && event.movementX ** 2 + event.movementY ** 2 < 2) return;
617
- clearTimeoutIfSet(restTimeoutRef);
618
- if (pointerTypeRef.current === "touch") handleMouseMove();
619
- else {
620
- restTimeoutPendingRef.current = true;
621
- restTimeoutRef.current = window.setTimeout(handleMouseMove, getRestMs(restMsRef.current));
622
- }
623
- }
624
- };
625
- }, [
626
- mouseOnly,
627
- onOpenChange,
628
- open,
629
- openRef,
630
- restMsRef
631
- ]);
632
- return react.useMemo(() => enabled ? { reference } : {}, [enabled, reference]);
633
- }
634
- /**
635
- * Provides context for a group of floating elements that should share a
636
- * `delay`.
637
- * @see https://floating-ui.com/docs/FloatingDelayGroup
638
- */
639
- function FloatingDelayGroup(props) {
640
- const { children, delay, timeoutMs = 0 } = props;
641
- const [state, setState] = react.useReducer((prev, next) => ({
642
- ...prev,
643
- ...next
644
- }), {
645
- delay,
646
- timeoutMs,
647
- initialDelay: delay,
648
- currentId: null,
649
- isInstantPhase: false
650
- });
651
- const initialCurrentIdRef = react.useRef(null);
652
- const setCurrentId = react.useCallback((currentId) => {
653
- setState({ currentId });
654
- }, []);
655
- require_floating_ui_react_utils.index(() => {
656
- if (state.currentId) {
657
- if (initialCurrentIdRef.current === null) initialCurrentIdRef.current = state.currentId;
658
- else if (!state.isInstantPhase) setState({ isInstantPhase: true });
659
- } else {
660
- if (state.isInstantPhase) setState({ isInstantPhase: false });
661
- initialCurrentIdRef.current = null;
662
- }
663
- }, [state.currentId, state.isInstantPhase]);
664
- return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(FloatingDelayGroupContext.Provider, {
665
- value: react.useMemo(() => ({
666
- ...state,
667
- setState,
668
- setCurrentId
669
- }), [state, setCurrentId]),
670
- children
671
- });
672
- }
673
- /**
674
- * Enables grouping when called inside a component that's a child of a
675
- * `FloatingDelayGroup`.
676
- * @see https://floating-ui.com/docs/FloatingDelayGroup
677
- */
678
- function useDelayGroup(context, options) {
679
- if (options === void 0) options = {};
680
- const { open, onOpenChange, floatingId } = context;
681
- const { id: optionId, enabled = true } = options;
682
- const id = optionId != null ? optionId : floatingId;
683
- const groupContext = useDelayGroupContext();
684
- const { currentId, setCurrentId, initialDelay, setState, timeoutMs } = groupContext;
685
- require_floating_ui_react_utils.index(() => {
686
- if (!enabled) return;
687
- if (!currentId) return;
688
- setState({ delay: {
689
- open: 1,
690
- close: getDelay(initialDelay, "close")
691
- } });
692
- if (currentId !== id) onOpenChange(false);
693
- }, [
694
- enabled,
695
- id,
696
- onOpenChange,
697
- setState,
698
- currentId,
699
- initialDelay
700
- ]);
701
- require_floating_ui_react_utils.index(() => {
702
- function unset() {
703
- onOpenChange(false);
704
- setState({
705
- delay: initialDelay,
706
- currentId: null
707
- });
708
- }
709
- if (!enabled) return;
710
- if (!currentId) return;
711
- if (!open && currentId === id) {
712
- if (timeoutMs) {
713
- const timeout = window.setTimeout(unset, timeoutMs);
714
- return () => {
715
- clearTimeout(timeout);
716
- };
717
- }
718
- unset();
719
- }
720
- }, [
721
- enabled,
722
- open,
723
- setState,
724
- currentId,
725
- id,
726
- onOpenChange,
727
- initialDelay,
728
- timeoutMs
729
- ]);
730
- require_floating_ui_react_utils.index(() => {
731
- if (!enabled) return;
732
- if (setCurrentId === NOOP || !open) return;
733
- setCurrentId(id);
734
- }, [
735
- enabled,
736
- open,
737
- setCurrentId,
738
- id
739
- ]);
740
- return groupContext;
741
- }
742
- /**
743
- * Experimental next version of `FloatingDelayGroup` to become the default
744
- * in the future. This component is not yet stable.
745
- * Provides context for a group of floating elements that should share a
746
- * `delay`. Unlike `FloatingDelayGroup`, `useNextDelayGroup` with this
747
- * component does not cause a re-render of unrelated consumers of the
748
- * context when the delay changes.
749
- * @see https://floating-ui.com/docs/FloatingDelayGroup
750
- */
751
- function NextFloatingDelayGroup(props) {
752
- const { children, delay, timeoutMs = 0 } = props;
753
- const delayRef = react.useRef(delay);
754
- const initialDelayRef = react.useRef(delay);
755
- const currentIdRef = react.useRef(null);
756
- const currentContextRef = react.useRef(null);
757
- const timeoutIdRef = react.useRef(-1);
758
- return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(NextFloatingDelayGroupContext.Provider, {
759
- value: react.useMemo(() => ({
760
- hasProvider: true,
761
- delayRef,
762
- initialDelayRef,
763
- currentIdRef,
764
- timeoutMs,
765
- currentContextRef,
766
- timeoutIdRef
767
- }), [timeoutMs]),
768
- children
769
- });
770
- }
771
- /**
772
- * Enables grouping when called inside a component that's a child of a
773
- * `NextFloatingDelayGroup`.
774
- * @see https://floating-ui.com/docs/FloatingDelayGroup
775
- */
776
- function useNextDelayGroup(context, options) {
777
- if (options === void 0) options = {};
778
- const { open, onOpenChange, floatingId } = context;
779
- const { enabled = true } = options;
780
- const { currentIdRef, delayRef, timeoutMs, initialDelayRef, currentContextRef, hasProvider, timeoutIdRef } = react.useContext(NextFloatingDelayGroupContext);
781
- const [isInstantPhase, setIsInstantPhase] = react.useState(false);
782
- require_floating_ui_react_utils.index(() => {
783
- function unset() {
784
- var _currentContextRef$cu;
785
- setIsInstantPhase(false);
786
- (_currentContextRef$cu = currentContextRef.current) == null || _currentContextRef$cu.setIsInstantPhase(false);
787
- currentIdRef.current = null;
788
- currentContextRef.current = null;
789
- delayRef.current = initialDelayRef.current;
790
- }
791
- if (!enabled) return;
792
- if (!currentIdRef.current) return;
793
- if (!open && currentIdRef.current === floatingId) {
794
- setIsInstantPhase(false);
795
- if (timeoutMs) {
796
- timeoutIdRef.current = window.setTimeout(unset, timeoutMs);
797
- return () => {
798
- clearTimeout(timeoutIdRef.current);
799
- };
800
- }
801
- unset();
802
- }
803
- }, [
804
- enabled,
805
- open,
806
- floatingId,
807
- currentIdRef,
808
- delayRef,
809
- timeoutMs,
810
- initialDelayRef,
811
- currentContextRef,
812
- timeoutIdRef
813
- ]);
814
- require_floating_ui_react_utils.index(() => {
815
- if (!enabled) return;
816
- if (!open) return;
817
- const prevContext = currentContextRef.current;
818
- const prevId = currentIdRef.current;
819
- currentContextRef.current = {
820
- onOpenChange,
821
- setIsInstantPhase
822
- };
823
- currentIdRef.current = floatingId;
824
- delayRef.current = {
825
- open: 0,
826
- close: getDelay(initialDelayRef.current, "close")
827
- };
828
- if (prevId !== null && prevId !== floatingId) {
829
- clearTimeoutIfSet(timeoutIdRef);
830
- setIsInstantPhase(true);
831
- prevContext?.setIsInstantPhase(true);
832
- prevContext?.onOpenChange(false);
833
- } else {
834
- setIsInstantPhase(false);
835
- prevContext?.setIsInstantPhase(false);
836
- }
837
- }, [
838
- enabled,
839
- open,
840
- floatingId,
841
- onOpenChange,
842
- currentIdRef,
843
- delayRef,
844
- timeoutMs,
845
- initialDelayRef,
846
- currentContextRef,
847
- timeoutIdRef
848
- ]);
849
- require_floating_ui_react_utils.index(() => {
850
- return () => {
851
- currentContextRef.current = null;
852
- };
853
- }, [currentContextRef]);
854
- return react.useMemo(() => ({
855
- hasProvider,
856
- delayRef,
857
- isInstantPhase
858
- }), [
859
- hasProvider,
860
- delayRef,
861
- isInstantPhase
862
- ]);
863
- }
864
- function enqueueFocus(el, options) {
865
- if (options === void 0) options = {};
866
- const { preventScroll = false, cancelPrevious = true, sync = false } = options;
867
- cancelPrevious && cancelAnimationFrame(rafId);
868
- const exec = () => el == null ? void 0 : el.focus({ preventScroll });
869
- if (sync) exec();
870
- else rafId = requestAnimationFrame(exec);
871
- }
872
- function contains$1(parent, child) {
873
- if (!parent || !child) return false;
874
- const rootNode = child.getRootNode == null ? void 0 : child.getRootNode();
875
- if (parent.contains(child)) return true;
876
- if (rootNode && require_floating_ui_utils_dom.isShadowRoot(rootNode)) {
877
- let next = child;
878
- while (next) {
879
- if (parent === next) return true;
880
- next = next.parentNode || next.host;
881
- }
882
- }
883
- return false;
884
- }
885
- function getTarget$1(event) {
886
- if ("composedPath" in event) return event.composedPath()[0];
887
- return event.target;
888
- }
889
- function getDocument$1(node) {
890
- return (node == null ? void 0 : node.ownerDocument) || document;
891
- }
892
- function getCounterMap(control) {
893
- if (control === "inert") return counters.inert;
894
- if (control === "aria-hidden") return counters["aria-hidden"];
895
- return counters.none;
896
- }
897
- function applyAttributeToOthers(uncorrectedAvoidElements, body, ariaHidden, inert) {
898
- const markerName = "data-floating-ui-inert";
899
- const controlAttribute = inert ? "inert" : ariaHidden ? "aria-hidden" : null;
900
- const avoidElements = correctElements(body, uncorrectedAvoidElements);
901
- const elementsToKeep = /* @__PURE__ */ new Set();
902
- const elementsToStop = new Set(avoidElements);
903
- const hiddenElements = [];
904
- if (!markerMap[markerName]) markerMap[markerName] = /* @__PURE__ */ new WeakMap();
905
- const markerCounter = markerMap[markerName];
906
- avoidElements.forEach(keep);
907
- deep(body);
908
- elementsToKeep.clear();
909
- function keep(el) {
910
- if (!el || elementsToKeep.has(el)) return;
911
- elementsToKeep.add(el);
912
- el.parentNode && keep(el.parentNode);
913
- }
914
- function deep(parent) {
915
- if (!parent || elementsToStop.has(parent)) return;
916
- [].forEach.call(parent.children, (node) => {
917
- if (require_floating_ui_utils_dom.getNodeName(node) === "script") return;
918
- if (elementsToKeep.has(node)) deep(node);
919
- else {
920
- const attr$1 = controlAttribute ? node.getAttribute(controlAttribute) : null;
921
- const alreadyHidden = attr$1 !== null && attr$1 !== "false";
922
- const counterMap = getCounterMap(controlAttribute);
923
- const counterValue = (counterMap.get(node) || 0) + 1;
924
- const markerValue = (markerCounter.get(node) || 0) + 1;
925
- counterMap.set(node, counterValue);
926
- markerCounter.set(node, markerValue);
927
- hiddenElements.push(node);
928
- if (counterValue === 1 && alreadyHidden) uncontrolledElementsSet.add(node);
929
- if (markerValue === 1) node.setAttribute(markerName, "");
930
- if (!alreadyHidden && controlAttribute) node.setAttribute(controlAttribute, controlAttribute === "inert" ? "" : "true");
931
- }
932
- });
933
- }
934
- lockCount$1++;
935
- return () => {
936
- hiddenElements.forEach((element) => {
937
- const counterMap = getCounterMap(controlAttribute);
938
- const counterValue = (counterMap.get(element) || 0) - 1;
939
- const markerValue = (markerCounter.get(element) || 0) - 1;
940
- counterMap.set(element, counterValue);
941
- markerCounter.set(element, markerValue);
942
- if (!counterValue) {
943
- if (!uncontrolledElementsSet.has(element) && controlAttribute) element.removeAttribute(controlAttribute);
944
- uncontrolledElementsSet.delete(element);
945
- }
946
- if (!markerValue) element.removeAttribute(markerName);
947
- });
948
- lockCount$1--;
949
- if (!lockCount$1) {
950
- counters.inert = /* @__PURE__ */ new WeakMap();
951
- counters["aria-hidden"] = /* @__PURE__ */ new WeakMap();
952
- counters.none = /* @__PURE__ */ new WeakMap();
953
- uncontrolledElementsSet = /* @__PURE__ */ new WeakSet();
954
- markerMap = {};
955
- }
956
- };
957
- }
958
- function markOthers(avoidElements, ariaHidden, inert) {
959
- if (ariaHidden === void 0) ariaHidden = false;
960
- if (inert === void 0) inert = false;
961
- const body = getDocument$1(avoidElements[0]).body;
962
- return applyAttributeToOthers(avoidElements.concat(Array.from(body.querySelectorAll("[aria-live],[role=\"status\"],output"))), body, ariaHidden, inert);
963
- }
964
- /**
965
- * @see https://floating-ui.com/docs/FloatingPortal#usefloatingportalnode
966
- */
967
- function useFloatingPortalNode(props) {
968
- if (props === void 0) props = {};
969
- const { id, root } = props;
970
- const uniqueId = useId();
971
- const portalContext = usePortalContext();
972
- const [portalNode, setPortalNode] = react.useState(null);
973
- const portalNodeRef = react.useRef(null);
974
- require_floating_ui_react_utils.index(() => {
975
- return () => {
976
- portalNode?.remove();
977
- queueMicrotask(() => {
978
- portalNodeRef.current = null;
979
- });
980
- };
981
- }, [portalNode]);
982
- require_floating_ui_react_utils.index(() => {
983
- if (!uniqueId) return;
984
- if (portalNodeRef.current) return;
985
- const existingIdRoot = id ? document.getElementById(id) : null;
986
- if (!existingIdRoot) return;
987
- const subRoot = document.createElement("div");
988
- subRoot.id = uniqueId;
989
- subRoot.setAttribute(attr, "");
990
- existingIdRoot.appendChild(subRoot);
991
- portalNodeRef.current = subRoot;
992
- setPortalNode(subRoot);
993
- }, [id, uniqueId]);
994
- require_floating_ui_react_utils.index(() => {
995
- if (root === null) return;
996
- if (!uniqueId) return;
997
- if (portalNodeRef.current) return;
998
- let container = root || (portalContext == null ? void 0 : portalContext.portalNode);
999
- if (container && !require_floating_ui_utils_dom.isNode(container)) container = container.current;
1000
- container = container || document.body;
1001
- let idWrapper = null;
1002
- if (id) {
1003
- idWrapper = document.createElement("div");
1004
- idWrapper.id = id;
1005
- container.appendChild(idWrapper);
1006
- }
1007
- const subRoot = document.createElement("div");
1008
- subRoot.id = uniqueId;
1009
- subRoot.setAttribute(attr, "");
1010
- container = idWrapper || container;
1011
- container.appendChild(subRoot);
1012
- portalNodeRef.current = subRoot;
1013
- setPortalNode(subRoot);
1014
- }, [
1015
- id,
1016
- root,
1017
- uniqueId,
1018
- portalContext
1019
- ]);
1020
- return portalNode;
1021
- }
1022
- /**
1023
- * Portals the floating element into a given container element — by default,
1024
- * outside of the app root and into the body.
1025
- * This is necessary to ensure the floating element can appear outside any
1026
- * potential parent containers that cause clipping (such as `overflow: hidden`),
1027
- * while retaining its location in the React tree.
1028
- * @see https://floating-ui.com/docs/FloatingPortal
1029
- */
1030
- function FloatingPortal(props) {
1031
- const { children, id, root, preserveTabOrder = true } = props;
1032
- const portalNode = useFloatingPortalNode({
1033
- id,
1034
- root
1035
- });
1036
- const [focusManagerState, setFocusManagerState] = react.useState(null);
1037
- const beforeOutsideRef = react.useRef(null);
1038
- const afterOutsideRef = react.useRef(null);
1039
- const beforeInsideRef = react.useRef(null);
1040
- const afterInsideRef = react.useRef(null);
1041
- const modal = focusManagerState == null ? void 0 : focusManagerState.modal;
1042
- const open = focusManagerState == null ? void 0 : focusManagerState.open;
1043
- const shouldRenderGuards = !!focusManagerState && !focusManagerState.modal && focusManagerState.open && preserveTabOrder && !!(root || portalNode);
1044
- react.useEffect(() => {
1045
- if (!portalNode || !preserveTabOrder || modal) return;
1046
- function onFocus(event) {
1047
- if (portalNode && require_floating_ui_react_utils.isOutsideEvent(event)) (event.type === "focusin" ? require_floating_ui_react_utils.enableFocusInside : require_floating_ui_react_utils.disableFocusInside)(portalNode);
1048
- }
1049
- portalNode.addEventListener("focusin", onFocus, true);
1050
- portalNode.addEventListener("focusout", onFocus, true);
1051
- return () => {
1052
- portalNode.removeEventListener("focusin", onFocus, true);
1053
- portalNode.removeEventListener("focusout", onFocus, true);
1054
- };
1055
- }, [
1056
- portalNode,
1057
- preserveTabOrder,
1058
- modal
1059
- ]);
1060
- react.useEffect(() => {
1061
- if (!portalNode) return;
1062
- if (open) return;
1063
- require_floating_ui_react_utils.enableFocusInside(portalNode);
1064
- }, [open, portalNode]);
1065
- return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(PortalContext.Provider, {
1066
- value: react.useMemo(() => ({
1067
- preserveTabOrder,
1068
- beforeOutsideRef,
1069
- afterOutsideRef,
1070
- beforeInsideRef,
1071
- afterInsideRef,
1072
- portalNode,
1073
- setFocusManagerState
1074
- }), [preserveTabOrder, portalNode]),
1075
- children: [
1076
- shouldRenderGuards && portalNode && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(FocusGuard, {
1077
- "data-type": "outside",
1078
- ref: beforeOutsideRef,
1079
- onFocus: (event) => {
1080
- if (require_floating_ui_react_utils.isOutsideEvent(event, portalNode)) {
1081
- var _beforeInsideRef$curr;
1082
- (_beforeInsideRef$curr = beforeInsideRef.current) == null || _beforeInsideRef$curr.focus();
1083
- } else require_floating_ui_react_utils.getPreviousTabbable(focusManagerState ? focusManagerState.domReference : null)?.focus();
1084
- }
1085
- }),
1086
- shouldRenderGuards && portalNode && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
1087
- "aria-owns": portalNode.id,
1088
- style: HIDDEN_STYLES
1089
- }),
1090
- portalNode && /* @__PURE__ */ react_dom.createPortal(children, portalNode),
1091
- shouldRenderGuards && portalNode && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(FocusGuard, {
1092
- "data-type": "outside",
1093
- ref: afterOutsideRef,
1094
- onFocus: (event) => {
1095
- if (require_floating_ui_react_utils.isOutsideEvent(event, portalNode)) {
1096
- var _afterInsideRef$curre;
1097
- (_afterInsideRef$curre = afterInsideRef.current) == null || _afterInsideRef$curre.focus();
1098
- } else {
1099
- require_floating_ui_react_utils.getNextTabbable(focusManagerState ? focusManagerState.domReference : null)?.focus();
1100
- focusManagerState != null && focusManagerState.closeOnFocusOut && focusManagerState?.onOpenChange(false, event.nativeEvent, "focus-out");
1101
- }
1102
- }
1103
- })
1104
- ]
1105
- });
1106
- }
1107
- function useLiteMergeRefs(refs) {
1108
- return react.useMemo(() => {
1109
- return (value) => {
1110
- refs.forEach((ref) => {
1111
- if (ref) ref.current = value;
1112
- });
1113
- };
1114
- }, refs);
1115
- }
1116
- function clearDisconnectedPreviouslyFocusedElements() {
1117
- previouslyFocusedElements = previouslyFocusedElements.filter((el) => el.isConnected);
1118
- }
1119
- function addPreviouslyFocusedElement(element) {
1120
- clearDisconnectedPreviouslyFocusedElements();
1121
- if (element && require_floating_ui_utils_dom.getNodeName(element) !== "body") {
1122
- previouslyFocusedElements.push(element);
1123
- if (previouslyFocusedElements.length > LIST_LIMIT) previouslyFocusedElements = previouslyFocusedElements.slice(-20);
1124
- }
1125
- }
1126
- function getPreviouslyFocusedElement() {
1127
- clearDisconnectedPreviouslyFocusedElements();
1128
- return previouslyFocusedElements[previouslyFocusedElements.length - 1];
1129
- }
1130
- function getFirstTabbableElement(container) {
1131
- const tabbableOptions = require_floating_ui_react_utils.getTabbableOptions();
1132
- if ((0, import_dist.isTabbable)(container, tabbableOptions)) return container;
1133
- return (0, import_dist.tabbable)(container, tabbableOptions)[0] || container;
1134
- }
1135
- function handleTabIndex(floatingFocusElement, orderRef) {
1136
- var _floatingFocusElement;
1137
- if (!orderRef.current.includes("floating") && !((_floatingFocusElement = floatingFocusElement.getAttribute("role")) != null && _floatingFocusElement.includes("dialog"))) return;
1138
- const options = require_floating_ui_react_utils.getTabbableOptions();
1139
- const tabbableContent = (0, import_dist.focusable)(floatingFocusElement, options).filter((element) => {
1140
- const dataTabIndex = element.getAttribute("data-tabindex") || "";
1141
- return (0, import_dist.isTabbable)(element, options) || element.hasAttribute("data-tabindex") && !dataTabIndex.startsWith("-");
1142
- });
1143
- const tabIndex = floatingFocusElement.getAttribute("tabindex");
1144
- if (orderRef.current.includes("floating") || tabbableContent.length === 0) {
1145
- if (tabIndex !== "0") floatingFocusElement.setAttribute("tabindex", "0");
1146
- } else if (tabIndex !== "-1" || floatingFocusElement.hasAttribute("data-tabindex") && floatingFocusElement.getAttribute("data-tabindex") !== "-1") {
1147
- floatingFocusElement.setAttribute("tabindex", "-1");
1148
- floatingFocusElement.setAttribute("data-tabindex", "-1");
1149
- }
1150
- }
1151
- /**
1152
- * Provides focus management for the floating element.
1153
- * @see https://floating-ui.com/docs/FloatingFocusManager
1154
- */
1155
- function FloatingFocusManager(props) {
1156
- const { context, children, disabled = false, order = ["content"], guards: _guards = true, initialFocus = 0, returnFocus = true, restoreFocus = false, modal = true, visuallyHiddenDismiss = false, closeOnFocusOut = true, outsideElementsInert = false, getInsideElements: _getInsideElements = () => [] } = props;
1157
- const { open, onOpenChange, events, dataRef, elements: { domReference, floating } } = context;
1158
- const getNodeId = require_floating_ui_react_utils.useEffectEvent(() => {
1159
- var _dataRef$current$floa;
1160
- return (_dataRef$current$floa = dataRef.current.floatingContext) == null ? void 0 : _dataRef$current$floa.nodeId;
1161
- });
1162
- const getInsideElements = require_floating_ui_react_utils.useEffectEvent(_getInsideElements);
1163
- const ignoreInitialFocus = typeof initialFocus === "number" && initialFocus < 0;
1164
- const isUntrappedTypeableCombobox = require_floating_ui_react_utils.isTypeableCombobox(domReference) && ignoreInitialFocus;
1165
- const inertSupported = supportsInert();
1166
- const guards = inertSupported ? _guards : true;
1167
- const useInert = !guards || inertSupported && outsideElementsInert;
1168
- const orderRef = require_floating_ui_react_utils.useLatestRef(order);
1169
- const initialFocusRef = require_floating_ui_react_utils.useLatestRef(initialFocus);
1170
- const returnFocusRef = require_floating_ui_react_utils.useLatestRef(returnFocus);
1171
- const tree = useFloatingTree();
1172
- const portalContext = usePortalContext();
1173
- const startDismissButtonRef = react.useRef(null);
1174
- const endDismissButtonRef = react.useRef(null);
1175
- const preventReturnFocusRef = react.useRef(false);
1176
- const isPointerDownRef = react.useRef(false);
1177
- const tabbableIndexRef = react.useRef(-1);
1178
- const blurTimeoutRef = react.useRef(-1);
1179
- const isInsidePortal = portalContext != null;
1180
- const floatingFocusElement = require_floating_ui_react_utils.getFloatingFocusElement(floating);
1181
- const getTabbableContent = require_floating_ui_react_utils.useEffectEvent(function(container) {
1182
- if (container === void 0) container = floatingFocusElement;
1183
- return container ? (0, import_dist.tabbable)(container, require_floating_ui_react_utils.getTabbableOptions()) : [];
1184
- });
1185
- const getTabbableElements = require_floating_ui_react_utils.useEffectEvent((container) => {
1186
- const content = getTabbableContent(container);
1187
- return orderRef.current.map((type) => {
1188
- if (domReference && type === "reference") return domReference;
1189
- if (floatingFocusElement && type === "floating") return floatingFocusElement;
1190
- return content;
1191
- }).filter(Boolean).flat();
1192
- });
1193
- react.useEffect(() => {
1194
- if (disabled) return;
1195
- if (!modal) return;
1196
- function onKeyDown(event) {
1197
- if (event.key === "Tab") {
1198
- if (require_floating_ui_react_utils.contains(floatingFocusElement, require_floating_ui_react_utils.activeElement(require_floating_ui_react_utils.getDocument(floatingFocusElement))) && getTabbableContent().length === 0 && !isUntrappedTypeableCombobox) require_floating_ui_react_utils.stopEvent(event);
1199
- const els = getTabbableElements();
1200
- const target = require_floating_ui_react_utils.getTarget(event);
1201
- if (orderRef.current[0] === "reference" && target === domReference) {
1202
- require_floating_ui_react_utils.stopEvent(event);
1203
- if (event.shiftKey) enqueueFocus(els[els.length - 1]);
1204
- else enqueueFocus(els[1]);
1205
- }
1206
- if (orderRef.current[1] === "floating" && target === floatingFocusElement && event.shiftKey) {
1207
- require_floating_ui_react_utils.stopEvent(event);
1208
- enqueueFocus(els[0]);
1209
- }
1210
- }
1211
- }
1212
- const doc = require_floating_ui_react_utils.getDocument(floatingFocusElement);
1213
- doc.addEventListener("keydown", onKeyDown);
1214
- return () => {
1215
- doc.removeEventListener("keydown", onKeyDown);
1216
- };
1217
- }, [
1218
- disabled,
1219
- domReference,
1220
- floatingFocusElement,
1221
- modal,
1222
- orderRef,
1223
- isUntrappedTypeableCombobox,
1224
- getTabbableContent,
1225
- getTabbableElements
1226
- ]);
1227
- react.useEffect(() => {
1228
- if (disabled) return;
1229
- if (!floating) return;
1230
- function handleFocusIn(event) {
1231
- const target = require_floating_ui_react_utils.getTarget(event);
1232
- const tabbableIndex = getTabbableContent().indexOf(target);
1233
- if (tabbableIndex !== -1) tabbableIndexRef.current = tabbableIndex;
1234
- }
1235
- floating.addEventListener("focusin", handleFocusIn);
1236
- return () => {
1237
- floating.removeEventListener("focusin", handleFocusIn);
1238
- };
1239
- }, [
1240
- disabled,
1241
- floating,
1242
- getTabbableContent
1243
- ]);
1244
- react.useEffect(() => {
1245
- if (disabled) return;
1246
- if (!closeOnFocusOut) return;
1247
- function handlePointerDown() {
1248
- isPointerDownRef.current = true;
1249
- setTimeout(() => {
1250
- isPointerDownRef.current = false;
1251
- });
1252
- }
1253
- function handleFocusOutside(event) {
1254
- const relatedTarget = event.relatedTarget;
1255
- const currentTarget = event.currentTarget;
1256
- const target = require_floating_ui_react_utils.getTarget(event);
1257
- queueMicrotask(() => {
1258
- const nodeId = getNodeId();
1259
- const movedToUnrelatedNode = !(require_floating_ui_react_utils.contains(domReference, relatedTarget) || require_floating_ui_react_utils.contains(floating, relatedTarget) || require_floating_ui_react_utils.contains(relatedTarget, floating) || require_floating_ui_react_utils.contains(portalContext == null ? void 0 : portalContext.portalNode, relatedTarget) || relatedTarget != null && relatedTarget.hasAttribute(createAttribute("focus-guard")) || tree && (require_floating_ui_react_utils.getNodeChildren(tree.nodesRef.current, nodeId).find((node) => {
1260
- var _node$context, _node$context2;
1261
- return require_floating_ui_react_utils.contains((_node$context = node.context) == null ? void 0 : _node$context.elements.floating, relatedTarget) || require_floating_ui_react_utils.contains((_node$context2 = node.context) == null ? void 0 : _node$context2.elements.domReference, relatedTarget);
1262
- }) || require_floating_ui_react_utils.getNodeAncestors(tree.nodesRef.current, nodeId).find((node) => {
1263
- var _node$context3, _node$context4, _node$context5;
1264
- return [(_node$context3 = node.context) == null ? void 0 : _node$context3.elements.floating, require_floating_ui_react_utils.getFloatingFocusElement((_node$context4 = node.context) == null ? void 0 : _node$context4.elements.floating)].includes(relatedTarget) || ((_node$context5 = node.context) == null ? void 0 : _node$context5.elements.domReference) === relatedTarget;
1265
- })));
1266
- if (currentTarget === domReference && floatingFocusElement) handleTabIndex(floatingFocusElement, orderRef);
1267
- if (restoreFocus && currentTarget !== domReference && !(target != null && target.isConnected) && require_floating_ui_react_utils.activeElement(require_floating_ui_react_utils.getDocument(floatingFocusElement)) === require_floating_ui_react_utils.getDocument(floatingFocusElement).body) {
1268
- if (require_floating_ui_utils_dom.isHTMLElement(floatingFocusElement)) floatingFocusElement.focus();
1269
- const prevTabbableIndex = tabbableIndexRef.current;
1270
- const tabbableContent = getTabbableContent();
1271
- const nodeToFocus = tabbableContent[prevTabbableIndex] || tabbableContent[tabbableContent.length - 1] || floatingFocusElement;
1272
- if (require_floating_ui_utils_dom.isHTMLElement(nodeToFocus)) nodeToFocus.focus();
1273
- }
1274
- if (dataRef.current.insideReactTree) {
1275
- dataRef.current.insideReactTree = false;
1276
- return;
1277
- }
1278
- if ((isUntrappedTypeableCombobox ? true : !modal) && relatedTarget && movedToUnrelatedNode && !isPointerDownRef.current && relatedTarget !== getPreviouslyFocusedElement()) {
1279
- preventReturnFocusRef.current = true;
1280
- onOpenChange(false, event, "focus-out");
1281
- }
1282
- });
1283
- }
1284
- const shouldHandleBlurCapture = Boolean(!tree && portalContext);
1285
- function markInsideReactTree() {
1286
- clearTimeoutIfSet(blurTimeoutRef);
1287
- dataRef.current.insideReactTree = true;
1288
- blurTimeoutRef.current = window.setTimeout(() => {
1289
- dataRef.current.insideReactTree = false;
1290
- });
1291
- }
1292
- if (floating && require_floating_ui_utils_dom.isHTMLElement(domReference)) {
1293
- domReference.addEventListener("focusout", handleFocusOutside);
1294
- domReference.addEventListener("pointerdown", handlePointerDown);
1295
- floating.addEventListener("focusout", handleFocusOutside);
1296
- if (shouldHandleBlurCapture) floating.addEventListener("focusout", markInsideReactTree, true);
1297
- return () => {
1298
- domReference.removeEventListener("focusout", handleFocusOutside);
1299
- domReference.removeEventListener("pointerdown", handlePointerDown);
1300
- floating.removeEventListener("focusout", handleFocusOutside);
1301
- if (shouldHandleBlurCapture) floating.removeEventListener("focusout", markInsideReactTree, true);
1302
- };
1303
- }
1304
- }, [
1305
- disabled,
1306
- domReference,
1307
- floating,
1308
- floatingFocusElement,
1309
- modal,
1310
- tree,
1311
- portalContext,
1312
- onOpenChange,
1313
- closeOnFocusOut,
1314
- restoreFocus,
1315
- getTabbableContent,
1316
- isUntrappedTypeableCombobox,
1317
- getNodeId,
1318
- orderRef,
1319
- dataRef
1320
- ]);
1321
- const beforeGuardRef = react.useRef(null);
1322
- const afterGuardRef = react.useRef(null);
1323
- const mergedBeforeGuardRef = useLiteMergeRefs([beforeGuardRef, portalContext == null ? void 0 : portalContext.beforeInsideRef]);
1324
- const mergedAfterGuardRef = useLiteMergeRefs([afterGuardRef, portalContext == null ? void 0 : portalContext.afterInsideRef]);
1325
- react.useEffect(() => {
1326
- var _portalContext$portal, _ancestors$find;
1327
- if (disabled) return;
1328
- if (!floating) return;
1329
- const portalNodes = Array.from((portalContext == null || (_portalContext$portal = portalContext.portalNode) == null ? void 0 : _portalContext$portal.querySelectorAll("[" + createAttribute("portal") + "]")) || []);
1330
- const insideElements = [
1331
- floating,
1332
- (_ancestors$find = (tree ? require_floating_ui_react_utils.getNodeAncestors(tree.nodesRef.current, getNodeId()) : []).find((node) => {
1333
- var _node$context6;
1334
- return require_floating_ui_react_utils.isTypeableCombobox(((_node$context6 = node.context) == null ? void 0 : _node$context6.elements.domReference) || null);
1335
- })) == null || (_ancestors$find = _ancestors$find.context) == null ? void 0 : _ancestors$find.elements.domReference,
1336
- ...portalNodes,
1337
- ...getInsideElements(),
1338
- startDismissButtonRef.current,
1339
- endDismissButtonRef.current,
1340
- beforeGuardRef.current,
1341
- afterGuardRef.current,
1342
- portalContext == null ? void 0 : portalContext.beforeOutsideRef.current,
1343
- portalContext == null ? void 0 : portalContext.afterOutsideRef.current,
1344
- orderRef.current.includes("reference") || isUntrappedTypeableCombobox ? domReference : null
1345
- ].filter((x) => x != null);
1346
- const cleanup$1 = modal || isUntrappedTypeableCombobox ? markOthers(insideElements, !useInert, useInert) : markOthers(insideElements);
1347
- return () => {
1348
- cleanup$1();
1349
- };
1350
- }, [
1351
- disabled,
1352
- domReference,
1353
- floating,
1354
- modal,
1355
- orderRef,
1356
- portalContext,
1357
- isUntrappedTypeableCombobox,
1358
- guards,
1359
- useInert,
1360
- tree,
1361
- getNodeId,
1362
- getInsideElements
1363
- ]);
1364
- require_floating_ui_react_utils.index(() => {
1365
- if (disabled || !require_floating_ui_utils_dom.isHTMLElement(floatingFocusElement)) return;
1366
- const previouslyFocusedElement = require_floating_ui_react_utils.activeElement(require_floating_ui_react_utils.getDocument(floatingFocusElement));
1367
- queueMicrotask(() => {
1368
- const focusableElements = getTabbableElements(floatingFocusElement);
1369
- const initialFocusValue = initialFocusRef.current;
1370
- const elToFocus = (typeof initialFocusValue === "number" ? focusableElements[initialFocusValue] : initialFocusValue.current) || floatingFocusElement;
1371
- const focusAlreadyInsideFloatingEl = require_floating_ui_react_utils.contains(floatingFocusElement, previouslyFocusedElement);
1372
- if (!ignoreInitialFocus && !focusAlreadyInsideFloatingEl && open) enqueueFocus(elToFocus, { preventScroll: elToFocus === floatingFocusElement });
1373
- });
1374
- }, [
1375
- disabled,
1376
- open,
1377
- floatingFocusElement,
1378
- ignoreInitialFocus,
1379
- getTabbableElements,
1380
- initialFocusRef
1381
- ]);
1382
- require_floating_ui_react_utils.index(() => {
1383
- if (disabled || !floatingFocusElement) return;
1384
- const doc = require_floating_ui_react_utils.getDocument(floatingFocusElement);
1385
- addPreviouslyFocusedElement(require_floating_ui_react_utils.activeElement(doc));
1386
- function onOpenChange$1(_ref) {
1387
- let { reason, event, nested } = _ref;
1388
- if (["hover", "safe-polygon"].includes(reason) && event.type === "mouseleave") preventReturnFocusRef.current = true;
1389
- if (reason !== "outside-press") return;
1390
- if (nested) preventReturnFocusRef.current = false;
1391
- else if (require_floating_ui_react_utils.isVirtualClick(event) || require_floating_ui_react_utils.isVirtualPointerEvent(event)) preventReturnFocusRef.current = false;
1392
- else {
1393
- let isPreventScrollSupported = false;
1394
- document.createElement("div").focus({ get preventScroll() {
1395
- isPreventScrollSupported = true;
1396
- return false;
1397
- } });
1398
- if (isPreventScrollSupported) preventReturnFocusRef.current = false;
1399
- else preventReturnFocusRef.current = true;
1400
- }
1401
- }
1402
- events.on("openchange", onOpenChange$1);
1403
- const fallbackEl = doc.createElement("span");
1404
- fallbackEl.setAttribute("tabindex", "-1");
1405
- fallbackEl.setAttribute("aria-hidden", "true");
1406
- Object.assign(fallbackEl.style, HIDDEN_STYLES);
1407
- if (isInsidePortal && domReference) domReference.insertAdjacentElement("afterend", fallbackEl);
1408
- function getReturnElement() {
1409
- if (typeof returnFocusRef.current === "boolean") {
1410
- const el = domReference || getPreviouslyFocusedElement();
1411
- return el && el.isConnected ? el : fallbackEl;
1412
- }
1413
- return returnFocusRef.current.current || fallbackEl;
1414
- }
1415
- return () => {
1416
- events.off("openchange", onOpenChange$1);
1417
- const activeEl = require_floating_ui_react_utils.activeElement(doc);
1418
- const isFocusInsideFloatingTree = require_floating_ui_react_utils.contains(floating, activeEl) || tree && require_floating_ui_react_utils.getNodeChildren(tree.nodesRef.current, getNodeId(), false).some((node) => {
1419
- var _node$context7;
1420
- return require_floating_ui_react_utils.contains((_node$context7 = node.context) == null ? void 0 : _node$context7.elements.floating, activeEl);
1421
- });
1422
- const returnElement = getReturnElement();
1423
- queueMicrotask(() => {
1424
- const tabbableReturnElement = getFirstTabbableElement(returnElement);
1425
- if (returnFocusRef.current && !preventReturnFocusRef.current && require_floating_ui_utils_dom.isHTMLElement(tabbableReturnElement) && (tabbableReturnElement !== activeEl && activeEl !== doc.body ? isFocusInsideFloatingTree : true)) tabbableReturnElement.focus({ preventScroll: true });
1426
- fallbackEl.remove();
1427
- });
1428
- };
1429
- }, [
1430
- disabled,
1431
- floating,
1432
- floatingFocusElement,
1433
- returnFocusRef,
1434
- dataRef,
1435
- events,
1436
- tree,
1437
- isInsidePortal,
1438
- domReference,
1439
- getNodeId
1440
- ]);
1441
- react.useEffect(() => {
1442
- queueMicrotask(() => {
1443
- preventReturnFocusRef.current = false;
1444
- });
1445
- return () => {
1446
- queueMicrotask(clearDisconnectedPreviouslyFocusedElements);
1447
- };
1448
- }, [disabled]);
1449
- require_floating_ui_react_utils.index(() => {
1450
- if (disabled) return;
1451
- if (!portalContext) return;
1452
- portalContext.setFocusManagerState({
1453
- modal,
1454
- closeOnFocusOut,
1455
- open,
1456
- onOpenChange,
1457
- domReference
1458
- });
1459
- return () => {
1460
- portalContext.setFocusManagerState(null);
1461
- };
1462
- }, [
1463
- disabled,
1464
- portalContext,
1465
- modal,
1466
- open,
1467
- onOpenChange,
1468
- closeOnFocusOut,
1469
- domReference
1470
- ]);
1471
- require_floating_ui_react_utils.index(() => {
1472
- if (disabled) return;
1473
- if (!floatingFocusElement) return;
1474
- handleTabIndex(floatingFocusElement, orderRef);
1475
- }, [
1476
- disabled,
1477
- floatingFocusElement,
1478
- orderRef
1479
- ]);
1480
- function renderDismissButton(location) {
1481
- if (disabled || !visuallyHiddenDismiss || !modal) return null;
1482
- return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(VisuallyHiddenDismiss, {
1483
- ref: location === "start" ? startDismissButtonRef : endDismissButtonRef,
1484
- onClick: (event) => onOpenChange(false, event.nativeEvent),
1485
- children: typeof visuallyHiddenDismiss === "string" ? visuallyHiddenDismiss : "Dismiss"
1486
- });
1487
- }
1488
- const shouldRenderGuards = !disabled && guards && (modal ? !isUntrappedTypeableCombobox : true) && (isInsidePortal || modal);
1489
- return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_jsx_runtime.Fragment, { children: [
1490
- shouldRenderGuards && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(FocusGuard, {
1491
- "data-type": "inside",
1492
- ref: mergedBeforeGuardRef,
1493
- onFocus: (event) => {
1494
- if (modal) {
1495
- const els = getTabbableElements();
1496
- enqueueFocus(order[0] === "reference" ? els[0] : els[els.length - 1]);
1497
- } else if (portalContext != null && portalContext.preserveTabOrder && portalContext.portalNode) {
1498
- preventReturnFocusRef.current = false;
1499
- if (require_floating_ui_react_utils.isOutsideEvent(event, portalContext.portalNode)) require_floating_ui_react_utils.getNextTabbable(domReference)?.focus();
1500
- else {
1501
- var _portalContext$before;
1502
- (_portalContext$before = portalContext.beforeOutsideRef.current) == null || _portalContext$before.focus();
1503
- }
1504
- }
1505
- }
1506
- }),
1507
- !isUntrappedTypeableCombobox && renderDismissButton("start"),
1508
- children,
1509
- renderDismissButton("end"),
1510
- shouldRenderGuards && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(FocusGuard, {
1511
- "data-type": "inside",
1512
- ref: mergedAfterGuardRef,
1513
- onFocus: (event) => {
1514
- if (modal) enqueueFocus(getTabbableElements()[0]);
1515
- else if (portalContext != null && portalContext.preserveTabOrder && portalContext.portalNode) {
1516
- if (closeOnFocusOut) preventReturnFocusRef.current = true;
1517
- if (require_floating_ui_react_utils.isOutsideEvent(event, portalContext.portalNode)) require_floating_ui_react_utils.getPreviousTabbable(domReference)?.focus();
1518
- else {
1519
- var _portalContext$afterO;
1520
- (_portalContext$afterO = portalContext.afterOutsideRef.current) == null || _portalContext$afterO.focus();
1521
- }
1522
- }
1523
- }
1524
- })
1525
- ] });
1526
- }
1527
- function enableScrollLock() {
1528
- const platform$1 = require_floating_ui_react_utils.getPlatform();
1529
- const isIOS = /iP(hone|ad|od)|iOS/.test(platform$1) || platform$1 === "MacIntel" && navigator.maxTouchPoints > 1;
1530
- const bodyStyle = document.body.style;
1531
- const paddingProp = Math.round(document.documentElement.getBoundingClientRect().left) + document.documentElement.scrollLeft ? "paddingLeft" : "paddingRight";
1532
- const scrollbarWidth = window.innerWidth - document.documentElement.clientWidth;
1533
- const scrollX = bodyStyle.left ? parseFloat(bodyStyle.left) : window.scrollX;
1534
- const scrollY = bodyStyle.top ? parseFloat(bodyStyle.top) : window.scrollY;
1535
- bodyStyle.overflow = "hidden";
1536
- bodyStyle.setProperty(scrollbarProperty, scrollbarWidth + "px");
1537
- if (scrollbarWidth) bodyStyle[paddingProp] = scrollbarWidth + "px";
1538
- if (isIOS) {
1539
- var _window$visualViewpor, _window$visualViewpor2;
1540
- const offsetLeft = ((_window$visualViewpor = window.visualViewport) == null ? void 0 : _window$visualViewpor.offsetLeft) || 0;
1541
- const offsetTop = ((_window$visualViewpor2 = window.visualViewport) == null ? void 0 : _window$visualViewpor2.offsetTop) || 0;
1542
- Object.assign(bodyStyle, {
1543
- position: "fixed",
1544
- top: -(scrollY - Math.floor(offsetTop)) + "px",
1545
- left: -(scrollX - Math.floor(offsetLeft)) + "px",
1546
- right: "0"
1547
- });
1548
- }
1549
- return () => {
1550
- Object.assign(bodyStyle, {
1551
- overflow: "",
1552
- [paddingProp]: ""
1553
- });
1554
- bodyStyle.removeProperty(scrollbarProperty);
1555
- if (isIOS) {
1556
- Object.assign(bodyStyle, {
1557
- position: "",
1558
- top: "",
1559
- left: "",
1560
- right: ""
1561
- });
1562
- window.scrollTo(scrollX, scrollY);
1563
- }
1564
- };
1565
- }
1566
- function isButtonTarget(event) {
1567
- return require_floating_ui_utils_dom.isHTMLElement(event.target) && event.target.tagName === "BUTTON";
1568
- }
1569
- function isAnchorTarget(event) {
1570
- return require_floating_ui_utils_dom.isHTMLElement(event.target) && event.target.tagName === "A";
1571
- }
1572
- function isSpaceIgnored(element) {
1573
- return require_floating_ui_react_utils.isTypeableElement(element);
1574
- }
1575
- /**
1576
- * Opens or closes the floating element when clicking the reference element.
1577
- * @see https://floating-ui.com/docs/useClick
1578
- */
1579
- function useClick(context, props) {
1580
- if (props === void 0) props = {};
1581
- const { open, onOpenChange, dataRef, elements: { domReference } } = context;
1582
- const { enabled = true, event: eventOption = "click", toggle = true, ignoreMouse = false, keyboardHandlers = true, stickIfOpen = true } = props;
1583
- const pointerTypeRef = react.useRef();
1584
- const didKeyDownRef = react.useRef(false);
1585
- const reference = react.useMemo(() => ({
1586
- onPointerDown(event) {
1587
- pointerTypeRef.current = event.pointerType;
1588
- },
1589
- onMouseDown(event) {
1590
- const pointerType = pointerTypeRef.current;
1591
- if (event.button !== 0) return;
1592
- if (eventOption === "click") return;
1593
- if (require_floating_ui_react_utils.isMouseLikePointerType(pointerType, true) && ignoreMouse) return;
1594
- if (open && toggle && (dataRef.current.openEvent && stickIfOpen ? dataRef.current.openEvent.type === "mousedown" : true)) onOpenChange(false, event.nativeEvent, "click");
1595
- else {
1596
- event.preventDefault();
1597
- onOpenChange(true, event.nativeEvent, "click");
1598
- }
1599
- },
1600
- onClick(event) {
1601
- const pointerType = pointerTypeRef.current;
1602
- if (eventOption === "mousedown" && pointerTypeRef.current) {
1603
- pointerTypeRef.current = void 0;
1604
- return;
1605
- }
1606
- if (require_floating_ui_react_utils.isMouseLikePointerType(pointerType, true) && ignoreMouse) return;
1607
- if (open && toggle && (dataRef.current.openEvent && stickIfOpen ? dataRef.current.openEvent.type === "click" : true)) onOpenChange(false, event.nativeEvent, "click");
1608
- else onOpenChange(true, event.nativeEvent, "click");
1609
- },
1610
- onKeyDown(event) {
1611
- pointerTypeRef.current = void 0;
1612
- if (event.defaultPrevented || !keyboardHandlers || isButtonTarget(event)) return;
1613
- if (event.key === " " && !isSpaceIgnored(domReference)) {
1614
- event.preventDefault();
1615
- didKeyDownRef.current = true;
1616
- }
1617
- if (isAnchorTarget(event)) return;
1618
- if (event.key === "Enter") if (open && toggle) onOpenChange(false, event.nativeEvent, "click");
1619
- else onOpenChange(true, event.nativeEvent, "click");
1620
- },
1621
- onKeyUp(event) {
1622
- if (event.defaultPrevented || !keyboardHandlers || isButtonTarget(event) || isSpaceIgnored(domReference)) return;
1623
- if (event.key === " " && didKeyDownRef.current) {
1624
- didKeyDownRef.current = false;
1625
- if (open && toggle) onOpenChange(false, event.nativeEvent, "click");
1626
- else onOpenChange(true, event.nativeEvent, "click");
1627
- }
1628
- }
1629
- }), [
1630
- dataRef,
1631
- domReference,
1632
- eventOption,
1633
- ignoreMouse,
1634
- keyboardHandlers,
1635
- onOpenChange,
1636
- open,
1637
- stickIfOpen,
1638
- toggle
1639
- ]);
1640
- return react.useMemo(() => enabled ? { reference } : {}, [enabled, reference]);
1641
- }
1642
- function createVirtualElement(domElement, data) {
1643
- let offsetX = null;
1644
- let offsetY = null;
1645
- let isAutoUpdateEvent = false;
1646
- return {
1647
- contextElement: domElement || void 0,
1648
- getBoundingClientRect() {
1649
- var _data$dataRef$current;
1650
- const domRect = (domElement == null ? void 0 : domElement.getBoundingClientRect()) || {
1651
- width: 0,
1652
- height: 0,
1653
- x: 0,
1654
- y: 0
1655
- };
1656
- const isXAxis = data.axis === "x" || data.axis === "both";
1657
- const isYAxis = data.axis === "y" || data.axis === "both";
1658
- const canTrackCursorOnAutoUpdate = ["mouseenter", "mousemove"].includes(((_data$dataRef$current = data.dataRef.current.openEvent) == null ? void 0 : _data$dataRef$current.type) || "") && data.pointerType !== "touch";
1659
- let width = domRect.width;
1660
- let height = domRect.height;
1661
- let x = domRect.x;
1662
- let y = domRect.y;
1663
- if (offsetX == null && data.x && isXAxis) offsetX = domRect.x - data.x;
1664
- if (offsetY == null && data.y && isYAxis) offsetY = domRect.y - data.y;
1665
- x -= offsetX || 0;
1666
- y -= offsetY || 0;
1667
- width = 0;
1668
- height = 0;
1669
- if (!isAutoUpdateEvent || canTrackCursorOnAutoUpdate) {
1670
- width = data.axis === "y" ? domRect.width : 0;
1671
- height = data.axis === "x" ? domRect.height : 0;
1672
- x = isXAxis && data.x != null ? data.x : x;
1673
- y = isYAxis && data.y != null ? data.y : y;
1674
- } else if (isAutoUpdateEvent && !canTrackCursorOnAutoUpdate) {
1675
- height = data.axis === "x" ? domRect.height : height;
1676
- width = data.axis === "y" ? domRect.width : width;
1677
- }
1678
- isAutoUpdateEvent = true;
1679
- return {
1680
- width,
1681
- height,
1682
- x,
1683
- y,
1684
- top: y,
1685
- right: x + width,
1686
- bottom: y + height,
1687
- left: x
1688
- };
1689
- }
1690
- };
1691
- }
1692
- function isMouseBasedEvent(event) {
1693
- return event != null && event.clientX != null;
1694
- }
1695
- /**
1696
- * Positions the floating element relative to a client point (in the viewport),
1697
- * such as the mouse position. By default, it follows the mouse cursor.
1698
- * @see https://floating-ui.com/docs/useClientPoint
1699
- */
1700
- function useClientPoint(context, props) {
1701
- if (props === void 0) props = {};
1702
- const { open, dataRef, elements: { floating, domReference }, refs } = context;
1703
- const { enabled = true, axis = "both", x = null, y = null } = props;
1704
- const initialRef = react.useRef(false);
1705
- const cleanupListenerRef = react.useRef(null);
1706
- const [pointerType, setPointerType] = react.useState();
1707
- const [reactive, setReactive] = react.useState([]);
1708
- const setReference = require_floating_ui_react_utils.useEffectEvent((x$1, y$1) => {
1709
- if (initialRef.current) return;
1710
- if (dataRef.current.openEvent && !isMouseBasedEvent(dataRef.current.openEvent)) return;
1711
- refs.setPositionReference(createVirtualElement(domReference, {
1712
- x: x$1,
1713
- y: y$1,
1714
- axis,
1715
- dataRef,
1716
- pointerType
1717
- }));
1718
- });
1719
- const handleReferenceEnterOrMove = require_floating_ui_react_utils.useEffectEvent((event) => {
1720
- if (x != null || y != null) return;
1721
- if (!open) setReference(event.clientX, event.clientY);
1722
- else if (!cleanupListenerRef.current) setReactive([]);
1723
- });
1724
- const openCheck = require_floating_ui_react_utils.isMouseLikePointerType(pointerType) ? floating : open;
1725
- const addListener = react.useCallback(() => {
1726
- if (!openCheck || !enabled || x != null || y != null) return;
1727
- const win = require_floating_ui_utils_dom.getWindow(floating);
1728
- function handleMouseMove(event) {
1729
- if (!require_floating_ui_react_utils.contains(floating, require_floating_ui_react_utils.getTarget(event))) setReference(event.clientX, event.clientY);
1730
- else {
1731
- win.removeEventListener("mousemove", handleMouseMove);
1732
- cleanupListenerRef.current = null;
1733
- }
1734
- }
1735
- if (!dataRef.current.openEvent || isMouseBasedEvent(dataRef.current.openEvent)) {
1736
- win.addEventListener("mousemove", handleMouseMove);
1737
- const cleanup$1 = () => {
1738
- win.removeEventListener("mousemove", handleMouseMove);
1739
- cleanupListenerRef.current = null;
1740
- };
1741
- cleanupListenerRef.current = cleanup$1;
1742
- return cleanup$1;
1743
- }
1744
- refs.setPositionReference(domReference);
1745
- }, [
1746
- openCheck,
1747
- enabled,
1748
- x,
1749
- y,
1750
- floating,
1751
- dataRef,
1752
- refs,
1753
- domReference,
1754
- setReference
1755
- ]);
1756
- react.useEffect(() => {
1757
- return addListener();
1758
- }, [addListener, reactive]);
1759
- react.useEffect(() => {
1760
- if (enabled && !floating) initialRef.current = false;
1761
- }, [enabled, floating]);
1762
- react.useEffect(() => {
1763
- if (!enabled && open) initialRef.current = true;
1764
- }, [enabled, open]);
1765
- require_floating_ui_react_utils.index(() => {
1766
- if (enabled && (x != null || y != null)) {
1767
- initialRef.current = false;
1768
- setReference(x, y);
1769
- }
1770
- }, [
1771
- enabled,
1772
- x,
1773
- y,
1774
- setReference
1775
- ]);
1776
- const reference = react.useMemo(() => {
1777
- function setPointerTypeRef(_ref) {
1778
- let { pointerType: pointerType$1 } = _ref;
1779
- setPointerType(pointerType$1);
1780
- }
1781
- return {
1782
- onPointerDown: setPointerTypeRef,
1783
- onPointerEnter: setPointerTypeRef,
1784
- onMouseMove: handleReferenceEnterOrMove,
1785
- onMouseEnter: handleReferenceEnterOrMove
1786
- };
1787
- }, [handleReferenceEnterOrMove]);
1788
- return react.useMemo(() => enabled ? { reference } : {}, [enabled, reference]);
1789
- }
1790
- /**
1791
- * Closes the floating element when a dismissal is requested — by default, when
1792
- * the user presses the `escape` key or outside of the floating element.
1793
- * @see https://floating-ui.com/docs/useDismiss
1794
- */
1795
- function useDismiss(context, props) {
1796
- if (props === void 0) props = {};
1797
- const { open, onOpenChange, elements, dataRef } = context;
1798
- const { enabled = true, escapeKey = true, outsidePress: unstable_outsidePress = true, outsidePressEvent = "pointerdown", referencePress = false, referencePressEvent = "pointerdown", ancestorScroll = false, bubbles, capture } = props;
1799
- const tree = useFloatingTree();
1800
- const outsidePressFn = require_floating_ui_react_utils.useEffectEvent(typeof unstable_outsidePress === "function" ? unstable_outsidePress : () => false);
1801
- const outsidePress = typeof unstable_outsidePress === "function" ? outsidePressFn : unstable_outsidePress;
1802
- const endedOrStartedInsideRef = react.useRef(false);
1803
- const { escapeKey: escapeKeyBubbles, outsidePress: outsidePressBubbles } = normalizeProp(bubbles);
1804
- const { escapeKey: escapeKeyCapture, outsidePress: outsidePressCapture } = normalizeProp(capture);
1805
- const isComposingRef = react.useRef(false);
1806
- const closeOnEscapeKeyDown = require_floating_ui_react_utils.useEffectEvent((event) => {
1807
- var _dataRef$current$floa;
1808
- if (!open || !enabled || !escapeKey || event.key !== "Escape") return;
1809
- if (isComposingRef.current) return;
1810
- const nodeId = (_dataRef$current$floa = dataRef.current.floatingContext) == null ? void 0 : _dataRef$current$floa.nodeId;
1811
- const children = tree ? require_floating_ui_react_utils.getNodeChildren(tree.nodesRef.current, nodeId) : [];
1812
- if (!escapeKeyBubbles) {
1813
- event.stopPropagation();
1814
- if (children.length > 0) {
1815
- let shouldDismiss = true;
1816
- children.forEach((child) => {
1817
- var _child$context;
1818
- if ((_child$context = child.context) != null && _child$context.open && !child.context.dataRef.current.__escapeKeyBubbles) {
1819
- shouldDismiss = false;
1820
- return;
1821
- }
1822
- });
1823
- if (!shouldDismiss) return;
1824
- }
1825
- }
1826
- onOpenChange(false, require_floating_ui_react_utils.isReactEvent(event) ? event.nativeEvent : event, "escape-key");
1827
- });
1828
- const closeOnEscapeKeyDownCapture = require_floating_ui_react_utils.useEffectEvent((event) => {
1829
- var _getTarget2;
1830
- const callback = () => {
1831
- var _getTarget;
1832
- closeOnEscapeKeyDown(event);
1833
- (_getTarget = require_floating_ui_react_utils.getTarget(event)) == null || _getTarget.removeEventListener("keydown", callback);
1834
- };
1835
- (_getTarget2 = require_floating_ui_react_utils.getTarget(event)) == null || _getTarget2.addEventListener("keydown", callback);
1836
- });
1837
- const closeOnPressOutside = require_floating_ui_react_utils.useEffectEvent((event) => {
1838
- var _dataRef$current$floa2;
1839
- const insideReactTree = dataRef.current.insideReactTree;
1840
- dataRef.current.insideReactTree = false;
1841
- const endedOrStartedInside = endedOrStartedInsideRef.current;
1842
- endedOrStartedInsideRef.current = false;
1843
- if (outsidePressEvent === "click" && endedOrStartedInside) return;
1844
- if (insideReactTree) return;
1845
- if (typeof outsidePress === "function" && !outsidePress(event)) return;
1846
- const target = require_floating_ui_react_utils.getTarget(event);
1847
- const inertSelector = "[" + createAttribute("inert") + "]";
1848
- const markers = require_floating_ui_react_utils.getDocument(elements.floating).querySelectorAll(inertSelector);
1849
- let targetRootAncestor = require_floating_ui_utils_dom.isElement(target) ? target : null;
1850
- while (targetRootAncestor && !require_floating_ui_utils_dom.isLastTraversableNode(targetRootAncestor)) {
1851
- const nextParent = require_floating_ui_utils_dom.getParentNode(targetRootAncestor);
1852
- if (require_floating_ui_utils_dom.isLastTraversableNode(nextParent) || !require_floating_ui_utils_dom.isElement(nextParent)) break;
1853
- targetRootAncestor = nextParent;
1854
- }
1855
- if (markers.length && require_floating_ui_utils_dom.isElement(target) && !require_floating_ui_react_utils.isRootElement(target) && !require_floating_ui_react_utils.contains(target, elements.floating) && Array.from(markers).every((marker) => !require_floating_ui_react_utils.contains(targetRootAncestor, marker))) return;
1856
- if (require_floating_ui_utils_dom.isHTMLElement(target) && floating) {
1857
- const lastTraversableNode = require_floating_ui_utils_dom.isLastTraversableNode(target);
1858
- const style = require_floating_ui_utils_dom.getComputedStyle(target);
1859
- const scrollRe = /auto|scroll/;
1860
- const isScrollableX = lastTraversableNode || scrollRe.test(style.overflowX);
1861
- const isScrollableY = lastTraversableNode || scrollRe.test(style.overflowY);
1862
- const canScrollX = isScrollableX && target.clientWidth > 0 && target.scrollWidth > target.clientWidth;
1863
- const canScrollY = isScrollableY && target.clientHeight > 0 && target.scrollHeight > target.clientHeight;
1864
- const isRTL = style.direction === "rtl";
1865
- const pressedVerticalScrollbar = canScrollY && (isRTL ? event.offsetX <= target.offsetWidth - target.clientWidth : event.offsetX > target.clientWidth);
1866
- const pressedHorizontalScrollbar = canScrollX && event.offsetY > target.clientHeight;
1867
- if (pressedVerticalScrollbar || pressedHorizontalScrollbar) return;
1868
- }
1869
- const nodeId = (_dataRef$current$floa2 = dataRef.current.floatingContext) == null ? void 0 : _dataRef$current$floa2.nodeId;
1870
- const targetIsInsideChildren = tree && require_floating_ui_react_utils.getNodeChildren(tree.nodesRef.current, nodeId).some((node) => {
1871
- var _node$context;
1872
- return require_floating_ui_react_utils.isEventTargetWithin(event, (_node$context = node.context) == null ? void 0 : _node$context.elements.floating);
1873
- });
1874
- if (require_floating_ui_react_utils.isEventTargetWithin(event, elements.floating) || require_floating_ui_react_utils.isEventTargetWithin(event, elements.domReference) || targetIsInsideChildren) return;
1875
- const children = tree ? require_floating_ui_react_utils.getNodeChildren(tree.nodesRef.current, nodeId) : [];
1876
- if (children.length > 0) {
1877
- let shouldDismiss = true;
1878
- children.forEach((child) => {
1879
- var _child$context2;
1880
- if ((_child$context2 = child.context) != null && _child$context2.open && !child.context.dataRef.current.__outsidePressBubbles) {
1881
- shouldDismiss = false;
1882
- return;
1883
- }
1884
- });
1885
- if (!shouldDismiss) return;
1886
- }
1887
- onOpenChange(false, event, "outside-press");
1888
- });
1889
- const closeOnPressOutsideCapture = require_floating_ui_react_utils.useEffectEvent((event) => {
1890
- var _getTarget4;
1891
- const callback = () => {
1892
- var _getTarget3;
1893
- closeOnPressOutside(event);
1894
- (_getTarget3 = require_floating_ui_react_utils.getTarget(event)) == null || _getTarget3.removeEventListener(outsidePressEvent, callback);
1895
- };
1896
- (_getTarget4 = require_floating_ui_react_utils.getTarget(event)) == null || _getTarget4.addEventListener(outsidePressEvent, callback);
1897
- });
1898
- react.useEffect(() => {
1899
- if (!open || !enabled) return;
1900
- dataRef.current.__escapeKeyBubbles = escapeKeyBubbles;
1901
- dataRef.current.__outsidePressBubbles = outsidePressBubbles;
1902
- let compositionTimeout = -1;
1903
- function onScroll(event) {
1904
- onOpenChange(false, event, "ancestor-scroll");
1905
- }
1906
- function handleCompositionStart() {
1907
- window.clearTimeout(compositionTimeout);
1908
- isComposingRef.current = true;
1909
- }
1910
- function handleCompositionEnd() {
1911
- compositionTimeout = window.setTimeout(() => {
1912
- isComposingRef.current = false;
1913
- }, require_floating_ui_utils_dom.isWebKit() ? 5 : 0);
1914
- }
1915
- const doc = require_floating_ui_react_utils.getDocument(elements.floating);
1916
- if (escapeKey) {
1917
- doc.addEventListener("keydown", escapeKeyCapture ? closeOnEscapeKeyDownCapture : closeOnEscapeKeyDown, escapeKeyCapture);
1918
- doc.addEventListener("compositionstart", handleCompositionStart);
1919
- doc.addEventListener("compositionend", handleCompositionEnd);
1920
- }
1921
- outsidePress && doc.addEventListener(outsidePressEvent, outsidePressCapture ? closeOnPressOutsideCapture : closeOnPressOutside, outsidePressCapture);
1922
- let ancestors = [];
1923
- if (ancestorScroll) {
1924
- if (require_floating_ui_utils_dom.isElement(elements.domReference)) ancestors = require_floating_ui_utils_dom.getOverflowAncestors(elements.domReference);
1925
- if (require_floating_ui_utils_dom.isElement(elements.floating)) ancestors = ancestors.concat(require_floating_ui_utils_dom.getOverflowAncestors(elements.floating));
1926
- if (!require_floating_ui_utils_dom.isElement(elements.reference) && elements.reference && elements.reference.contextElement) ancestors = ancestors.concat(require_floating_ui_utils_dom.getOverflowAncestors(elements.reference.contextElement));
1927
- }
1928
- ancestors = ancestors.filter((ancestor) => {
1929
- var _doc$defaultView;
1930
- return ancestor !== ((_doc$defaultView = doc.defaultView) == null ? void 0 : _doc$defaultView.visualViewport);
1931
- });
1932
- ancestors.forEach((ancestor) => {
1933
- ancestor.addEventListener("scroll", onScroll, { passive: true });
1934
- });
1935
- return () => {
1936
- if (escapeKey) {
1937
- doc.removeEventListener("keydown", escapeKeyCapture ? closeOnEscapeKeyDownCapture : closeOnEscapeKeyDown, escapeKeyCapture);
1938
- doc.removeEventListener("compositionstart", handleCompositionStart);
1939
- doc.removeEventListener("compositionend", handleCompositionEnd);
1940
- }
1941
- outsidePress && doc.removeEventListener(outsidePressEvent, outsidePressCapture ? closeOnPressOutsideCapture : closeOnPressOutside, outsidePressCapture);
1942
- ancestors.forEach((ancestor) => {
1943
- ancestor.removeEventListener("scroll", onScroll);
1944
- });
1945
- window.clearTimeout(compositionTimeout);
1946
- };
1947
- }, [
1948
- dataRef,
1949
- elements,
1950
- escapeKey,
1951
- outsidePress,
1952
- outsidePressEvent,
1953
- open,
1954
- onOpenChange,
1955
- ancestorScroll,
1956
- enabled,
1957
- escapeKeyBubbles,
1958
- outsidePressBubbles,
1959
- closeOnEscapeKeyDown,
1960
- escapeKeyCapture,
1961
- closeOnEscapeKeyDownCapture,
1962
- closeOnPressOutside,
1963
- outsidePressCapture,
1964
- closeOnPressOutsideCapture
1965
- ]);
1966
- react.useEffect(() => {
1967
- dataRef.current.insideReactTree = false;
1968
- }, [
1969
- dataRef,
1970
- outsidePress,
1971
- outsidePressEvent
1972
- ]);
1973
- const reference = react.useMemo(() => ({
1974
- onKeyDown: closeOnEscapeKeyDown,
1975
- ...referencePress && {
1976
- [bubbleHandlerKeys[referencePressEvent]]: (event) => {
1977
- onOpenChange(false, event.nativeEvent, "reference-press");
1978
- },
1979
- ...referencePressEvent !== "click" && { onClick(event) {
1980
- onOpenChange(false, event.nativeEvent, "reference-press");
1981
- } }
1982
- }
1983
- }), [
1984
- closeOnEscapeKeyDown,
1985
- onOpenChange,
1986
- referencePress,
1987
- referencePressEvent
1988
- ]);
1989
- const floating = react.useMemo(() => ({
1990
- onKeyDown: closeOnEscapeKeyDown,
1991
- onMouseDown() {
1992
- endedOrStartedInsideRef.current = true;
1993
- },
1994
- onMouseUp() {
1995
- endedOrStartedInsideRef.current = true;
1996
- },
1997
- [captureHandlerKeys[outsidePressEvent]]: () => {
1998
- dataRef.current.insideReactTree = true;
1999
- }
2000
- }), [
2001
- closeOnEscapeKeyDown,
2002
- outsidePressEvent,
2003
- dataRef
2004
- ]);
2005
- return react.useMemo(() => enabled ? {
2006
- reference,
2007
- floating
2008
- } : {}, [
2009
- enabled,
2010
- reference,
2011
- floating
2012
- ]);
2013
- }
2014
- function useFloatingRootContext(options) {
2015
- const { open = false, onOpenChange: onOpenChangeProp, elements: elementsProp } = options;
2016
- const floatingId = useId();
2017
- const dataRef = react.useRef({});
2018
- const [events] = react.useState(() => createEventEmitter());
2019
- const nested = useFloatingParentNodeId() != null;
2020
- if (process.env.NODE_ENV !== "production") {
2021
- const optionDomReference = elementsProp.reference;
2022
- if (optionDomReference && !require_floating_ui_utils_dom.isElement(optionDomReference)) error("Cannot pass a virtual element to the `elements.reference` option,", "as it must be a real DOM element. Use `refs.setPositionReference()`", "instead.");
2023
- }
2024
- const [positionReference, setPositionReference] = react.useState(elementsProp.reference);
2025
- const onOpenChange = require_floating_ui_react_utils.useEffectEvent((open$1, event, reason) => {
2026
- dataRef.current.openEvent = open$1 ? event : void 0;
2027
- events.emit("openchange", {
2028
- open: open$1,
2029
- event,
2030
- reason,
2031
- nested
2032
- });
2033
- onOpenChangeProp?.(open$1, event, reason);
2034
- });
2035
- const refs = react.useMemo(() => ({ setPositionReference }), []);
2036
- const elements = react.useMemo(() => ({
2037
- reference: positionReference || elementsProp.reference || null,
2038
- floating: elementsProp.floating || null,
2039
- domReference: elementsProp.reference
2040
- }), [
2041
- positionReference,
2042
- elementsProp.reference,
2043
- elementsProp.floating
2044
- ]);
2045
- return react.useMemo(() => ({
2046
- dataRef,
2047
- open,
2048
- onOpenChange,
2049
- elements,
2050
- events,
2051
- floatingId,
2052
- refs
2053
- }), [
2054
- open,
2055
- onOpenChange,
2056
- elements,
2057
- events,
2058
- floatingId,
2059
- refs
2060
- ]);
2061
- }
2062
- /**
2063
- * Provides data to position a floating element and context to add interactions.
2064
- * @see https://floating-ui.com/docs/useFloating
2065
- */
2066
- function useFloating$1(options) {
2067
- if (options === void 0) options = {};
2068
- const { nodeId } = options;
2069
- const internalRootContext = useFloatingRootContext({
2070
- ...options,
2071
- elements: {
2072
- reference: null,
2073
- floating: null,
2074
- ...options.elements
2075
- }
2076
- });
2077
- const rootContext = options.rootContext || internalRootContext;
2078
- const computedElements = rootContext.elements;
2079
- const [_domReference, setDomReference] = react.useState(null);
2080
- const [positionReference, _setPositionReference] = react.useState(null);
2081
- const domReference = (computedElements == null ? void 0 : computedElements.domReference) || _domReference;
2082
- const domReferenceRef = react.useRef(null);
2083
- const tree = useFloatingTree();
2084
- require_floating_ui_react_utils.index(() => {
2085
- if (domReference) domReferenceRef.current = domReference;
2086
- }, [domReference]);
2087
- const position = require_floating_ui_react_dom.useFloating({
2088
- ...options,
2089
- elements: {
2090
- ...computedElements,
2091
- ...positionReference && { reference: positionReference }
2092
- }
2093
- });
2094
- const setPositionReference = react.useCallback((node) => {
2095
- const computedPositionReference = require_floating_ui_utils_dom.isElement(node) ? {
2096
- getBoundingClientRect: () => node.getBoundingClientRect(),
2097
- getClientRects: () => node.getClientRects(),
2098
- contextElement: node
2099
- } : node;
2100
- _setPositionReference(computedPositionReference);
2101
- position.refs.setReference(computedPositionReference);
2102
- }, [position.refs]);
2103
- const setReference = react.useCallback((node) => {
2104
- if (require_floating_ui_utils_dom.isElement(node) || node === null) {
2105
- domReferenceRef.current = node;
2106
- setDomReference(node);
2107
- }
2108
- if (require_floating_ui_utils_dom.isElement(position.refs.reference.current) || position.refs.reference.current === null || node !== null && !require_floating_ui_utils_dom.isElement(node)) position.refs.setReference(node);
2109
- }, [position.refs]);
2110
- const refs = react.useMemo(() => ({
2111
- ...position.refs,
2112
- setReference,
2113
- setPositionReference,
2114
- domReference: domReferenceRef
2115
- }), [
2116
- position.refs,
2117
- setReference,
2118
- setPositionReference
2119
- ]);
2120
- const elements = react.useMemo(() => ({
2121
- ...position.elements,
2122
- domReference
2123
- }), [position.elements, domReference]);
2124
- const context = react.useMemo(() => ({
2125
- ...position,
2126
- ...rootContext,
2127
- refs,
2128
- elements,
2129
- nodeId
2130
- }), [
2131
- position,
2132
- refs,
2133
- elements,
2134
- nodeId,
2135
- rootContext
2136
- ]);
2137
- require_floating_ui_react_utils.index(() => {
2138
- rootContext.dataRef.current.floatingContext = context;
2139
- const node = tree == null ? void 0 : tree.nodesRef.current.find((node$1) => node$1.id === nodeId);
2140
- if (node) node.context = context;
2141
- });
2142
- return react.useMemo(() => ({
2143
- ...position,
2144
- context,
2145
- refs,
2146
- elements
2147
- }), [
2148
- position,
2149
- refs,
2150
- elements,
2151
- context
2152
- ]);
2153
- }
2154
- function isMacSafari() {
2155
- return require_floating_ui_react_utils.isMac() && require_floating_ui_react_utils.isSafari();
2156
- }
2157
- /**
2158
- * Opens the floating element while the reference element has focus, like CSS
2159
- * `:focus`.
2160
- * @see https://floating-ui.com/docs/useFocus
2161
- */
2162
- function useFocus(context, props) {
2163
- if (props === void 0) props = {};
2164
- const { open, onOpenChange, events, dataRef, elements } = context;
2165
- const { enabled = true, visibleOnly = true } = props;
2166
- const blockFocusRef = react.useRef(false);
2167
- const timeoutRef = react.useRef(-1);
2168
- const keyboardModalityRef = react.useRef(true);
2169
- react.useEffect(() => {
2170
- if (!enabled) return;
2171
- const win = require_floating_ui_utils_dom.getWindow(elements.domReference);
2172
- function onBlur() {
2173
- if (!open && require_floating_ui_utils_dom.isHTMLElement(elements.domReference) && elements.domReference === require_floating_ui_react_utils.activeElement(require_floating_ui_react_utils.getDocument(elements.domReference))) blockFocusRef.current = true;
2174
- }
2175
- function onKeyDown() {
2176
- keyboardModalityRef.current = true;
2177
- }
2178
- function onPointerDown() {
2179
- keyboardModalityRef.current = false;
2180
- }
2181
- win.addEventListener("blur", onBlur);
2182
- if (isMacSafari()) {
2183
- win.addEventListener("keydown", onKeyDown, true);
2184
- win.addEventListener("pointerdown", onPointerDown, true);
2185
- }
2186
- return () => {
2187
- win.removeEventListener("blur", onBlur);
2188
- if (isMacSafari()) {
2189
- win.removeEventListener("keydown", onKeyDown, true);
2190
- win.removeEventListener("pointerdown", onPointerDown, true);
2191
- }
2192
- };
2193
- }, [
2194
- elements.domReference,
2195
- open,
2196
- enabled
2197
- ]);
2198
- react.useEffect(() => {
2199
- if (!enabled) return;
2200
- function onOpenChange$1(_ref) {
2201
- let { reason } = _ref;
2202
- if (reason === "reference-press" || reason === "escape-key") blockFocusRef.current = true;
2203
- }
2204
- events.on("openchange", onOpenChange$1);
2205
- return () => {
2206
- events.off("openchange", onOpenChange$1);
2207
- };
2208
- }, [events, enabled]);
2209
- react.useEffect(() => {
2210
- return () => {
2211
- clearTimeoutIfSet(timeoutRef);
2212
- };
2213
- }, []);
2214
- const reference = react.useMemo(() => ({
2215
- onMouseLeave() {
2216
- blockFocusRef.current = false;
2217
- },
2218
- onFocus(event) {
2219
- if (blockFocusRef.current) return;
2220
- const target = require_floating_ui_react_utils.getTarget(event.nativeEvent);
2221
- if (visibleOnly && require_floating_ui_utils_dom.isElement(target)) {
2222
- if (isMacSafari() && !event.relatedTarget) {
2223
- if (!keyboardModalityRef.current && !require_floating_ui_react_utils.isTypeableElement(target)) return;
2224
- } else if (!require_floating_ui_react_utils.matchesFocusVisible(target)) return;
2225
- }
2226
- onOpenChange(true, event.nativeEvent, "focus");
2227
- },
2228
- onBlur(event) {
2229
- blockFocusRef.current = false;
2230
- const relatedTarget = event.relatedTarget;
2231
- const nativeEvent = event.nativeEvent;
2232
- const movedToFocusGuard = require_floating_ui_utils_dom.isElement(relatedTarget) && relatedTarget.hasAttribute(createAttribute("focus-guard")) && relatedTarget.getAttribute("data-type") === "outside";
2233
- timeoutRef.current = window.setTimeout(() => {
2234
- var _dataRef$current$floa;
2235
- const activeEl = require_floating_ui_react_utils.activeElement(elements.domReference ? elements.domReference.ownerDocument : document);
2236
- if (!relatedTarget && activeEl === elements.domReference) return;
2237
- if (require_floating_ui_react_utils.contains((_dataRef$current$floa = dataRef.current.floatingContext) == null ? void 0 : _dataRef$current$floa.refs.floating.current, activeEl) || require_floating_ui_react_utils.contains(elements.domReference, activeEl) || movedToFocusGuard) return;
2238
- onOpenChange(false, nativeEvent, "focus");
2239
- });
2240
- }
2241
- }), [
2242
- dataRef,
2243
- elements.domReference,
2244
- onOpenChange,
2245
- visibleOnly
2246
- ]);
2247
- return react.useMemo(() => enabled ? { reference } : {}, [enabled, reference]);
2248
- }
2249
- function mergeProps(userProps, propsList, elementKey) {
2250
- const map = /* @__PURE__ */ new Map();
2251
- const isItem = elementKey === "item";
2252
- let domUserProps = userProps;
2253
- if (isItem && userProps) {
2254
- const { [ACTIVE_KEY]: _, [SELECTED_KEY]: __,...validProps } = userProps;
2255
- domUserProps = validProps;
2256
- }
2257
- return {
2258
- ...elementKey === "floating" && {
2259
- tabIndex: -1,
2260
- [FOCUSABLE_ATTRIBUTE]: ""
2261
- },
2262
- ...domUserProps,
2263
- ...propsList.map((value) => {
2264
- const propsOrGetProps = value ? value[elementKey] : null;
2265
- if (typeof propsOrGetProps === "function") return userProps ? propsOrGetProps(userProps) : null;
2266
- return propsOrGetProps;
2267
- }).concat(userProps).reduce((acc, props) => {
2268
- if (!props) return acc;
2269
- Object.entries(props).forEach((_ref) => {
2270
- let [key, value] = _ref;
2271
- if (isItem && [ACTIVE_KEY, SELECTED_KEY].includes(key)) return;
2272
- if (key.indexOf("on") === 0) {
2273
- if (!map.has(key)) map.set(key, []);
2274
- if (typeof value === "function") {
2275
- var _map$get;
2276
- (_map$get = map.get(key)) == null || _map$get.push(value);
2277
- acc[key] = function() {
2278
- var _map$get2;
2279
- for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) args[_key] = arguments[_key];
2280
- return (_map$get2 = map.get(key)) == null ? void 0 : _map$get2.map((fn) => fn(...args)).find((val) => val !== void 0);
2281
- };
2282
- }
2283
- } else acc[key] = value;
2284
- });
2285
- return acc;
2286
- }, {})
2287
- };
2288
- }
2289
- /**
2290
- * Merges an array of interaction hooks' props into prop getters, allowing
2291
- * event handler functions to be composed together without overwriting one
2292
- * another.
2293
- * @see https://floating-ui.com/docs/useInteractions
2294
- */
2295
- function useInteractions(propsList) {
2296
- if (propsList === void 0) propsList = [];
2297
- const referenceDeps = propsList.map((key) => key == null ? void 0 : key.reference);
2298
- const floatingDeps = propsList.map((key) => key == null ? void 0 : key.floating);
2299
- const itemDeps = propsList.map((key) => key == null ? void 0 : key.item);
2300
- const getReferenceProps = react.useCallback((userProps) => mergeProps(userProps, propsList, "reference"), referenceDeps);
2301
- const getFloatingProps = react.useCallback((userProps) => mergeProps(userProps, propsList, "floating"), floatingDeps);
2302
- const getItemProps = react.useCallback((userProps) => mergeProps(userProps, propsList, "item"), itemDeps);
2303
- return react.useMemo(() => ({
2304
- getReferenceProps,
2305
- getFloatingProps,
2306
- getItemProps
2307
- }), [
2308
- getReferenceProps,
2309
- getFloatingProps,
2310
- getItemProps
2311
- ]);
2312
- }
2313
- function doSwitch(orientation, vertical, horizontal) {
2314
- switch (orientation) {
2315
- case "vertical": return vertical;
2316
- case "horizontal": return horizontal;
2317
- default: return vertical || horizontal;
2318
- }
2319
- }
2320
- function isMainOrientationKey(key, orientation) {
2321
- return doSwitch(orientation, key === ARROW_UP || key === ARROW_DOWN, key === ARROW_LEFT || key === ARROW_RIGHT);
2322
- }
2323
- function isMainOrientationToEndKey(key, orientation, rtl) {
2324
- return doSwitch(orientation, key === ARROW_DOWN, rtl ? key === ARROW_LEFT : key === ARROW_RIGHT) || key === "Enter" || key === " " || key === "";
2325
- }
2326
- function isCrossOrientationOpenKey(key, orientation, rtl) {
2327
- return doSwitch(orientation, rtl ? key === ARROW_LEFT : key === ARROW_RIGHT, key === ARROW_DOWN);
2328
- }
2329
- function isCrossOrientationCloseKey(key, orientation, rtl, cols) {
2330
- const vertical = rtl ? key === ARROW_RIGHT : key === ARROW_LEFT;
2331
- const horizontal = key === ARROW_UP;
2332
- if (orientation === "both" || orientation === "horizontal" && cols && cols > 1) return key === ESCAPE;
2333
- return doSwitch(orientation, vertical, horizontal);
2334
- }
2335
- /**
2336
- * Adds arrow key-based navigation of a list of items, either using real DOM
2337
- * focus or virtual focus.
2338
- * @see https://floating-ui.com/docs/useListNavigation
2339
- */
2340
- function useListNavigation(context, props) {
2341
- const { open, onOpenChange, elements, floatingId } = context;
2342
- const { listRef, activeIndex, onNavigate: unstable_onNavigate = () => {}, enabled = true, selectedIndex = null, allowEscape = false, loop = false, nested = false, rtl = false, virtual = false, focusItemOnOpen = "auto", focusItemOnHover = true, openOnArrowKeyDown = true, disabledIndices = void 0, orientation = "vertical", parentOrientation, cols = 1, scrollItemIntoView = true, virtualItemRef, itemSizes, dense = false } = props;
2343
- if (process.env.NODE_ENV !== "production") {
2344
- if (allowEscape) {
2345
- if (!loop) warn("`useListNavigation` looping must be enabled to allow escaping.");
2346
- if (!virtual) warn("`useListNavigation` must be virtual to allow escaping.");
2347
- }
2348
- if (orientation === "vertical" && cols > 1) warn("In grid list navigation mode (`cols` > 1), the `orientation` should", "be either \"horizontal\" or \"both\".");
2349
- }
2350
- const floatingFocusElementRef = require_floating_ui_react_utils.useLatestRef(require_floating_ui_react_utils.getFloatingFocusElement(elements.floating));
2351
- const parentId = useFloatingParentNodeId();
2352
- const tree = useFloatingTree();
2353
- require_floating_ui_react_utils.index(() => {
2354
- context.dataRef.current.orientation = orientation;
2355
- }, [context, orientation]);
2356
- const onNavigate = require_floating_ui_react_utils.useEffectEvent(() => {
2357
- unstable_onNavigate(indexRef.current === -1 ? null : indexRef.current);
2358
- });
2359
- const typeableComboboxReference = require_floating_ui_react_utils.isTypeableCombobox(elements.domReference);
2360
- const focusItemOnOpenRef = react.useRef(focusItemOnOpen);
2361
- const indexRef = react.useRef(selectedIndex != null ? selectedIndex : -1);
2362
- const keyRef = react.useRef(null);
2363
- const isPointerModalityRef = react.useRef(true);
2364
- const previousOnNavigateRef = react.useRef(onNavigate);
2365
- const previousMountedRef = react.useRef(!!elements.floating);
2366
- const previousOpenRef = react.useRef(open);
2367
- const forceSyncFocusRef = react.useRef(false);
2368
- const forceScrollIntoViewRef = react.useRef(false);
2369
- const disabledIndicesRef = require_floating_ui_react_utils.useLatestRef(disabledIndices);
2370
- const latestOpenRef = require_floating_ui_react_utils.useLatestRef(open);
2371
- const scrollItemIntoViewRef = require_floating_ui_react_utils.useLatestRef(scrollItemIntoView);
2372
- const selectedIndexRef = require_floating_ui_react_utils.useLatestRef(selectedIndex);
2373
- const [activeId, setActiveId] = react.useState();
2374
- const [virtualId, setVirtualId] = react.useState();
2375
- const focusItem = require_floating_ui_react_utils.useEffectEvent(() => {
2376
- function runFocus(item$1) {
2377
- if (virtual) {
2378
- var _item$id;
2379
- if ((_item$id = item$1.id) != null && _item$id.endsWith("-fui-option")) item$1.id = floatingId + "-" + Math.random().toString(16).slice(2, 10);
2380
- setActiveId(item$1.id);
2381
- tree?.events.emit("virtualfocus", item$1);
2382
- if (virtualItemRef) virtualItemRef.current = item$1;
2383
- } else enqueueFocus(item$1, {
2384
- sync: forceSyncFocusRef.current,
2385
- preventScroll: true
2386
- });
2387
- }
2388
- const initialItem = listRef.current[indexRef.current];
2389
- const forceScrollIntoView = forceScrollIntoViewRef.current;
2390
- if (initialItem) runFocus(initialItem);
2391
- (forceSyncFocusRef.current ? (v) => v() : requestAnimationFrame)(() => {
2392
- const waitedItem = listRef.current[indexRef.current] || initialItem;
2393
- if (!waitedItem) return;
2394
- if (!initialItem) runFocus(waitedItem);
2395
- const scrollIntoViewOptions = scrollItemIntoViewRef.current;
2396
- if (scrollIntoViewOptions && item && (forceScrollIntoView || !isPointerModalityRef.current)) waitedItem.scrollIntoView == null || waitedItem.scrollIntoView(typeof scrollIntoViewOptions === "boolean" ? {
2397
- block: "nearest",
2398
- inline: "nearest"
2399
- } : scrollIntoViewOptions);
2400
- });
2401
- });
2402
- require_floating_ui_react_utils.index(() => {
2403
- if (!enabled) return;
2404
- if (open && elements.floating) {
2405
- if (focusItemOnOpenRef.current && selectedIndex != null) {
2406
- forceScrollIntoViewRef.current = true;
2407
- indexRef.current = selectedIndex;
2408
- onNavigate();
2409
- }
2410
- } else if (previousMountedRef.current) {
2411
- indexRef.current = -1;
2412
- previousOnNavigateRef.current();
2413
- }
2414
- }, [
2415
- enabled,
2416
- open,
2417
- elements.floating,
2418
- selectedIndex,
2419
- onNavigate
2420
- ]);
2421
- require_floating_ui_react_utils.index(() => {
2422
- if (!enabled) return;
2423
- if (!open) return;
2424
- if (!elements.floating) return;
2425
- if (activeIndex == null) {
2426
- forceSyncFocusRef.current = false;
2427
- if (selectedIndexRef.current != null) return;
2428
- if (previousMountedRef.current) {
2429
- indexRef.current = -1;
2430
- focusItem();
2431
- }
2432
- if ((!previousOpenRef.current || !previousMountedRef.current) && focusItemOnOpenRef.current && (keyRef.current != null || focusItemOnOpenRef.current === true && keyRef.current == null)) {
2433
- let runs = 0;
2434
- const waitForListPopulated = () => {
2435
- if (listRef.current[0] == null) {
2436
- if (runs < 2) (runs ? requestAnimationFrame : queueMicrotask)(waitForListPopulated);
2437
- runs++;
2438
- } else {
2439
- indexRef.current = keyRef.current == null || isMainOrientationToEndKey(keyRef.current, orientation, rtl) || nested ? require_floating_ui_react_utils.getMinListIndex(listRef, disabledIndicesRef.current) : require_floating_ui_react_utils.getMaxListIndex(listRef, disabledIndicesRef.current);
2440
- keyRef.current = null;
2441
- onNavigate();
2442
- }
2443
- };
2444
- waitForListPopulated();
2445
- }
2446
- } else if (!require_floating_ui_react_utils.isIndexOutOfListBounds(listRef, activeIndex)) {
2447
- indexRef.current = activeIndex;
2448
- focusItem();
2449
- forceScrollIntoViewRef.current = false;
2450
- }
2451
- }, [
2452
- enabled,
2453
- open,
2454
- elements.floating,
2455
- activeIndex,
2456
- selectedIndexRef,
2457
- nested,
2458
- listRef,
2459
- orientation,
2460
- rtl,
2461
- onNavigate,
2462
- focusItem,
2463
- disabledIndicesRef
2464
- ]);
2465
- require_floating_ui_react_utils.index(() => {
2466
- var _nodes$find;
2467
- if (!enabled || elements.floating || !tree || virtual || !previousMountedRef.current) return;
2468
- const nodes = tree.nodesRef.current;
2469
- const parent = (_nodes$find = nodes.find((node) => node.id === parentId)) == null || (_nodes$find = _nodes$find.context) == null ? void 0 : _nodes$find.elements.floating;
2470
- const activeEl = require_floating_ui_react_utils.activeElement(require_floating_ui_react_utils.getDocument(elements.floating));
2471
- const treeContainsActiveEl = nodes.some((node) => node.context && require_floating_ui_react_utils.contains(node.context.elements.floating, activeEl));
2472
- if (parent && !treeContainsActiveEl && isPointerModalityRef.current) parent.focus({ preventScroll: true });
2473
- }, [
2474
- enabled,
2475
- elements.floating,
2476
- tree,
2477
- parentId,
2478
- virtual
2479
- ]);
2480
- require_floating_ui_react_utils.index(() => {
2481
- if (!enabled) return;
2482
- if (!tree) return;
2483
- if (!virtual) return;
2484
- if (parentId) return;
2485
- function handleVirtualFocus(item$1) {
2486
- setVirtualId(item$1.id);
2487
- if (virtualItemRef) virtualItemRef.current = item$1;
2488
- }
2489
- tree.events.on("virtualfocus", handleVirtualFocus);
2490
- return () => {
2491
- tree.events.off("virtualfocus", handleVirtualFocus);
2492
- };
2493
- }, [
2494
- enabled,
2495
- tree,
2496
- virtual,
2497
- parentId,
2498
- virtualItemRef
2499
- ]);
2500
- require_floating_ui_react_utils.index(() => {
2501
- previousOnNavigateRef.current = onNavigate;
2502
- previousOpenRef.current = open;
2503
- previousMountedRef.current = !!elements.floating;
2504
- });
2505
- require_floating_ui_react_utils.index(() => {
2506
- if (!open) {
2507
- keyRef.current = null;
2508
- focusItemOnOpenRef.current = focusItemOnOpen;
2509
- }
2510
- }, [open, focusItemOnOpen]);
2511
- const hasActiveIndex = activeIndex != null;
2512
- const item = react.useMemo(() => {
2513
- function syncCurrentTarget(currentTarget) {
2514
- if (!latestOpenRef.current) return;
2515
- const index$1 = listRef.current.indexOf(currentTarget);
2516
- if (index$1 !== -1 && indexRef.current !== index$1) {
2517
- indexRef.current = index$1;
2518
- onNavigate();
2519
- }
2520
- }
2521
- return {
2522
- onFocus(_ref) {
2523
- let { currentTarget } = _ref;
2524
- forceSyncFocusRef.current = true;
2525
- syncCurrentTarget(currentTarget);
2526
- },
2527
- onClick: (_ref2) => {
2528
- let { currentTarget } = _ref2;
2529
- return currentTarget.focus({ preventScroll: true });
2530
- },
2531
- onMouseMove(_ref3) {
2532
- let { currentTarget } = _ref3;
2533
- forceSyncFocusRef.current = true;
2534
- forceScrollIntoViewRef.current = false;
2535
- if (focusItemOnHover) syncCurrentTarget(currentTarget);
2536
- },
2537
- onPointerLeave(_ref4) {
2538
- let { pointerType } = _ref4;
2539
- if (!isPointerModalityRef.current || pointerType === "touch") return;
2540
- forceSyncFocusRef.current = true;
2541
- if (!focusItemOnHover) return;
2542
- indexRef.current = -1;
2543
- onNavigate();
2544
- if (!virtual) {
2545
- var _floatingFocusElement;
2546
- (_floatingFocusElement = floatingFocusElementRef.current) == null || _floatingFocusElement.focus({ preventScroll: true });
2547
- }
2548
- }
2549
- };
2550
- }, [
2551
- latestOpenRef,
2552
- floatingFocusElementRef,
2553
- focusItemOnHover,
2554
- listRef,
2555
- onNavigate,
2556
- virtual
2557
- ]);
2558
- const getParentOrientation = react.useCallback(() => {
2559
- var _tree$nodesRef$curren;
2560
- return parentOrientation != null ? parentOrientation : tree == null || (_tree$nodesRef$curren = tree.nodesRef.current.find((node) => node.id === parentId)) == null || (_tree$nodesRef$curren = _tree$nodesRef$curren.context) == null || (_tree$nodesRef$curren = _tree$nodesRef$curren.dataRef) == null ? void 0 : _tree$nodesRef$curren.current.orientation;
2561
- }, [
2562
- parentId,
2563
- tree,
2564
- parentOrientation
2565
- ]);
2566
- const commonOnKeyDown = require_floating_ui_react_utils.useEffectEvent((event) => {
2567
- isPointerModalityRef.current = false;
2568
- forceSyncFocusRef.current = true;
2569
- if (event.which === 229) return;
2570
- if (!latestOpenRef.current && event.currentTarget === floatingFocusElementRef.current) return;
2571
- if (nested && isCrossOrientationCloseKey(event.key, orientation, rtl, cols)) {
2572
- if (!isMainOrientationKey(event.key, getParentOrientation())) require_floating_ui_react_utils.stopEvent(event);
2573
- onOpenChange(false, event.nativeEvent, "list-navigation");
2574
- if (require_floating_ui_utils_dom.isHTMLElement(elements.domReference)) if (virtual) tree?.events.emit("virtualfocus", elements.domReference);
2575
- else elements.domReference.focus();
2576
- return;
2577
- }
2578
- const currentIndex = indexRef.current;
2579
- const minIndex = require_floating_ui_react_utils.getMinListIndex(listRef, disabledIndices);
2580
- const maxIndex = require_floating_ui_react_utils.getMaxListIndex(listRef, disabledIndices);
2581
- if (!typeableComboboxReference) {
2582
- if (event.key === "Home") {
2583
- require_floating_ui_react_utils.stopEvent(event);
2584
- indexRef.current = minIndex;
2585
- onNavigate();
2586
- }
2587
- if (event.key === "End") {
2588
- require_floating_ui_react_utils.stopEvent(event);
2589
- indexRef.current = maxIndex;
2590
- onNavigate();
2591
- }
2592
- }
2593
- if (cols > 1) {
2594
- const sizes = itemSizes || Array.from({ length: listRef.current.length }, () => ({
2595
- width: 1,
2596
- height: 1
2597
- }));
2598
- const cellMap = require_floating_ui_react_utils.createGridCellMap(sizes, cols, dense);
2599
- const minGridIndex = cellMap.findIndex((index$2) => index$2 != null && !require_floating_ui_react_utils.isListIndexDisabled(listRef, index$2, disabledIndices));
2600
- const maxGridIndex = cellMap.reduce((foundIndex, index$2, cellIndex) => index$2 != null && !require_floating_ui_react_utils.isListIndexDisabled(listRef, index$2, disabledIndices) ? cellIndex : foundIndex, -1);
2601
- const index$1 = cellMap[require_floating_ui_react_utils.getGridNavigatedIndex({ current: cellMap.map((itemIndex) => itemIndex != null ? listRef.current[itemIndex] : null) }, {
2602
- event,
2603
- orientation,
2604
- loop,
2605
- rtl,
2606
- cols,
2607
- disabledIndices: require_floating_ui_react_utils.getGridCellIndices([...(typeof disabledIndices !== "function" ? disabledIndices : null) || listRef.current.map((_, index$2) => require_floating_ui_react_utils.isListIndexDisabled(listRef, index$2, disabledIndices) ? index$2 : void 0), void 0], cellMap),
2608
- minIndex: minGridIndex,
2609
- maxIndex: maxGridIndex,
2610
- prevIndex: require_floating_ui_react_utils.getGridCellIndexOfCorner(indexRef.current > maxIndex ? minIndex : indexRef.current, sizes, cellMap, cols, event.key === ARROW_DOWN ? "bl" : event.key === (rtl ? ARROW_LEFT : ARROW_RIGHT) ? "tr" : "tl"),
2611
- stopEvent: true
2612
- })];
2613
- if (index$1 != null) {
2614
- indexRef.current = index$1;
2615
- onNavigate();
2616
- }
2617
- if (orientation === "both") return;
2618
- }
2619
- if (isMainOrientationKey(event.key, orientation)) {
2620
- require_floating_ui_react_utils.stopEvent(event);
2621
- if (open && !virtual && require_floating_ui_react_utils.activeElement(event.currentTarget.ownerDocument) === event.currentTarget) {
2622
- indexRef.current = isMainOrientationToEndKey(event.key, orientation, rtl) ? minIndex : maxIndex;
2623
- onNavigate();
2624
- return;
2625
- }
2626
- if (isMainOrientationToEndKey(event.key, orientation, rtl)) if (loop) indexRef.current = currentIndex >= maxIndex ? allowEscape && currentIndex !== listRef.current.length ? -1 : minIndex : require_floating_ui_react_utils.findNonDisabledListIndex(listRef, {
2627
- startingIndex: currentIndex,
2628
- disabledIndices
2629
- });
2630
- else indexRef.current = Math.min(maxIndex, require_floating_ui_react_utils.findNonDisabledListIndex(listRef, {
2631
- startingIndex: currentIndex,
2632
- disabledIndices
2633
- }));
2634
- else if (loop) indexRef.current = currentIndex <= minIndex ? allowEscape && currentIndex !== -1 ? listRef.current.length : maxIndex : require_floating_ui_react_utils.findNonDisabledListIndex(listRef, {
2635
- startingIndex: currentIndex,
2636
- decrement: true,
2637
- disabledIndices
2638
- });
2639
- else indexRef.current = Math.max(minIndex, require_floating_ui_react_utils.findNonDisabledListIndex(listRef, {
2640
- startingIndex: currentIndex,
2641
- decrement: true,
2642
- disabledIndices
2643
- }));
2644
- if (require_floating_ui_react_utils.isIndexOutOfListBounds(listRef, indexRef.current)) indexRef.current = -1;
2645
- onNavigate();
2646
- }
2647
- });
2648
- const ariaActiveDescendantProp = react.useMemo(() => {
2649
- return virtual && open && hasActiveIndex && { "aria-activedescendant": virtualId || activeId };
2650
- }, [
2651
- virtual,
2652
- open,
2653
- hasActiveIndex,
2654
- virtualId,
2655
- activeId
2656
- ]);
2657
- const floating = react.useMemo(() => {
2658
- return {
2659
- "aria-orientation": orientation === "both" ? void 0 : orientation,
2660
- ...!typeableComboboxReference ? ariaActiveDescendantProp : {},
2661
- onKeyDown: commonOnKeyDown,
2662
- onPointerMove() {
2663
- isPointerModalityRef.current = true;
2664
- }
2665
- };
2666
- }, [
2667
- ariaActiveDescendantProp,
2668
- commonOnKeyDown,
2669
- orientation,
2670
- typeableComboboxReference
2671
- ]);
2672
- const reference = react.useMemo(() => {
2673
- function checkVirtualMouse(event) {
2674
- if (focusItemOnOpen === "auto" && require_floating_ui_react_utils.isVirtualClick(event.nativeEvent)) focusItemOnOpenRef.current = true;
2675
- }
2676
- function checkVirtualPointer(event) {
2677
- focusItemOnOpenRef.current = focusItemOnOpen;
2678
- if (focusItemOnOpen === "auto" && require_floating_ui_react_utils.isVirtualPointerEvent(event.nativeEvent)) focusItemOnOpenRef.current = true;
2679
- }
2680
- return {
2681
- ...ariaActiveDescendantProp,
2682
- onKeyDown(event) {
2683
- isPointerModalityRef.current = false;
2684
- const isArrowKey = event.key.startsWith("Arrow");
2685
- const isHomeOrEndKey = ["Home", "End"].includes(event.key);
2686
- const isMoveKey = isArrowKey || isHomeOrEndKey;
2687
- const isCrossOpenKey = isCrossOrientationOpenKey(event.key, orientation, rtl);
2688
- const isCrossCloseKey = isCrossOrientationCloseKey(event.key, orientation, rtl, cols);
2689
- const isParentCrossOpenKey = isCrossOrientationOpenKey(event.key, getParentOrientation(), rtl);
2690
- const isMainKey = isMainOrientationKey(event.key, orientation);
2691
- const isNavigationKey = (nested ? isParentCrossOpenKey : isMainKey) || event.key === "Enter" || event.key.trim() === "";
2692
- if (virtual && open) {
2693
- const rootNode = tree == null ? void 0 : tree.nodesRef.current.find((node) => node.parentId == null);
2694
- const deepestNode = tree && rootNode ? require_floating_ui_react_utils.getDeepestNode(tree.nodesRef.current, rootNode.id) : null;
2695
- if (isMoveKey && deepestNode && virtualItemRef) {
2696
- const eventObject = new KeyboardEvent("keydown", {
2697
- key: event.key,
2698
- bubbles: true
2699
- });
2700
- if (isCrossOpenKey || isCrossCloseKey) {
2701
- var _deepestNode$context, _deepestNode$context2;
2702
- const isCurrentTarget = ((_deepestNode$context = deepestNode.context) == null ? void 0 : _deepestNode$context.elements.domReference) === event.currentTarget;
2703
- const dispatchItem = isCrossCloseKey && !isCurrentTarget ? (_deepestNode$context2 = deepestNode.context) == null ? void 0 : _deepestNode$context2.elements.domReference : isCrossOpenKey ? listRef.current.find((item$1) => (item$1 == null ? void 0 : item$1.id) === activeId) : null;
2704
- if (dispatchItem) {
2705
- require_floating_ui_react_utils.stopEvent(event);
2706
- dispatchItem.dispatchEvent(eventObject);
2707
- setVirtualId(void 0);
2708
- }
2709
- }
2710
- if ((isMainKey || isHomeOrEndKey) && deepestNode.context) {
2711
- if (deepestNode.context.open && deepestNode.parentId && event.currentTarget !== deepestNode.context.elements.domReference) {
2712
- var _deepestNode$context$;
2713
- require_floating_ui_react_utils.stopEvent(event);
2714
- (_deepestNode$context$ = deepestNode.context.elements.domReference) == null || _deepestNode$context$.dispatchEvent(eventObject);
2715
- return;
2716
- }
2717
- }
2718
- }
2719
- return commonOnKeyDown(event);
2720
- }
2721
- if (!open && !openOnArrowKeyDown && isArrowKey) return;
2722
- if (isNavigationKey) {
2723
- const isParentMainKey = isMainOrientationKey(event.key, getParentOrientation());
2724
- keyRef.current = nested && isParentMainKey ? null : event.key;
2725
- }
2726
- if (nested) {
2727
- if (isParentCrossOpenKey) {
2728
- require_floating_ui_react_utils.stopEvent(event);
2729
- if (open) {
2730
- indexRef.current = require_floating_ui_react_utils.getMinListIndex(listRef, disabledIndicesRef.current);
2731
- onNavigate();
2732
- } else onOpenChange(true, event.nativeEvent, "list-navigation");
2733
- }
2734
- return;
2735
- }
2736
- if (isMainKey) {
2737
- if (selectedIndex != null) indexRef.current = selectedIndex;
2738
- require_floating_ui_react_utils.stopEvent(event);
2739
- if (!open && openOnArrowKeyDown) onOpenChange(true, event.nativeEvent, "list-navigation");
2740
- else commonOnKeyDown(event);
2741
- if (open) onNavigate();
2742
- }
2743
- },
2744
- onFocus() {
2745
- if (open && !virtual) {
2746
- indexRef.current = -1;
2747
- onNavigate();
2748
- }
2749
- },
2750
- onPointerDown: checkVirtualPointer,
2751
- onPointerEnter: checkVirtualPointer,
2752
- onMouseDown: checkVirtualMouse,
2753
- onClick: checkVirtualMouse
2754
- };
2755
- }, [
2756
- activeId,
2757
- ariaActiveDescendantProp,
2758
- cols,
2759
- commonOnKeyDown,
2760
- disabledIndicesRef,
2761
- focusItemOnOpen,
2762
- listRef,
2763
- nested,
2764
- onNavigate,
2765
- onOpenChange,
2766
- open,
2767
- openOnArrowKeyDown,
2768
- orientation,
2769
- getParentOrientation,
2770
- rtl,
2771
- selectedIndex,
2772
- tree,
2773
- virtual,
2774
- virtualItemRef
2775
- ]);
2776
- return react.useMemo(() => enabled ? {
2777
- reference,
2778
- floating,
2779
- item
2780
- } : {}, [
2781
- enabled,
2782
- reference,
2783
- floating,
2784
- item
2785
- ]);
2786
- }
2787
- /**
2788
- * Adds base screen reader props to the reference and floating elements for a
2789
- * given floating element `role`.
2790
- * @see https://floating-ui.com/docs/useRole
2791
- */
2792
- function useRole(context, props) {
2793
- var _elements$domReferenc, _componentRoleToAriaR;
2794
- if (props === void 0) props = {};
2795
- const { open, elements, floatingId: defaultFloatingId } = context;
2796
- const { enabled = true, role = "dialog" } = props;
2797
- const defaultReferenceId = useId();
2798
- const referenceId = ((_elements$domReferenc = elements.domReference) == null ? void 0 : _elements$domReferenc.id) || defaultReferenceId;
2799
- const floatingId = react.useMemo(() => {
2800
- var _getFloatingFocusElem;
2801
- return ((_getFloatingFocusElem = require_floating_ui_react_utils.getFloatingFocusElement(elements.floating)) == null ? void 0 : _getFloatingFocusElem.id) || defaultFloatingId;
2802
- }, [elements.floating, defaultFloatingId]);
2803
- const ariaRole = (_componentRoleToAriaR = componentRoleToAriaRoleMap.get(role)) != null ? _componentRoleToAriaR : role;
2804
- const isNested = useFloatingParentNodeId() != null;
2805
- const reference = react.useMemo(() => {
2806
- if (ariaRole === "tooltip" || role === "label") return { ["aria-" + (role === "label" ? "labelledby" : "describedby")]: open ? floatingId : void 0 };
2807
- return {
2808
- "aria-expanded": open ? "true" : "false",
2809
- "aria-haspopup": ariaRole === "alertdialog" ? "dialog" : ariaRole,
2810
- "aria-controls": open ? floatingId : void 0,
2811
- ...ariaRole === "listbox" && { role: "combobox" },
2812
- ...ariaRole === "menu" && { id: referenceId },
2813
- ...ariaRole === "menu" && isNested && { role: "menuitem" },
2814
- ...role === "select" && { "aria-autocomplete": "none" },
2815
- ...role === "combobox" && { "aria-autocomplete": "list" }
2816
- };
2817
- }, [
2818
- ariaRole,
2819
- floatingId,
2820
- isNested,
2821
- open,
2822
- referenceId,
2823
- role
2824
- ]);
2825
- const floating = react.useMemo(() => {
2826
- const floatingProps = {
2827
- id: floatingId,
2828
- ...ariaRole && { role: ariaRole }
2829
- };
2830
- if (ariaRole === "tooltip" || role === "label") return floatingProps;
2831
- return {
2832
- ...floatingProps,
2833
- ...ariaRole === "menu" && { "aria-labelledby": referenceId }
2834
- };
2835
- }, [
2836
- ariaRole,
2837
- floatingId,
2838
- referenceId,
2839
- role
2840
- ]);
2841
- const item = react.useCallback((_ref) => {
2842
- let { active, selected } = _ref;
2843
- const commonProps = {
2844
- role: "option",
2845
- ...active && { id: floatingId + "-fui-option" }
2846
- };
2847
- switch (role) {
2848
- case "select":
2849
- case "combobox": return {
2850
- ...commonProps,
2851
- "aria-selected": selected
2852
- };
2853
- }
2854
- return {};
2855
- }, [floatingId, role]);
2856
- return react.useMemo(() => enabled ? {
2857
- reference,
2858
- floating,
2859
- item
2860
- } : {}, [
2861
- enabled,
2862
- reference,
2863
- floating,
2864
- item
2865
- ]);
2866
- }
2867
- function execWithArgsOrReturn(valueOrFn, args) {
2868
- return typeof valueOrFn === "function" ? valueOrFn(args) : valueOrFn;
2869
- }
2870
- function useDelayUnmount(open, durationMs) {
2871
- const [isMounted, setIsMounted] = react.useState(open);
2872
- if (open && !isMounted) setIsMounted(true);
2873
- react.useEffect(() => {
2874
- if (!open && isMounted) {
2875
- const timeout = setTimeout(() => setIsMounted(false), durationMs);
2876
- return () => clearTimeout(timeout);
2877
- }
2878
- }, [
2879
- open,
2880
- isMounted,
2881
- durationMs
2882
- ]);
2883
- return isMounted;
2884
- }
2885
- /**
2886
- * Provides a status string to apply CSS transitions to a floating element,
2887
- * correctly handling placement-aware transitions.
2888
- * @see https://floating-ui.com/docs/useTransition#usetransitionstatus
2889
- */
2890
- function useTransitionStatus(context, props) {
2891
- if (props === void 0) props = {};
2892
- const { open, elements: { floating } } = context;
2893
- const { duration = 250 } = props;
2894
- const closeDuration = (typeof duration === "number" ? duration : duration.close) || 0;
2895
- const [status, setStatus] = react.useState("unmounted");
2896
- const isMounted = useDelayUnmount(open, closeDuration);
2897
- if (!isMounted && status === "close") setStatus("unmounted");
2898
- require_floating_ui_react_utils.index(() => {
2899
- if (!floating) return;
2900
- if (open) {
2901
- setStatus("initial");
2902
- const frame = requestAnimationFrame(() => {
2903
- react_dom.flushSync(() => {
2904
- setStatus("open");
2905
- });
2906
- });
2907
- return () => {
2908
- cancelAnimationFrame(frame);
2909
- };
2910
- }
2911
- setStatus("close");
2912
- }, [open, floating]);
2913
- return {
2914
- isMounted,
2915
- status
2916
- };
2917
- }
2918
- /**
2919
- * Provides styles to apply CSS transitions to a floating element, correctly
2920
- * handling placement-aware transitions. Wrapper around `useTransitionStatus`.
2921
- * @see https://floating-ui.com/docs/useTransition#usetransitionstyles
2922
- */
2923
- function useTransitionStyles(context, props) {
2924
- if (props === void 0) props = {};
2925
- const { initial: unstable_initial = { opacity: 0 }, open: unstable_open, close: unstable_close, common: unstable_common, duration = 250 } = props;
2926
- const placement = context.placement;
2927
- const side = placement.split("-")[0];
2928
- const fnArgs = react.useMemo(() => ({
2929
- side,
2930
- placement
2931
- }), [side, placement]);
2932
- const isNumberDuration = typeof duration === "number";
2933
- const openDuration = (isNumberDuration ? duration : duration.open) || 0;
2934
- const closeDuration = (isNumberDuration ? duration : duration.close) || 0;
2935
- const [styles, setStyles] = react.useState(() => ({
2936
- ...execWithArgsOrReturn(unstable_common, fnArgs),
2937
- ...execWithArgsOrReturn(unstable_initial, fnArgs)
2938
- }));
2939
- const { isMounted, status } = useTransitionStatus(context, { duration });
2940
- const initialRef = require_floating_ui_react_utils.useLatestRef(unstable_initial);
2941
- const openRef = require_floating_ui_react_utils.useLatestRef(unstable_open);
2942
- const closeRef = require_floating_ui_react_utils.useLatestRef(unstable_close);
2943
- const commonRef = require_floating_ui_react_utils.useLatestRef(unstable_common);
2944
- require_floating_ui_react_utils.index(() => {
2945
- const initialStyles = execWithArgsOrReturn(initialRef.current, fnArgs);
2946
- const closeStyles = execWithArgsOrReturn(closeRef.current, fnArgs);
2947
- const commonStyles = execWithArgsOrReturn(commonRef.current, fnArgs);
2948
- const openStyles = execWithArgsOrReturn(openRef.current, fnArgs) || Object.keys(initialStyles).reduce((acc, key) => {
2949
- acc[key] = "";
2950
- return acc;
2951
- }, {});
2952
- if (status === "initial") setStyles((styles$1) => ({
2953
- transitionProperty: styles$1.transitionProperty,
2954
- ...commonStyles,
2955
- ...initialStyles
2956
- }));
2957
- if (status === "open") setStyles({
2958
- transitionProperty: Object.keys(openStyles).map(camelCaseToKebabCase).join(","),
2959
- transitionDuration: openDuration + "ms",
2960
- ...commonStyles,
2961
- ...openStyles
2962
- });
2963
- if (status === "close") {
2964
- const styles$1 = closeStyles || initialStyles;
2965
- setStyles({
2966
- transitionProperty: Object.keys(styles$1).map(camelCaseToKebabCase).join(","),
2967
- transitionDuration: closeDuration + "ms",
2968
- ...commonStyles,
2969
- ...styles$1
2970
- });
2971
- }
2972
- }, [
2973
- closeDuration,
2974
- closeRef,
2975
- initialRef,
2976
- openRef,
2977
- commonRef,
2978
- openDuration,
2979
- status,
2980
- fnArgs
2981
- ]);
2982
- return {
2983
- isMounted,
2984
- styles
2985
- };
2986
- }
2987
- /**
2988
- * Provides a matching callback that can be used to focus an item as the user
2989
- * types, often used in tandem with `useListNavigation()`.
2990
- * @see https://floating-ui.com/docs/useTypeahead
2991
- */
2992
- function useTypeahead(context, props) {
2993
- var _ref;
2994
- const { open, dataRef } = context;
2995
- const { listRef, activeIndex, onMatch: unstable_onMatch, onTypingChange: unstable_onTypingChange, enabled = true, findMatch = null, resetMs = 750, ignoreKeys = [], selectedIndex = null } = props;
2996
- const timeoutIdRef = react.useRef(-1);
2997
- const stringRef = react.useRef("");
2998
- const prevIndexRef = react.useRef((_ref = selectedIndex != null ? selectedIndex : activeIndex) != null ? _ref : -1);
2999
- const matchIndexRef = react.useRef(null);
3000
- const onMatch = require_floating_ui_react_utils.useEffectEvent(unstable_onMatch);
3001
- const onTypingChange = require_floating_ui_react_utils.useEffectEvent(unstable_onTypingChange);
3002
- const findMatchRef = require_floating_ui_react_utils.useLatestRef(findMatch);
3003
- const ignoreKeysRef = require_floating_ui_react_utils.useLatestRef(ignoreKeys);
3004
- require_floating_ui_react_utils.index(() => {
3005
- if (open) {
3006
- clearTimeoutIfSet(timeoutIdRef);
3007
- matchIndexRef.current = null;
3008
- stringRef.current = "";
3009
- }
3010
- }, [open]);
3011
- require_floating_ui_react_utils.index(() => {
3012
- if (open && stringRef.current === "") {
3013
- var _ref2;
3014
- prevIndexRef.current = (_ref2 = selectedIndex != null ? selectedIndex : activeIndex) != null ? _ref2 : -1;
3015
- }
3016
- }, [
3017
- open,
3018
- selectedIndex,
3019
- activeIndex
3020
- ]);
3021
- const setTypingChange = require_floating_ui_react_utils.useEffectEvent((value) => {
3022
- if (value) {
3023
- if (!dataRef.current.typing) {
3024
- dataRef.current.typing = value;
3025
- onTypingChange(value);
3026
- }
3027
- } else if (dataRef.current.typing) {
3028
- dataRef.current.typing = value;
3029
- onTypingChange(value);
3030
- }
3031
- });
3032
- const onKeyDown = require_floating_ui_react_utils.useEffectEvent((event) => {
3033
- function getMatchingIndex(list, orderedList, string) {
3034
- const str = findMatchRef.current ? findMatchRef.current(orderedList, string) : orderedList.find((text) => (text == null ? void 0 : text.toLocaleLowerCase().indexOf(string.toLocaleLowerCase())) === 0);
3035
- return str ? list.indexOf(str) : -1;
3036
- }
3037
- const listContent = listRef.current;
3038
- if (stringRef.current.length > 0 && stringRef.current[0] !== " ") {
3039
- if (getMatchingIndex(listContent, listContent, stringRef.current) === -1) setTypingChange(false);
3040
- else if (event.key === " ") require_floating_ui_react_utils.stopEvent(event);
3041
- }
3042
- if (listContent == null || ignoreKeysRef.current.includes(event.key) || event.key.length !== 1 || event.ctrlKey || event.metaKey || event.altKey) return;
3043
- if (open && event.key !== " ") {
3044
- require_floating_ui_react_utils.stopEvent(event);
3045
- setTypingChange(true);
3046
- }
3047
- if (listContent.every((text) => {
3048
- var _text$, _text$2;
3049
- return text ? ((_text$ = text[0]) == null ? void 0 : _text$.toLocaleLowerCase()) !== ((_text$2 = text[1]) == null ? void 0 : _text$2.toLocaleLowerCase()) : true;
3050
- }) && stringRef.current === event.key) {
3051
- stringRef.current = "";
3052
- prevIndexRef.current = matchIndexRef.current;
3053
- }
3054
- stringRef.current += event.key;
3055
- clearTimeoutIfSet(timeoutIdRef);
3056
- timeoutIdRef.current = window.setTimeout(() => {
3057
- stringRef.current = "";
3058
- prevIndexRef.current = matchIndexRef.current;
3059
- setTypingChange(false);
3060
- }, resetMs);
3061
- const prevIndex = prevIndexRef.current;
3062
- const index$1 = getMatchingIndex(listContent, [...listContent.slice((prevIndex || 0) + 1), ...listContent.slice(0, (prevIndex || 0) + 1)], stringRef.current);
3063
- if (index$1 !== -1) {
3064
- onMatch(index$1);
3065
- matchIndexRef.current = index$1;
3066
- } else if (event.key !== " ") {
3067
- stringRef.current = "";
3068
- setTypingChange(false);
3069
- }
3070
- });
3071
- const reference = react.useMemo(() => ({ onKeyDown }), [onKeyDown]);
3072
- const floating = react.useMemo(() => {
3073
- return {
3074
- onKeyDown,
3075
- onKeyUp(event) {
3076
- if (event.key === " ") setTypingChange(false);
3077
- }
3078
- };
3079
- }, [onKeyDown, setTypingChange]);
3080
- return react.useMemo(() => enabled ? {
3081
- reference,
3082
- floating
3083
- } : {}, [
3084
- enabled,
3085
- reference,
3086
- floating
3087
- ]);
3088
- }
3089
- function getArgsWithCustomFloatingHeight(state, height) {
3090
- return {
3091
- ...state,
3092
- rects: {
3093
- ...state.rects,
3094
- floating: {
3095
- ...state.rects.floating,
3096
- height
3097
- }
3098
- }
3099
- };
3100
- }
3101
- /**
3102
- * Changes the `inner` middleware's `offset` upon a `wheel` event to
3103
- * expand the floating element's height, revealing more list items.
3104
- * @see https://floating-ui.com/docs/inner
3105
- * @deprecated
3106
- */
3107
- function useInnerOffset(context, props) {
3108
- const { open, elements } = context;
3109
- const { enabled = true, overflowRef, scrollRef, onChange: unstable_onChange } = props;
3110
- const onChange = require_floating_ui_react_utils.useEffectEvent(unstable_onChange);
3111
- const controlledScrollingRef = react.useRef(false);
3112
- const prevScrollTopRef = react.useRef(null);
3113
- const initialOverflowRef = react.useRef(null);
3114
- react.useEffect(() => {
3115
- if (!enabled) return;
3116
- function onWheel(e) {
3117
- if (e.ctrlKey || !el || overflowRef.current == null) return;
3118
- const dY = e.deltaY;
3119
- const isAtTop = overflowRef.current.top >= -.5;
3120
- const isAtBottom = overflowRef.current.bottom >= -.5;
3121
- const remainingScroll = el.scrollHeight - el.clientHeight;
3122
- const sign = dY < 0 ? -1 : 1;
3123
- const method = dY < 0 ? "max" : "min";
3124
- if (el.scrollHeight <= el.clientHeight) return;
3125
- if (!isAtTop && dY > 0 || !isAtBottom && dY < 0) {
3126
- e.preventDefault();
3127
- react_dom.flushSync(() => {
3128
- onChange((d) => d + Math[method](dY, remainingScroll * sign));
3129
- });
3130
- } else if (/firefox/i.test(require_floating_ui_react_utils.getUserAgent())) el.scrollTop += dY;
3131
- }
3132
- const el = (scrollRef == null ? void 0 : scrollRef.current) || elements.floating;
3133
- if (open && el) {
3134
- el.addEventListener("wheel", onWheel);
3135
- requestAnimationFrame(() => {
3136
- prevScrollTopRef.current = el.scrollTop;
3137
- if (overflowRef.current != null) initialOverflowRef.current = { ...overflowRef.current };
3138
- });
3139
- return () => {
3140
- prevScrollTopRef.current = null;
3141
- initialOverflowRef.current = null;
3142
- el.removeEventListener("wheel", onWheel);
3143
- };
3144
- }
3145
- }, [
3146
- enabled,
3147
- open,
3148
- elements.floating,
3149
- overflowRef,
3150
- scrollRef,
3151
- onChange
3152
- ]);
3153
- const floating = react.useMemo(() => ({
3154
- onKeyDown() {
3155
- controlledScrollingRef.current = true;
3156
- },
3157
- onWheel() {
3158
- controlledScrollingRef.current = false;
3159
- },
3160
- onPointerMove() {
3161
- controlledScrollingRef.current = false;
3162
- },
3163
- onScroll() {
3164
- const el = (scrollRef == null ? void 0 : scrollRef.current) || elements.floating;
3165
- if (!overflowRef.current || !el || !controlledScrollingRef.current) return;
3166
- if (prevScrollTopRef.current !== null) {
3167
- const scrollDiff = el.scrollTop - prevScrollTopRef.current;
3168
- if (overflowRef.current.bottom < -.5 && scrollDiff < -1 || overflowRef.current.top < -.5 && scrollDiff > 1) react_dom.flushSync(() => onChange((d) => d + scrollDiff));
3169
- }
3170
- requestAnimationFrame(() => {
3171
- prevScrollTopRef.current = el.scrollTop;
3172
- });
3173
- }
3174
- }), [
3175
- elements.floating,
3176
- onChange,
3177
- overflowRef,
3178
- scrollRef
3179
- ]);
3180
- return react.useMemo(() => enabled ? { floating } : {}, [enabled, floating]);
3181
- }
3182
- function getNodeChildren$1(nodes, id, onlyOpenChildren) {
3183
- if (onlyOpenChildren === void 0) onlyOpenChildren = true;
3184
- return nodes.filter((node) => {
3185
- var _node$context;
3186
- return node.parentId === id && (!onlyOpenChildren || ((_node$context = node.context) == null ? void 0 : _node$context.open));
3187
- }).flatMap((child) => [child, ...getNodeChildren$1(nodes, child.id, onlyOpenChildren)]);
3188
- }
3189
- function isPointInPolygon(point, polygon) {
3190
- const [x, y] = point;
3191
- let isInside$1 = false;
3192
- const length = polygon.length;
3193
- for (let i = 0, j = length - 1; i < length; j = i++) {
3194
- const [xi, yi] = polygon[i] || [0, 0];
3195
- const [xj, yj] = polygon[j] || [0, 0];
3196
- if (yi >= y !== yj >= y && x <= (xj - xi) * (y - yi) / (yj - yi) + xi) isInside$1 = !isInside$1;
3197
- }
3198
- return isInside$1;
3199
- }
3200
- function isInside(point, rect) {
3201
- return point[0] >= rect.x && point[0] <= rect.x + rect.width && point[1] >= rect.y && point[1] <= rect.y + rect.height;
3202
- }
3203
- /**
3204
- * Generates a safe polygon area that the user can traverse without closing the
3205
- * floating element once leaving the reference element.
3206
- * @see https://floating-ui.com/docs/useHover#safepolygon
3207
- */
3208
- function safePolygon(options) {
3209
- if (options === void 0) options = {};
3210
- const { buffer = .5, blockPointerEvents = false, requireIntent = true } = options;
3211
- const timeoutRef = { current: -1 };
3212
- let hasLanded = false;
3213
- let lastX = null;
3214
- let lastY = null;
3215
- let lastCursorTime = typeof performance !== "undefined" ? performance.now() : 0;
3216
- function getCursorSpeed(x, y) {
3217
- const currentTime = performance.now();
3218
- const elapsedTime = currentTime - lastCursorTime;
3219
- if (lastX === null || lastY === null || elapsedTime === 0) {
3220
- lastX = x;
3221
- lastY = y;
3222
- lastCursorTime = currentTime;
3223
- return null;
3224
- }
3225
- const deltaX = x - lastX;
3226
- const deltaY = y - lastY;
3227
- const speed = Math.sqrt(deltaX * deltaX + deltaY * deltaY) / elapsedTime;
3228
- lastX = x;
3229
- lastY = y;
3230
- lastCursorTime = currentTime;
3231
- return speed;
3232
- }
3233
- const fn = (_ref) => {
3234
- let { x, y, placement, elements, onClose, nodeId, tree } = _ref;
3235
- return function onMouseMove(event) {
3236
- function close() {
3237
- clearTimeoutIfSet(timeoutRef);
3238
- onClose();
3239
- }
3240
- clearTimeoutIfSet(timeoutRef);
3241
- if (!elements.domReference || !elements.floating || placement == null || x == null || y == null) return;
3242
- const { clientX, clientY } = event;
3243
- const clientPoint = [clientX, clientY];
3244
- const target = getTarget$1(event);
3245
- const isLeave = event.type === "mouseleave";
3246
- const isOverFloatingEl = contains$1(elements.floating, target);
3247
- const isOverReferenceEl = contains$1(elements.domReference, target);
3248
- const refRect = elements.domReference.getBoundingClientRect();
3249
- const rect = elements.floating.getBoundingClientRect();
3250
- const side = placement.split("-")[0];
3251
- const cursorLeaveFromRight = x > rect.right - rect.width / 2;
3252
- const cursorLeaveFromBottom = y > rect.bottom - rect.height / 2;
3253
- const isOverReferenceRect = isInside(clientPoint, refRect);
3254
- const isFloatingWider = rect.width > refRect.width;
3255
- const isFloatingTaller = rect.height > refRect.height;
3256
- const left = (isFloatingWider ? refRect : rect).left;
3257
- const right = (isFloatingWider ? refRect : rect).right;
3258
- const top = (isFloatingTaller ? refRect : rect).top;
3259
- const bottom = (isFloatingTaller ? refRect : rect).bottom;
3260
- if (isOverFloatingEl) {
3261
- hasLanded = true;
3262
- if (!isLeave) return;
3263
- }
3264
- if (isOverReferenceEl) hasLanded = false;
3265
- if (isOverReferenceEl && !isLeave) {
3266
- hasLanded = true;
3267
- return;
3268
- }
3269
- if (isLeave && require_floating_ui_utils_dom.isElement(event.relatedTarget) && contains$1(elements.floating, event.relatedTarget)) return;
3270
- if (tree && getNodeChildren$1(tree.nodesRef.current, nodeId).length) return;
3271
- if (side === "top" && y >= refRect.bottom - 1 || side === "bottom" && y <= refRect.top + 1 || side === "left" && x >= refRect.right - 1 || side === "right" && x <= refRect.left + 1) return close();
3272
- let rectPoly = [];
3273
- switch (side) {
3274
- case "top":
3275
- rectPoly = [
3276
- [left, refRect.top + 1],
3277
- [left, rect.bottom - 1],
3278
- [right, rect.bottom - 1],
3279
- [right, refRect.top + 1]
3280
- ];
3281
- break;
3282
- case "bottom":
3283
- rectPoly = [
3284
- [left, rect.top + 1],
3285
- [left, refRect.bottom - 1],
3286
- [right, refRect.bottom - 1],
3287
- [right, rect.top + 1]
3288
- ];
3289
- break;
3290
- case "left":
3291
- rectPoly = [
3292
- [rect.right - 1, bottom],
3293
- [rect.right - 1, top],
3294
- [refRect.left + 1, top],
3295
- [refRect.left + 1, bottom]
3296
- ];
3297
- break;
3298
- case "right":
3299
- rectPoly = [
3300
- [refRect.right - 1, bottom],
3301
- [refRect.right - 1, top],
3302
- [rect.left + 1, top],
3303
- [rect.left + 1, bottom]
3304
- ];
3305
- break;
3306
- }
3307
- function getPolygon(_ref2) {
3308
- let [x$1, y$1] = _ref2;
3309
- switch (side) {
3310
- case "top": return [
3311
- [isFloatingWider ? x$1 + buffer / 2 : cursorLeaveFromRight ? x$1 + buffer * 4 : x$1 - buffer * 4, y$1 + buffer + 1],
3312
- [isFloatingWider ? x$1 - buffer / 2 : cursorLeaveFromRight ? x$1 + buffer * 4 : x$1 - buffer * 4, y$1 + buffer + 1],
3313
- ...[[rect.left, cursorLeaveFromRight ? rect.bottom - buffer : isFloatingWider ? rect.bottom - buffer : rect.top], [rect.right, cursorLeaveFromRight ? isFloatingWider ? rect.bottom - buffer : rect.top : rect.bottom - buffer]]
3314
- ];
3315
- case "bottom": return [
3316
- [isFloatingWider ? x$1 + buffer / 2 : cursorLeaveFromRight ? x$1 + buffer * 4 : x$1 - buffer * 4, y$1 - buffer],
3317
- [isFloatingWider ? x$1 - buffer / 2 : cursorLeaveFromRight ? x$1 + buffer * 4 : x$1 - buffer * 4, y$1 - buffer],
3318
- ...[[rect.left, cursorLeaveFromRight ? rect.top + buffer : isFloatingWider ? rect.top + buffer : rect.bottom], [rect.right, cursorLeaveFromRight ? isFloatingWider ? rect.top + buffer : rect.bottom : rect.top + buffer]]
3319
- ];
3320
- case "left": {
3321
- const cursorPointOne = [x$1 + buffer + 1, isFloatingTaller ? y$1 + buffer / 2 : cursorLeaveFromBottom ? y$1 + buffer * 4 : y$1 - buffer * 4];
3322
- const cursorPointTwo = [x$1 + buffer + 1, isFloatingTaller ? y$1 - buffer / 2 : cursorLeaveFromBottom ? y$1 + buffer * 4 : y$1 - buffer * 4];
3323
- return [
3324
- ...[[cursorLeaveFromBottom ? rect.right - buffer : isFloatingTaller ? rect.right - buffer : rect.left, rect.top], [cursorLeaveFromBottom ? isFloatingTaller ? rect.right - buffer : rect.left : rect.right - buffer, rect.bottom]],
3325
- cursorPointOne,
3326
- cursorPointTwo
3327
- ];
3328
- }
3329
- case "right": return [
3330
- [x$1 - buffer, isFloatingTaller ? y$1 + buffer / 2 : cursorLeaveFromBottom ? y$1 + buffer * 4 : y$1 - buffer * 4],
3331
- [x$1 - buffer, isFloatingTaller ? y$1 - buffer / 2 : cursorLeaveFromBottom ? y$1 + buffer * 4 : y$1 - buffer * 4],
3332
- ...[[cursorLeaveFromBottom ? rect.left + buffer : isFloatingTaller ? rect.left + buffer : rect.right, rect.top], [cursorLeaveFromBottom ? isFloatingTaller ? rect.left + buffer : rect.right : rect.left + buffer, rect.bottom]]
3333
- ];
3334
- }
3335
- }
3336
- if (isPointInPolygon([clientX, clientY], rectPoly)) return;
3337
- if (hasLanded && !isOverReferenceRect) return close();
3338
- if (!isLeave && requireIntent) {
3339
- const cursorSpeed = getCursorSpeed(event.clientX, event.clientY);
3340
- if (cursorSpeed !== null && cursorSpeed < .1) return close();
3341
- }
3342
- if (!isPointInPolygon([clientX, clientY], getPolygon([x, y]))) close();
3343
- else if (!hasLanded && requireIntent) timeoutRef.current = window.setTimeout(close, 40);
3344
- };
3345
- };
3346
- fn.__options = { blockPointerEvents };
3347
- return fn;
3348
- }
3349
- var import_dist, FloatingListContext, FOCUSABLE_ATTRIBUTE, ACTIVE_KEY, SELECTED_KEY, ARROW_LEFT, ARROW_RIGHT, ARROW_UP, ARROW_DOWN, CompositeContext, horizontalKeys, verticalKeys, allKeys, Composite, CompositeItem, SafeReact, serverHandoffComplete, count, genId, useId, devMessageSet, FloatingArrow, FloatingNodeContext, FloatingTreeContext, useFloatingParentNodeId, useFloatingTree, safePolygonIdentifier, NOOP, FloatingDelayGroupContext, useDelayGroupContext, NextFloatingDelayGroupContext, rafId, counters, uncontrolledElementsSet, markerMap, lockCount$1, supportsInert, unwrapHost, correctElements, HIDDEN_STYLES, FocusGuard, PortalContext, attr, usePortalContext, LIST_LIMIT, previouslyFocusedElements, VisuallyHiddenDismiss, lockCount, scrollbarProperty, cleanup, FloatingOverlay, bubbleHandlerKeys, captureHandlerKeys, normalizeProp, ESCAPE, componentRoleToAriaRoleMap, camelCaseToKebabCase, inner;
3350
- var init_floating_ui_react_esm = require_rolldown_runtime.__esm({ "../../node_modules/.pnpm/@floating-ui+react@0.27.16_react-dom@19.2.0_react@19.2.0__react@19.2.0/node_modules/@floating-ui/react/dist/floating-ui.react.esm.js": (() => {
3351
- require_floating_ui_react_utils.init_floating_ui_react_utils();
3352
- require_floating_ui_utils_dom.init_floating_ui_utils_dom();
3353
- import_dist = /* @__PURE__ */ require_rolldown_runtime.__toESM(require_index.require_dist());
3354
- require_floating_ui_react_dom.init_floating_ui_react_dom();
3355
- require_floating_ui_utils.init_floating_ui_utils();
3356
- FloatingListContext = /* @__PURE__ */ react.createContext({
3357
- register: () => {},
3358
- unregister: () => {},
3359
- map: /* @__PURE__ */ new Map(),
3360
- elementsRef: { current: [] }
3361
- });
3362
- FOCUSABLE_ATTRIBUTE = "data-floating-ui-focusable";
3363
- ACTIVE_KEY = "active";
3364
- SELECTED_KEY = "selected";
3365
- ARROW_LEFT = "ArrowLeft";
3366
- ARROW_RIGHT = "ArrowRight";
3367
- ARROW_UP = "ArrowUp";
3368
- ARROW_DOWN = "ArrowDown";
3369
- CompositeContext = /* @__PURE__ */ react.createContext({
3370
- activeIndex: 0,
3371
- onNavigate: () => {}
3372
- });
3373
- horizontalKeys = [ARROW_LEFT, ARROW_RIGHT];
3374
- verticalKeys = [ARROW_UP, ARROW_DOWN];
3375
- allKeys = [...horizontalKeys, ...verticalKeys];
3376
- Composite = /* @__PURE__ */ react.forwardRef(function Composite$1(props, forwardedRef) {
3377
- const { render, orientation = "both", loop = true, rtl = false, cols = 1, disabledIndices, activeIndex: externalActiveIndex, onNavigate: externalSetActiveIndex, itemSizes, dense = false,...domProps } = props;
3378
- const [internalActiveIndex, internalSetActiveIndex] = react.useState(0);
3379
- const activeIndex = externalActiveIndex != null ? externalActiveIndex : internalActiveIndex;
3380
- const onNavigate = require_floating_ui_react_utils.useEffectEvent(externalSetActiveIndex != null ? externalSetActiveIndex : internalSetActiveIndex);
3381
- const elementsRef = react.useRef([]);
3382
- const renderElementProps = render && typeof render !== "function" ? render.props : {};
3383
- const contextValue = react.useMemo(() => ({
3384
- activeIndex,
3385
- onNavigate
3386
- }), [activeIndex, onNavigate]);
3387
- const isGrid = cols > 1;
3388
- function handleKeyDown(event) {
3389
- if (!allKeys.includes(event.key)) return;
3390
- let nextIndex = activeIndex;
3391
- const minIndex = require_floating_ui_react_utils.getMinListIndex(elementsRef, disabledIndices);
3392
- const maxIndex = require_floating_ui_react_utils.getMaxListIndex(elementsRef, disabledIndices);
3393
- const horizontalEndKey = rtl ? ARROW_LEFT : ARROW_RIGHT;
3394
- const horizontalStartKey = rtl ? ARROW_RIGHT : ARROW_LEFT;
3395
- if (isGrid) {
3396
- const sizes = itemSizes || Array.from({ length: elementsRef.current.length }, () => ({
3397
- width: 1,
3398
- height: 1
3399
- }));
3400
- const cellMap = require_floating_ui_react_utils.createGridCellMap(sizes, cols, dense);
3401
- const minGridIndex = cellMap.findIndex((index$1) => index$1 != null && !require_floating_ui_react_utils.isListIndexDisabled(elementsRef, index$1, disabledIndices));
3402
- const maxGridIndex = cellMap.reduce((foundIndex, index$1, cellIndex) => index$1 != null && !require_floating_ui_react_utils.isListIndexDisabled(elementsRef, index$1, disabledIndices) ? cellIndex : foundIndex, -1);
3403
- const maybeNextIndex = cellMap[require_floating_ui_react_utils.getGridNavigatedIndex({ current: cellMap.map((itemIndex) => itemIndex ? elementsRef.current[itemIndex] : null) }, {
3404
- event,
3405
- orientation,
3406
- loop,
3407
- rtl,
3408
- cols,
3409
- disabledIndices: require_floating_ui_react_utils.getGridCellIndices([...(typeof disabledIndices !== "function" ? disabledIndices : null) || elementsRef.current.map((_, index$1) => require_floating_ui_react_utils.isListIndexDisabled(elementsRef, index$1, disabledIndices) ? index$1 : void 0), void 0], cellMap),
3410
- minIndex: minGridIndex,
3411
- maxIndex: maxGridIndex,
3412
- prevIndex: require_floating_ui_react_utils.getGridCellIndexOfCorner(activeIndex > maxIndex ? minIndex : activeIndex, sizes, cellMap, cols, event.key === ARROW_DOWN ? "bl" : event.key === horizontalEndKey ? "tr" : "tl")
3413
- })];
3414
- if (maybeNextIndex != null) nextIndex = maybeNextIndex;
3415
- }
3416
- const toEndKeys = {
3417
- horizontal: [horizontalEndKey],
3418
- vertical: [ARROW_DOWN],
3419
- both: [horizontalEndKey, ARROW_DOWN]
3420
- }[orientation];
3421
- const toStartKeys = {
3422
- horizontal: [horizontalStartKey],
3423
- vertical: [ARROW_UP],
3424
- both: [horizontalStartKey, ARROW_UP]
3425
- }[orientation];
3426
- const preventedKeys = isGrid ? allKeys : {
3427
- horizontal: horizontalKeys,
3428
- vertical: verticalKeys,
3429
- both: allKeys
3430
- }[orientation];
3431
- if (nextIndex === activeIndex && [...toEndKeys, ...toStartKeys].includes(event.key)) if (loop && nextIndex === maxIndex && toEndKeys.includes(event.key)) nextIndex = minIndex;
3432
- else if (loop && nextIndex === minIndex && toStartKeys.includes(event.key)) nextIndex = maxIndex;
3433
- else nextIndex = require_floating_ui_react_utils.findNonDisabledListIndex(elementsRef, {
3434
- startingIndex: nextIndex,
3435
- decrement: toStartKeys.includes(event.key),
3436
- disabledIndices
3437
- });
3438
- if (nextIndex !== activeIndex && !require_floating_ui_react_utils.isIndexOutOfListBounds(elementsRef, nextIndex)) {
3439
- var _elementsRef$current$;
3440
- event.stopPropagation();
3441
- if (preventedKeys.includes(event.key)) event.preventDefault();
3442
- onNavigate(nextIndex);
3443
- (_elementsRef$current$ = elementsRef.current[nextIndex]) == null || _elementsRef$current$.focus();
3444
- }
3445
- }
3446
- const computedProps = {
3447
- ...domProps,
3448
- ...renderElementProps,
3449
- ref: forwardedRef,
3450
- "aria-orientation": orientation === "both" ? void 0 : orientation,
3451
- onKeyDown(e) {
3452
- domProps.onKeyDown == null || domProps.onKeyDown(e);
3453
- renderElementProps.onKeyDown == null || renderElementProps.onKeyDown(e);
3454
- handleKeyDown(e);
3455
- }
3456
- };
3457
- return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(CompositeContext.Provider, {
3458
- value: contextValue,
3459
- children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(FloatingList, {
3460
- elementsRef,
3461
- children: renderJsx(render, computedProps)
3462
- })
3463
- });
3464
- });
3465
- CompositeItem = /* @__PURE__ */ react.forwardRef(function CompositeItem$1(props, forwardedRef) {
3466
- const { render,...domProps } = props;
3467
- const renderElementProps = render && typeof render !== "function" ? render.props : {};
3468
- const { activeIndex, onNavigate } = react.useContext(CompositeContext);
3469
- const { ref, index: index$1 } = useListItem();
3470
- const mergedRef = useMergeRefs([
3471
- ref,
3472
- forwardedRef,
3473
- renderElementProps.ref
3474
- ]);
3475
- const isActive = activeIndex === index$1;
3476
- return renderJsx(render, {
3477
- ...domProps,
3478
- ...renderElementProps,
3479
- ref: mergedRef,
3480
- tabIndex: isActive ? 0 : -1,
3481
- "data-active": isActive ? "" : void 0,
3482
- onFocus(e) {
3483
- domProps.onFocus == null || domProps.onFocus(e);
3484
- renderElementProps.onFocus == null || renderElementProps.onFocus(e);
3485
- onNavigate(index$1);
3486
- }
3487
- });
3488
- });
3489
- SafeReact = { ...react };
3490
- serverHandoffComplete = false;
3491
- count = 0;
3492
- genId = () => "floating-ui-" + Math.random().toString(36).slice(2, 6) + count++;
3493
- useId = SafeReact.useId || useFloatingId;
3494
- ;
3495
- if (process.env.NODE_ENV !== "production") devMessageSet = /* @__PURE__ */ new Set();
3496
- FloatingArrow = /* @__PURE__ */ react.forwardRef(function FloatingArrow$1(props, ref) {
3497
- const { context: { placement, elements: { floating }, middlewareData: { arrow: arrow$1, shift: shift$1 } }, width = 14, height = 7, tipRadius = 0, strokeWidth = 0, staticOffset, stroke, d, style: { transform,...restStyle } = {},...rest } = props;
3498
- if (process.env.NODE_ENV !== "production") {
3499
- if (!ref) warn("The `ref` prop is required for `FloatingArrow`.");
3500
- }
3501
- const clipPathId = useId();
3502
- const [isRTL, setIsRTL] = react.useState(false);
3503
- require_floating_ui_react_utils.index(() => {
3504
- if (!floating) return;
3505
- if (require_floating_ui_utils_dom.getComputedStyle(floating).direction === "rtl") setIsRTL(true);
3506
- }, [floating]);
3507
- if (!floating) return null;
3508
- const [side, alignment] = placement.split("-");
3509
- const isVerticalSide = side === "top" || side === "bottom";
3510
- let computedStaticOffset = staticOffset;
3511
- if (isVerticalSide && shift$1 != null && shift$1.x || !isVerticalSide && shift$1 != null && shift$1.y) computedStaticOffset = null;
3512
- const computedStrokeWidth = strokeWidth * 2;
3513
- const halfStrokeWidth = computedStrokeWidth / 2;
3514
- const svgX = width / 2 * (tipRadius / -8 + 1);
3515
- const svgY = height / 2 * tipRadius / 4;
3516
- const isCustomShape = !!d;
3517
- const yOffsetProp = computedStaticOffset && alignment === "end" ? "bottom" : "top";
3518
- let xOffsetProp = computedStaticOffset && alignment === "end" ? "right" : "left";
3519
- if (computedStaticOffset && isRTL) xOffsetProp = alignment === "end" ? "left" : "right";
3520
- const arrowX = (arrow$1 == null ? void 0 : arrow$1.x) != null ? computedStaticOffset || arrow$1.x : "";
3521
- const arrowY = (arrow$1 == null ? void 0 : arrow$1.y) != null ? computedStaticOffset || arrow$1.y : "";
3522
- const dValue = d || "M0,0" + (" H" + width) + (" L" + (width - svgX) + "," + (height - svgY)) + (" Q" + width / 2 + "," + height + " " + svgX + "," + (height - svgY)) + " Z";
3523
- const rotation = {
3524
- top: isCustomShape ? "rotate(180deg)" : "",
3525
- left: isCustomShape ? "rotate(90deg)" : "rotate(-90deg)",
3526
- bottom: isCustomShape ? "" : "rotate(180deg)",
3527
- right: isCustomShape ? "rotate(-90deg)" : "rotate(90deg)"
3528
- }[side];
3529
- return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("svg", {
3530
- ...rest,
3531
- "aria-hidden": true,
3532
- ref,
3533
- width: isCustomShape ? width : width + computedStrokeWidth,
3534
- height: width,
3535
- viewBox: "0 0 " + width + " " + (height > width ? height : width),
3536
- style: {
3537
- position: "absolute",
3538
- pointerEvents: "none",
3539
- [xOffsetProp]: arrowX,
3540
- [yOffsetProp]: arrowY,
3541
- [side]: isVerticalSide || isCustomShape ? "100%" : "calc(100% - " + computedStrokeWidth / 2 + "px)",
3542
- transform: [rotation, transform].filter((t) => !!t).join(" "),
3543
- ...restStyle
3544
- },
3545
- children: [
3546
- computedStrokeWidth > 0 && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("path", {
3547
- clipPath: "url(#" + clipPathId + ")",
3548
- fill: "none",
3549
- stroke,
3550
- strokeWidth: computedStrokeWidth + (d ? 0 : 1),
3551
- d: dValue
3552
- }),
3553
- /* @__PURE__ */ (0, react_jsx_runtime.jsx)("path", {
3554
- stroke: computedStrokeWidth && !d ? rest.fill : "none",
3555
- d: dValue
3556
- }),
3557
- /* @__PURE__ */ (0, react_jsx_runtime.jsx)("clipPath", {
3558
- id: clipPathId,
3559
- children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("rect", {
3560
- x: -halfStrokeWidth,
3561
- y: halfStrokeWidth * (isCustomShape ? -1 : 1),
3562
- width: width + computedStrokeWidth,
3563
- height: width
3564
- })
3565
- })
3566
- ]
3567
- });
3568
- });
3569
- FloatingNodeContext = /* @__PURE__ */ react.createContext(null);
3570
- FloatingTreeContext = /* @__PURE__ */ react.createContext(null);
3571
- useFloatingParentNodeId = () => {
3572
- var _React$useContext;
3573
- return ((_React$useContext = react.useContext(FloatingNodeContext)) == null ? void 0 : _React$useContext.id) || null;
3574
- };
3575
- useFloatingTree = () => react.useContext(FloatingTreeContext);
3576
- safePolygonIdentifier = /* @__PURE__ */ createAttribute("safe-polygon");
3577
- NOOP = () => {};
3578
- FloatingDelayGroupContext = /* @__PURE__ */ react.createContext({
3579
- delay: 0,
3580
- initialDelay: 0,
3581
- timeoutMs: 0,
3582
- currentId: null,
3583
- setCurrentId: NOOP,
3584
- setState: NOOP,
3585
- isInstantPhase: false
3586
- });
3587
- useDelayGroupContext = () => react.useContext(FloatingDelayGroupContext);
3588
- NextFloatingDelayGroupContext = /* @__PURE__ */ react.createContext({
3589
- hasProvider: false,
3590
- timeoutMs: 0,
3591
- delayRef: { current: 0 },
3592
- initialDelayRef: { current: 0 },
3593
- timeoutIdRef: { current: -1 },
3594
- currentIdRef: { current: null },
3595
- currentContextRef: { current: null }
3596
- });
3597
- rafId = 0;
3598
- counters = {
3599
- inert: /* @__PURE__ */ new WeakMap(),
3600
- "aria-hidden": /* @__PURE__ */ new WeakMap(),
3601
- none: /* @__PURE__ */ new WeakMap()
3602
- };
3603
- uncontrolledElementsSet = /* @__PURE__ */ new WeakSet();
3604
- markerMap = {};
3605
- lockCount$1 = 0;
3606
- supportsInert = () => typeof HTMLElement !== "undefined" && "inert" in HTMLElement.prototype;
3607
- unwrapHost = (node) => node && (node.host || unwrapHost(node.parentNode));
3608
- correctElements = (parent, targets) => targets.map((target) => {
3609
- if (parent.contains(target)) return target;
3610
- const correctedTarget = unwrapHost(target);
3611
- if (parent.contains(correctedTarget)) return correctedTarget;
3612
- return null;
3613
- }).filter((x) => x != null);
3614
- HIDDEN_STYLES = {
3615
- border: 0,
3616
- clip: "rect(0 0 0 0)",
3617
- height: "1px",
3618
- margin: "-1px",
3619
- overflow: "hidden",
3620
- padding: 0,
3621
- position: "fixed",
3622
- whiteSpace: "nowrap",
3623
- width: "1px",
3624
- top: 0,
3625
- left: 0
3626
- };
3627
- FocusGuard = /* @__PURE__ */ react.forwardRef(function FocusGuard$1(props, ref) {
3628
- const [role, setRole] = react.useState();
3629
- require_floating_ui_react_utils.index(() => {
3630
- if (require_floating_ui_react_utils.isSafari()) setRole("button");
3631
- }, []);
3632
- const restProps = {
3633
- ref,
3634
- tabIndex: 0,
3635
- role,
3636
- "aria-hidden": role ? void 0 : true,
3637
- [createAttribute("focus-guard")]: "",
3638
- style: HIDDEN_STYLES
3639
- };
3640
- return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
3641
- ...props,
3642
- ...restProps
3643
- });
3644
- });
3645
- PortalContext = /* @__PURE__ */ react.createContext(null);
3646
- attr = /* @__PURE__ */ createAttribute("portal");
3647
- usePortalContext = () => react.useContext(PortalContext);
3648
- LIST_LIMIT = 20;
3649
- previouslyFocusedElements = [];
3650
- VisuallyHiddenDismiss = /* @__PURE__ */ react.forwardRef(function VisuallyHiddenDismiss$1(props, ref) {
3651
- return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
3652
- ...props,
3653
- type: "button",
3654
- ref,
3655
- tabIndex: -1,
3656
- style: HIDDEN_STYLES
3657
- });
3658
- });
3659
- lockCount = 0;
3660
- scrollbarProperty = "--floating-ui-scrollbar-width";
3661
- cleanup = () => {};
3662
- FloatingOverlay = /* @__PURE__ */ react.forwardRef(function FloatingOverlay$1(props, ref) {
3663
- const { lockScroll = false,...rest } = props;
3664
- require_floating_ui_react_utils.index(() => {
3665
- if (!lockScroll) return;
3666
- lockCount++;
3667
- if (lockCount === 1) cleanup = enableScrollLock();
3668
- return () => {
3669
- lockCount--;
3670
- if (lockCount === 0) cleanup();
3671
- };
3672
- }, [lockScroll]);
3673
- return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
3674
- ref,
3675
- ...rest,
3676
- style: {
3677
- position: "fixed",
3678
- overflow: "auto",
3679
- top: 0,
3680
- right: 0,
3681
- bottom: 0,
3682
- left: 0,
3683
- ...rest.style
3684
- }
3685
- });
3686
- });
3687
- bubbleHandlerKeys = {
3688
- pointerdown: "onPointerDown",
3689
- mousedown: "onMouseDown",
3690
- click: "onClick"
3691
- };
3692
- captureHandlerKeys = {
3693
- pointerdown: "onPointerDownCapture",
3694
- mousedown: "onMouseDownCapture",
3695
- click: "onClickCapture"
3696
- };
3697
- normalizeProp = (normalizable) => {
3698
- var _normalizable$escapeK, _normalizable$outside;
3699
- return {
3700
- escapeKey: typeof normalizable === "boolean" ? normalizable : (_normalizable$escapeK = normalizable == null ? void 0 : normalizable.escapeKey) != null ? _normalizable$escapeK : false,
3701
- outsidePress: typeof normalizable === "boolean" ? normalizable : (_normalizable$outside = normalizable == null ? void 0 : normalizable.outsidePress) != null ? _normalizable$outside : true
3702
- };
3703
- };
3704
- ESCAPE = "Escape";
3705
- componentRoleToAriaRoleMap = /* @__PURE__ */ new Map([
3706
- ["select", "listbox"],
3707
- ["combobox", "listbox"],
3708
- ["label", false]
3709
- ]);
3710
- camelCaseToKebabCase = (str) => str.replace(/[A-Z]+(?![a-z])|[A-Z]/g, ($, ofs) => (ofs ? "-" : "") + $.toLowerCase());
3711
- inner = (props) => ({
3712
- name: "inner",
3713
- options: props,
3714
- async fn(state) {
3715
- const { listRef, overflowRef, onFallbackChange, offset: innerOffset = 0, index: index$1 = 0, minItemsVisible = 4, referenceOverflowThreshold = 0, scrollRef,...detectOverflowOptions } = require_floating_ui_utils.evaluate(props, state);
3716
- const { rects, elements: { floating } } = state;
3717
- const item = listRef.current[index$1];
3718
- const scrollEl = (scrollRef == null ? void 0 : scrollRef.current) || floating;
3719
- const clientTop = floating.clientTop || scrollEl.clientTop;
3720
- const floatingIsBordered = floating.clientTop !== 0;
3721
- const scrollElIsBordered = scrollEl.clientTop !== 0;
3722
- const floatingIsScrollEl = floating === scrollEl;
3723
- if (process.env.NODE_ENV !== "production") {
3724
- if (!state.placement.startsWith("bottom")) warn("`placement` side must be \"bottom\" when using the `inner`", "middleware.");
3725
- }
3726
- if (!item) return {};
3727
- const nextArgs = {
3728
- ...state,
3729
- ...await require_floating_ui_react_dom.offset(-item.offsetTop - floating.clientTop - rects.reference.height / 2 - item.offsetHeight / 2 - innerOffset).fn(state)
3730
- };
3731
- const overflow = await require_floating_ui_dom.detectOverflow(getArgsWithCustomFloatingHeight(nextArgs, scrollEl.scrollHeight + clientTop + floating.clientTop), detectOverflowOptions);
3732
- const refOverflow = await require_floating_ui_dom.detectOverflow(nextArgs, {
3733
- ...detectOverflowOptions,
3734
- elementContext: "reference"
3735
- });
3736
- const diffY = require_floating_ui_utils.max(0, overflow.top);
3737
- const nextY = nextArgs.y + diffY;
3738
- const maxHeight = (scrollEl.scrollHeight > scrollEl.clientHeight ? (v) => v : require_floating_ui_utils.round)(require_floating_ui_utils.max(0, scrollEl.scrollHeight + (floatingIsBordered && floatingIsScrollEl || scrollElIsBordered ? clientTop * 2 : 0) - diffY - require_floating_ui_utils.max(0, overflow.bottom)));
3739
- scrollEl.style.maxHeight = maxHeight + "px";
3740
- scrollEl.scrollTop = diffY;
3741
- if (onFallbackChange) {
3742
- const shouldFallback = scrollEl.offsetHeight < item.offsetHeight * require_floating_ui_utils.min(minItemsVisible, listRef.current.length) - 1 || refOverflow.top >= -referenceOverflowThreshold || refOverflow.bottom >= -referenceOverflowThreshold;
3743
- react_dom.flushSync(() => onFallbackChange(shouldFallback));
3744
- }
3745
- if (overflowRef) overflowRef.current = await require_floating_ui_dom.detectOverflow(getArgsWithCustomFloatingHeight({
3746
- ...nextArgs,
3747
- y: nextY
3748
- }, scrollEl.offsetHeight + clientTop + floating.clientTop), detectOverflowOptions);
3749
- return { y: nextY };
3750
- }
3751
- });
3752
- }) });
3753
-
3754
- //#endregion
3755
- init_floating_ui_react_esm();
3756
- Object.defineProperty(exports, 'floating_ui_react_esm_exports', {
3757
- enumerable: true,
3758
- get: function () {
3759
- return floating_ui_react_esm_exports;
3760
- }
3761
- });
3762
- Object.defineProperty(exports, 'init_floating_ui_react_esm', {
3763
- enumerable: true,
3764
- get: function () {
3765
- return init_floating_ui_react_esm;
3766
- }
3767
- });