Directory

Tooltips4Vaadin - Vaadin Add-on Directory

A Tippy.js based Tooltip-Plugin for Vaadin Flow (23+). Tooltips4Vaadin - Vaadin Add-on Directory
# Tooltips4Vaadin This plugin allows you to define proper tooltips. ![Tooltip example image did not load.](https://gitlab.com/gsedlacz/tooltips4vaadin/raw/master/misc/demo.png "Tooltip demo") ## EOL 2023-05 Since I no longer work with Vaadin (for two years by now) and I will not find the time to keep up with the changes in the framework, I will no longer work on the plugin. Thank you for input and general kindness. ### UPDATE 2023-08 If you want to implement changes or add features head over to https://gitlab.com/gsedlacz/tooltips4vaadin/. The code is not that complicated ;) ## Requirements 1. Java 11 2. Vaadin Flow version: 23+ 3. npm based build ## Breaking Changes ### 1.X to 2.X * replaced `Tooltips#removeAllTooltips` with `Tooltips#closeAllTooltips` * ~~build target changed from 1.8 to 11~~ requirement got removed in version 2.1.2 ### 2.X to 3.X * Vaadin Flow 23 based version * build target (finally) changed from 1.8 to 11 ([similar vaadin](https://vaadin.com/releases)) * changed `HasTooltip` methods (`show` → `showTooltip`, `hide` → `hideTooltip`) ## Usage ### Set / update a tooltip ``` Tooltips.getCurrent().setTooltip(yourComponent, "an important information") ``` ### Remove a tooltip ``` Tooltips.getCurrent().removeTooltip(yourComponent) ``` ### Mixin Interface for Components ``` class MyComp extends Component implements HasTooltip { MyComp(){ this.setTooltip("useful hint"); this.removeTooltip(); } } ``` ### Display Configuration ``` TooltipConfiguration ttconfig = new TooltipConfiguration("test text"); ttconfig.setDuration(null, 20); ttconfig.setContent("test \n
abc"); ttconfig.setFollowCursor(TC_FOLLOW_CURSOR.HORIZONTAL); ttconfig.setHideOnClick(TC_HIDE_ON_CLICK.FALSE); ttconfig.setShowOnCreate(false); Textfield tf = new TextField(); Tooltips.getCurrent().setTooltip(tf, tconf); ``` ### Using a default configuration ``` TooltipConfiguration defaultConf = new TooltipConfiguration(); defaultConf.setArrow(true); defaultConf.setDelay(2000); Tooltips.getCurrent().setDefaultTooltipConfiguration(defaultConf); // both of the approaches below will make use of the default configuration, while directly setting a customized configuration will not HasTooltip component = ... component.setTooltip("message"); // OR Tooltips.getCurrent().setTooltip(component, "message"); ``` ## Browser Compatibilty This library should work nicely with any modern browser but only the ones shown on the right side were tested. ## Trouble Shooting If you receive build errors like: ``` ERROR] Failed to execute goal com.vaadin:vaadin-maven-plugin:14.1.28:build-frontend (default) on project tooltipdemo: Execution default of goal com.vaadin:vaadin-maven-plugin:14.1.28:build-frontend failed: [ERROR] [ERROR] Failed to find the following css files in the `node_modules` or `PATH\tooltipdemo\frontend` directory tree: [ERROR] - tippy.js/dist/tippy.css [ERROR] Check that they exist or are installed. If you use a custom directory for your resource files instead of the default `frontend` folder then make sure it's correctly configured (e.g. set 'vaadin.frontend.frontend.folder' property) ``` Try loading npm dependencies manually using: `npm i` in your project directory. ## Credit This plugin makes use of these libraries: 1. tippy.js (license: MIT, version. 6.3.1, URL: https://github.com/atomiks/tippyjs) 2. Project Lombok (license: MIT, version 1.18.22, URL: https://projectlombok.org/) 3. retry (license: MIT, version: 0.12.0, URL: https://www.npmjs.com/package/retry) ## Copyright and license Code and documentation copyright 2022 Gerrit Sedlaczek. Code and documentation released under Apache 2.0 license.
Source Code
Issue tracker

Tooltips4Vaadin version 1.1.2
statemangement fixed * attach cleanup * detach cleanup

Tooltips4Vaadin version 1.2.1
##### Breaking Changes As `Tooltips` is now based on a `UI` accessing it changed. Old: ```java Tooltips.init(UI.getCurrent()); Tooltips.setTooltip(comp, "tooltip", UI.getCurrent()); ``` New: ```java new Tooltips(UI.getCurrent()); Tooltips.getCurrent().setTooltip(comp, "tooltip"); ``` ##### Updated the README to showcase the new API.

Tooltips4Vaadin version 1.2.2
NPE prevention ##### Breaking changes since 1.2.1

Tooltips4Vaadin version 1.2.3
* Added a Mixin-Interface "HasTooltip" * JS improvements

Tooltips4Vaadin version 1.2.4
* Added a VaadinServiceInitListener

Tooltips4Vaadin version 1.2.5
* Vaadin 14.0.4 * NPE fixed (UI#access called after a UI has been closed)

Tooltips4Vaadin version 1.3.0
* Java 1.8 targeted * Self-setup (You are no longer required to add an initlistener)

Tooltips4Vaadin version 1.3.1
* added Serializable interface

Tooltips4Vaadin version 1.3.2
* bugfix: Detach issue in Dialogs

Tooltips4Vaadin version 1.4.1
* added some automatic cleanup to prevent OutOfMemoryExceptions in larger deployments * added usage of [retry](https://www.npmjs.com/package/retry) in js to make finding entries more robust (especially when defining tooltips in Grids) * HasTooltip now allows to remove tooltips

Tooltips4Vaadin version 1.4.2
* Updated Tippy.js (v5.1.4)

Tooltips4Vaadin version 1.4.3
# Changes - vaadin: 14.1.17 - tippy: 5.2.1 - new: changelog - bugfix: NPE in Cleaner (#16) # Known Issues - Reattached Components may miss their tooltip

Tooltips4Vaadin version 1.4.4
#### Changes - vaadin: 14.1.18 - build fixed (#21) #### Known Issues Reattached Components may miss their tooltip

Tooltips4Vaadin version 1.4.8
* tooltips could not display html (#24) * vaadin 14.1.25 # Changes in 1.4.7 * js import issue resolved (#23) * vaadin: 14.1.24 # Changes in 1.4.6 * tooltips disappeard on reattaching (#18) # Changes in 1.4.5 * vaadin: 14.1.23 * tippy.js: 6.1.0 * removal of out-of-date tooltips fixed (#22)

Tooltips4Vaadin version 1.4.9
* fixed: Tooltip of Grid cell "freezes" if grid data is updated (#22)

Tooltips4Vaadin version 1.5.0-alpha
Experimental support for setting tippy props (settings). class: `TooltipConfiguration` example: ``` Textfield textfield = new TextField(); Tooltips tt = Tooltips.getCurrent(); tt.getConfiguration(textfield).ifPresent(conf -> { conf.setAllowHtml(false); conf.setFollowCursor("horizontal"); conf.setContent("new text"); tt.setTooltip(textfield, conf); }); ```

Tooltips4Vaadin version 1.5.0
Added support for setting tippy props (settings). class: `TooltipConfiguration` example: ``` Textfield tf = new TextField(); TooltipConfiguration ttconfig = new TooltipConfiguration("test text"); ttconfig.setDuration(null, 20); ttconfig.setContent("test \n
abc"); ttconfig.setFollowCursor(TC_FOLLOW_CURSOR.HORIZONTAL); ttconfig.setHideOnClick(TC_HIDE_ON_CLICK.FALSE); ttconfig.setShowOnCreate(false); Tooltips.getCurrent().setTooltip(tf, tconf); ```

Tooltips4Vaadin version 1.5.1
* new config property: 'touch' * new config property: 'trigger' * vaadin version: 14.2.2 * tippy version: 6.2.3

Tooltips4Vaadin version 1.6.0
### New Features * [Close all potentially open Tooltips if associated Component is unknown](https://gitlab.com/gsedlacz/tooltips4vaadin/-/issues/25) * [Programmatically show/hide a tooltip](https://gitlab.com/gsedlacz/tooltips4vaadin/-/issues/27)

Tooltips4Vaadin version 1.7.0
added support for a UI wide default configuration

Tooltips4Vaadin version 1.7.1
* bugfix: [Extended Tooltipconfigurations doesnt work](https://gitlab.com/gsedlacz/tooltips4vaadin/-/issues/29)

Tooltips4Vaadin version 1.7.2
* updated tippy.js to 6.3.1 * updated vaadin to 14.5.3

Tooltips4Vaadin version 2.0.0
# 2.0.0 Implementing support for @PreserveOnRefresh required introducing breaking changes. ## API changes * no longer supports '#removeAllTooltips' - closed and removed (so that they would not reappear afterwards) all Tooltips of the current UI * added support for '#closeAllTooltips' - closes all Tooltips of the current UI ## Other * [#32](https://gitlab.com/gsedlacz/tooltips4vaadin/-/issues/32): added support for [@PreserveOnRefresh](https://vaadin.com/docs/v14/flow/advanced/tutorial-preserving-state-on-refresh) * [#31](https://gitlab.com/gsedlacz/tooltips4vaadin/-/issues/31): removed the need to manage tooltip state manually (including a custom cleanup)

Tooltips4Vaadin version 2.1.0
##### Improvements: * [#33](https://gitlab.com/gsedlacz/tooltips4vaadin/-/issues/33) improved the way this plugin identifies its DOM elements and removed the need for a `Component` to be a `HasStyle` allowing MenuBars to receive tooltips. ##### Known Issues: * The initially visible elements of a MenuBar still cant display any tooltips as its not part of the visible DOM but instead hidden inside of `vaadin-menu-bar`s shadow DOM

Tooltips4Vaadin version 2.1.1
* prevents updates to the ui if the content supplied did not change

Tooltips4Vaadin version 2.1.2
* Java 1.8 support returns * bugfix: prevention of orphan tooltips

Tooltips4Vaadin version 2.2.0
* [Tooltipconfiguration now supports popperOptions](https://gitlab.com/gsedlacz/tooltips4vaadin/-/issues/39)

Tooltips4Vaadin version 2.3.0
* fixed [#40](https://gitlab.com/gsedlacz/tooltips4vaadin/-/issues/40) (faulty handling of initially hidden items)

Tooltips4Vaadin version 3.0.2
* fixed tooltip.js not being part of the released artifact

Tooltips4Vaadin version 3.1.0
* Add support for appendTo property (kindly provided by https://gitlab.com/schwarzwald1)