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