For components like Tooltips, we leverage Floating UI's positioning utilities, which are framework-agnostic. The hover, focus etc interactions Floating UI provides are, unfortunately, written specifically for React. To use Floating UI in Ember, Pluma ships with Ember versions of Floating UI's React hooks.
To use Pluma's Ember Floating UI, first we need to import useFloatingUi and
initialize it like this:
this needs to be provided so that the plugin can run cleanup when the parent
component gets destroyed.
The second argument is a function that returns a configuration object, which
accepts almost the same options as the useFloating React hook, for example:
The second argument is a function, instead of a plain object, to enable the
Floating UI class to recompute when tracked properties (like this.isOpen) change.
If a plain object was used, the class would initialize with the current values
of the properties, and would never recompute/update.
One option that differs is plugins, which accepts interaction plugins that
resemble the useHover etc hooks.
Currently, the following plugins exist:
Each plugin accepts options, which can be provided by calling the static .with
method on the import:
There is one additional plugin, TransitionStatus. The other plugins are all
interactions, which Floating UI uses to attach event listeners to the reference
and floating elements. TransitionStatus doesn't attach any listeners, and instead
returns state that can be used for animating floating elements. For example: