Skip to content

Commit c203160

Browse files
authored
feat: React DOM Interactions package (floating-ui#1585)
1 parent f695b52 commit c203160

File tree

98 files changed

+13464
-14667
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

98 files changed

+13464
-14667
lines changed

.config/tsconfig.json

+5-3
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,16 @@
22
"include": ["../packages/**/src/**/*.ts"],
33
"exclude": ["../**/*.test.ts"],
44
"compilerOptions": {
5-
"target": "es2015",
6-
"lib": ["dom", "es2017"],
5+
"target": "es2021",
6+
"lib": ["dom", "es2021"],
77
"moduleResolution": "node",
88
"module": "es2015",
99
"removeComments": false,
1010
"skipLibCheck": true,
1111
"declaration": true,
1212
"emitDeclarationOnly": true,
13-
"outDir": "../packages"
13+
"jsx": "react-jsx",
14+
"outDir": "../packages",
15+
"allowSyntheticDefaultImports": true
1416
}
1517
}

.eslintrc.js

+1
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ module.exports = {
1111
'@typescript-eslint/ban-ts-comment': 'off',
1212
'@typescript-eslint/no-explicit-any': 'off',
1313
'@typescript-eslint/no-var-requires': 'off',
14+
'@typescript-eslint/no-empty-function': 'off',
1415
'react-hooks/rules-of-hooks': 'error',
1516
'react-hooks/exhaustive-deps': 'warn',
1617
},

README.md

+67-41
Original file line numberDiff line numberDiff line change
@@ -1,38 +1,70 @@
11
<p align="center">
2-
<img height="300" src="https://github.com/atomiks/floating-ui/blob/main/website/assets/logo.png" alt="Floating UI">
2+
<img height="560" src="https://github.com/floating-ui/floating-ui/blob/master/website/assets/floating-ui-banner.png" alt="Floating UI">
33
<p>
4-
5-
> **Popper is now Floating UI! For Popper v2, visit [its dedicated branch.](https://github.com/floating-ui/popper-core/tree/v2.x)**
64

7-
[![Rolling Versions](https://img.shields.io/badge/Rolling%20Versions-Enabled-brightgreen)](https://rollingversions.com/floating-ui/floating-ui)
5+
> **Popper is now Floating UI! For Popper v2, visit
6+
> [its dedicated branch.](https://github.com/floating-ui/floating-ui/tree/v2.x)**
87
9-
[Website](https://floating-ui.com)
8+
[Floating UI](https://floating-ui.com) is a low-level library for creating
9+
"floating" elements like tooltips, popovers, dropdowns, menus, and more.
1010

11-
Floating UI is a low-level library for positioning "floating" elements like
12-
tooltips, popovers, dropdowns, menus and more while intelligently keeping them
13-
in view.
11+
The library provides two key functionalities:
1412

15-
Challenges arise when positioning floating elements as they get taken out of the
16-
normal layout flow of a document, leading to issues with clipping and overflow,
17-
which is where this library can help!
13+
- **Positioning primitives**: Ensure your floating element is positioned
14+
optimally in the viewport for the user (placement, overflow
15+
prevention/clipping detection, and more).
16+
- **Interaction primitives**: Add accessible interactions that power floating
17+
elements (event listeners, dismissing, ARIA attributes, focus trapping, list
18+
navigation, and more).
1819

19-
- **Tiny**: 600-byte core with highly modular architecture for tree-shaking
20-
- **Low-level**: Granular control over positioning behavior
21-
- **Pure**: Predictable and side-effect free
22-
- **Extensible**: Powerful middleware system
23-
- **Platform-agnostic**: Runs on any JavaScript environment which provides
24-
measurement APIs, including the web and React Native
20+
The positioning engine features a tiny 600-byte core with strong tree-shaking
21+
support, is extensible through custom middleware, and can support any platform.
2522

26-
## Installation
23+
## Install
2724

28-
To use it on the web:
25+
Choose the package that suits you.
26+
27+
### Vanilla DOM positioning engine
28+
29+
Use with vanilla JavaScript or a non-React framework
30+
([view tutorial](https://floating-ui.com/docs/tutorial)).
2931

3032
```shell
3133
npm install @floating-ui/dom
3234
```
3335

36+
### React DOM positioning engine
37+
38+
Use with React DOM ([view docs](https://floating-ui.com/docs/react-dom)).
39+
3440
```shell
35-
yarn add @floating-ui/dom
41+
npm install @floating-ui/react-dom
42+
```
43+
44+
### React DOM interactions and positioning engine
45+
46+
Primitive hooks and components, in addition to the positioning engine, to use
47+
with React DOM
48+
([view docs](https://floating-ui.com/docs/react-dom-interactions)).
49+
50+
```shell
51+
npm install @floating-ui/react-dom-interactions
52+
```
53+
54+
### React Native positioning engine
55+
56+
Use with React Native ([view docs](https://floating-ui.com/docs/react-native)).
57+
58+
```shell
59+
npm install @floating-ui/react-native
60+
```
61+
62+
### Canvas or other platforms
63+
64+
Learn about creating a [Platform](https://floating-ui.com/docs/platform).
65+
66+
```shell
67+
npm install @floating-ui/core
3668
```
3769

3870
## Quick start
@@ -62,33 +94,20 @@ computePosition(referenceElement, floatingElement, {
6294

6395
## Development and production builds
6496

65-
Floating UI is published with default, development, and
66-
production builds, using Node's support for
97+
Floating UI is published with default, development, and production builds, using
98+
Node's support for
6799
[export conditions](https://nodejs.org/api/packages.html#packages_conditional_exports).
68100

69-
- `"default"`: uses `process.env.NODE_ENV`, in which
70-
your bundler handles the env variable, dead code elimination,
71-
and minification
101+
- `"default"`: uses `process.env.NODE_ENV`, in which your bundler handles the
102+
env variable, dead code elimination, and minification
72103
- `"production"`: minified with no debug logging
73104
- `"development"`: unminified with debug logging
74105

75-
If you're using a bundler like webpack, Vite, or Parcel, this is
76-
handled for you **automatically**.
106+
If you're using a bundler like webpack, Vite, or Parcel, this is handled for you
107+
**automatically**.
77108

78-
If this is not handled, you must opt into one of the builds in
79-
tools that support export conditions. This is done differently
80-
for each tool.
81-
82-
## React
83-
84-
- [React DOM](https://floating-ui.com/docs/react-dom)
85-
- [React Native](https://floating-ui.com/docs/react-native) (\*experimental)
86-
87-
## Components
88-
89-
Right now, Floating UI focuses on positioning floating elements, but a package
90-
that exposes higher-level primitives for building these elements more easily is
91-
in development.
109+
If this is not handled, you must opt into one of the builds in tools that
110+
support export conditions. This is done differently for each tool.
92111

93112
## Contributing
94113

@@ -119,6 +138,13 @@ as much as possible.
119138
`npm -w website run dev` in the root will launch the website at
120139
`localhost:3000`.
121140

141+
## Credits
142+
143+
The floating shapes in the banner image are made by the amazing artists
144+
[@artstar3d](https://figma.com/@artstar3d),
145+
[@killnicole](https://figma.com/@killnicole) and
146+
[@liiiiiiii](https://www.figma.com/@liiiiiii) on Figma — check out their work!
147+
122148
## License
123149

124150
MIT

0 commit comments

Comments
 (0)