Localised number fields, positionable labels, form generator, collection/map field, server-side text selection, date pickers with date pattern, configurable select components (tabs, GridSelect and ItemGrid), multi-click button, a LazyLoad, a ComponentObserver and even an UnloadListener. Plus fluid API, good JavaDocs and general Java-friendliness.
# Now in Maven Central
From version 0.18.0 SuperFields work with Java 17 and Vaadin 24.
From version 0.16.0 onwards all new releases for Vaadin 23+ are available in Maven Central.
From version 0.17.0-vaadin14 all new releases for Vaadin 14 are also available in Maven Central.
Use group id `pl.unforgiven` and artifact id `superfields`.
# Demo app
Demo application of the latest release can be found at https://demo.unforgiven.pl/superfields.
Source code for the app and for the components can be found at https://github.com/vaadin-miki/super-fields/.
# SuperFields
All SuperFields are Java-friendly. There is as little client-side code as possible ;) In addition to that, any client-side code is considered **implementation detail** and may change at any time.
#### Fluid API
All SuperFields feature fluid API (or method chaining), at least to some extent. For example, instead of doing:
```
SuperDatePicker datePicker = new SuperDatePicker();
datePicker.setId("super-date-picker");
datePicker.setValue(LocalDate.today());
```
you can do a magic one-liner: `new SuperDatePicker().withId("super-date-picker").withValue(LocalDate.today())`.
#### Text selection
Some components contain server-side methods to control text selection in their web component part. In addition, they can optionally listen to text-selection events happening in the browser and broadcast them to the server.
The web components listen to each key press and mouse click. If text selection changes as a result of that action, they send an event to the server-side component. This may happen quite often and increase server load, so the feature is turned off by default. To turn it on simply call `setReceivingSelectionEventsFromClient(true)` (or `withReceivingSelectionEventsFromClient(true)`).
#### Label position
Most of the components that can have a label allow positioning said label through `setLabelPosition(...)` (or `withLabelPosition(...)`). This should work in most layouts, with `FormLayout` being an obvious exception. Not all components support all possible values of `LabelPosition` (`SuperCheckbox` ignores vertical alignment). In addition, things might work weird when using right-to-left languages - if that happens, please report the problem in GitHub.
#### Log messages
Quite a few components log their state using [SLF4J](https://www.slf4j.org). Critical information is logged as error or warning, debugging messages are, well, debug or trace. Information about [how to configure which log messages get displayed can be found e.g. on Stack Overflow](https://stackoverflow.com/questions/45997759/how-to-change-slf4j-logging-level).
## Number fields
None of the number fields support range checking, so if you allow too many digits, overflows will occur.
All number fields support text selection API.
### `SuperDoubleField` and `SuperBigDecimalField`
An input field for entering localised `Double` and `BigDecimal` numbers. Supports thousands (grouping) separators for the integer part and optional decimal separator.
Both fields allow the integer part of the number to be optional (thus omitted and defaulted to zero - `.27` parsed as `0.27`). This feature is turned off by default (meaning the integer part is required).
In addition to that `SuperBigDecimalField` supports (optionally) entering numbers with scientific notation, e.g. `12.34e-1`.
### `SuperIntegerField` and `SuperLongField`
An input field for entering localised `Integer` and `Long` numbers. Supports thousands (grouping) separators.
## Text fields
### `SuperTextField` and `SuperTextArea`
These are the same components as their Vaadin counterparts, except they fully support text selection API. This means that the text contained in the components can be selected from server-side code and that changes to selection in the browser are sent to the server as events.
In addition to that, both components allow server-side initiated text change at caret position (or any selected range).
## Date fields
### `SuperDatePicker` and `SuperDateTimePicker`
Fully localised `DatePicker` and `DateTimePicker` that fetch month names and weekday names from Java `Locale`. Those settings can be overwritten by resource bundle named `superdatepickeri18n`.
In addition to the above, both components allow setting custom date display pattern. This pattern should survive setting locale or i18n object, so keep that in mind.
**Please note:** Vaadin's `DatePicker` and `DateTimePicker` allow setting custom date display patterns since version 14.8. It is achieved through `DatePickerI18n.setDateFormat`. That method executes in `SuperDatePickerI18n`, but it logs a warning message. If you intend to set formatting through i18n, please use default Vaadin's components.
Both components behave funky when changing locale at runtime if their calendars were already shown. That is mostly due to some weird caching on the client side and is also a Vaadin bug.
**Please note:** only `SuperDatePicker` has support for text selection API.
## `CollectionField`, `MapField` and related helpers
### `CollectionField`
Almost out-of-the-box, fully configurable `CustomField` for data of type `List` (or `Set`). Supports custom layouts, fields, removing individual or all elements and adding at specified indices.
To help navigate around functional interfaces `CollectionComponentProviders` contains some common use cases, like buttons for removing, clearing or adding elements. Please check the demo app (`CollectionFieldProvider`) for an example.
### `HasIndex` and `IndexedButton`
While intended to work with `CollectionField`, here is a general interface for anything that needs an index (an integer number). `IndexedButton` does nothing by itself, but it is a `Button` that implements `HasIndex`. It is used e.g. to represent a button that removes an element from a collection.
### `MapField` and `MapEntryField`
`MapField` is a customisable `CustomField` for data of type `Map`. It is based on `CollectionField` and works with any field capable of displaying value of type `Map.Entry`.
`MapEntryField` is a component that is a `CustomField` for `Map.Entry`. It allows custom layout and dedicated components for keys and values of the map.
## `HasHeader`, `HasFooter` and layout helpers
A three-part layout, with header, content and footer, is quite common in UX design. Two helper classes are offered:
* `HeaderFooterFieldWrapper` - a fully functional `CustomField` that has a header and a footer, and the content is just the field;
* `HeaderFooterLayoutWrapper` - a fully functional layout (`HasComponents`) that has a header and a footer, and the content is a layout to which `HasComponents` method calls are delegated.
Both wrappers attempt to be API-transparent and can replace already existing layouts or fields (for example, replacing a `SuperTextField` with a `HeaderFooterFieldWrapper` should just result in a header and footer around the text field, and no other changes should be needed).
## Other fields
### `LabelField`
This is an always read-only field. Basically, it is a `CustomField` that uses a `Text` to display `String` representation of the value. It is possible to customise how that representation is created and what text to show when the value is `null`. Note that the *readonlyness* of this component applies only to the UI.
### `VariantField`
A `CustomField
SuperFields version 0.10.0 # 0.10.0 - ContentAware and Scientific Notation
## New features and enhancements
* \#156 - [Content-aware component containers](https://github.com/vaadin-miki/super-fields/issues/156)
* \#244 - [Number fields should support scientific notation](https://github.com/vaadin-miki/super-fields/issues/244)
## Changes to API
* \#264 - [Remove deprecated code from DatePattern](https://github.com/vaadin-miki/super-fields/issues/264)
* \#280 - [Java 11](https://github.com/vaadin-miki/super-fields/issues/280)
## Bug fixes
* \#268 - [Number with big precision cannot be changed with direct input representation](https://github.com/vaadin-miki/super-fields/issues/268)
* \#270 - [Incorrect width of fields when used in FormLayout](https://github.com/vaadin-miki/super-fields/issues/270)
* \#274 - [Using SuperBigDecimalField as a editor component in a gridpro produces warnings in developer console](https://github.com/vaadin-miki/super-fields/issues/274)
SuperFields version 0.10.1 # 0.10.1 - Vaadin 14.5
## New features and enhancements
(nothing reported)
## Changes to API
(nothing reported)
## Bug fixes
* \#284 - [If the input is deleted (empty string), a StringIndexOutOfBoundsException is thrown](https://github.com/vaadin-miki/super-fields/issues/284)
SuperFields version 0.10.2 # 0.10.2 - CanModifyText and Vaadin 14.6
## New features and enhancements
* \#290 - [Add text at caret position](https://github.com/vaadin-miki/super-fields/issues/290)
## Changes to API
* \#299 - [Update to Vaadin 14.6](https://github.com/vaadin-miki/super-fields/issues/299)
SuperFields version 0.11.0 ## 0.11.0 - CollectionField and Vaadin 14.7
This release introduces a `CollectionField` - a configurable `CustomField` for `Collection`s. As a bonus it comes with `HeaderFooterLayoutWrapper` and `HeaderFooterFieldWrapper` to make configuration of collection fields easier.
Finally, floating-point number fields can have its leading zero before the decimal point omitted, and Vaadin has been bumped to 14.7.
SuperFields version 0.11.1 # 0.11.1 - Focus fixes and reworked demo app
## New features and enhancements
(nothing reported)
## Changes to API
* \#324 - [Methods to control helper text/component position](https://github.com/vaadin-miki/super-fields/issues/324)
* \#326 - [Bump Vaadin to 14.7.3](https://github.com/vaadin-miki/super-fields/issues/326)
* \#330 - [Vaadin 14.7.5 and Java8 Support for the new super-fields version](https://github.com/vaadin-miki/super-fields/issues/330)
## Bug fixes
* \#329 - [Number fields do not receive focus from code](https://github.com/vaadin-miki/super-fields/issues/329)
SuperFields version 0.11.2 # 0.11.2 - HasValueChangeMode
## New features and enhancements
* \#337 - [ValueChangeMode and clear button](https://github.com/vaadin-miki/super-fields/issues/337)
## Changes to API
* \#337 - [ValueChangeMode and clear button](https://github.com/vaadin-miki/super-fields/issues/337)
## Bug fixes
* \#339 - [Setting fraction/integer digits should not be destructive](https://github.com/vaadin-miki/super-fields/issues/339)
SuperFields version 0.12.0 # 0.12.0 - Support for Vaadin 23
## New features and enhancements
* \#349 - [Support for Vaadin 23](https://github.com/vaadin-miki/super-fields/issues/349)
## Changes to API
* \#345 - [Upgrade to Vaadin 14.8.1](https://github.com/vaadin-miki/super-fields/issues/345)
## Bug fixes
(nothing reported)
SuperFields version 0.13.0 # 0.13.0 - MapField, VariantField and LabelField
## New features and enhancements
* \#356 - [MapField](https://github.com/vaadin-miki/super-fields/issues/356)
* \#359 - [VariantField](https://github.com/vaadin-miki/super-fields/issues/359)
* \#361 - [LabelField](https://github.com/vaadin-miki/super-fields/issues/361)
## Changes to API
* \#357 - [CollectionField should implement HasStyle](https://github.com/vaadin-miki/super-fields/issues/357)
SuperFields version 0.13.1 # 0.13.1 - Bugfixes
## Changes to API
* \#374 - [CollectionField should filter out empty values when saving the collection](https://github.com/vaadin-miki/super-fields/issues/374)
## Bug fixes
* \#374 - [CollectionField should filter out empty values when saving the collection](https://github.com/vaadin-miki/super-fields/issues/374)
* \#375 - [HeaderFooterFieldWrapper does not get default value from wrapped field](https://github.com/vaadin-miki/super-fields/issues/375)
SuperFields version 0.14.0 # 0.14.0 - ObjectField
## New features and enhancements
* \#380 - [ObjectField](https://github.com/vaadin-miki/super-fields/issues/380)
* \#386 - [Add HasRequired to control setRequired in components](https://github.com/vaadin-miki/super-fields/issues/386)
## Changes to API
* \#382 - [Use Vaadin's HasClearButton](https://github.com/vaadin-miki/super-fields/issues/382)
* \#386 - [Add HasRequired to control setRequired in components](https://github.com/vaadin-miki/super-fields/issues/386)
* \#391 - [Upgrade to Vaadin 23.2](https://github.com/vaadin-miki/super-fields/issues/391)
## Bug fixes
* \#387 - [ObjectField does not react to value change events from components in layouts](https://github.com/vaadin-miki/super-fields/issues/387)
* \#388 - [MapEntryField has incorrect value after creation](https://github.com/vaadin-miki/super-fields/issues/388)
* \#395 - [MapEntryField does not broadcast value change events properly](https://github.com/vaadin-miki/super-fields/issues/395)
* and more
SuperFields version 0.14.1 # 0.14.1 - SuperCheckbox and bugfixes
## New features and enhancements
* \#400 - [ObjectField should support enums and other values presentable with ComboBox](https://github.com/vaadin-miki/super-fields/issues/400)
* \#404 - [Checkbox that actually can be made read-only](https://github.com/vaadin-miki/super-fields/issues/404)
## Changes to API
* \#406 - [ObjectFieldFactory should return interface types](https://github.com/vaadin-miki/super-fields/issues/406)
## Bug fixes
* \#402 - [HasReadOnly disables layouts](https://github.com/vaadin-miki/super-fields/issues/402)
* \#403 - [Component added to read-only layout is not read-only](https://github.com/vaadin-miki/super-fields/issues/403)
* \#406 - [ObjectFieldFactory should return interface types](https://github.com/vaadin-miki/super-fields/issues/406)
SuperFields version 0.15.0 # 0.15.0 - HasPositionableLabel
## New features and enhancements
* \#414 - [Positionable component labels](https://github.com/vaadin-miki/super-fields/issues/414)
## Changes to API
* \#412 - [SuperCheckbox should implement relevant marker interfaces](https://github.com/vaadin-miki/super-fields/issues/412)
* \#415 - [CollectionField and Grid(Multi)Select should implement HasLabel](https://github.com/vaadin-miki/super-fields/issues/415)
## Bug fixes
* \#415 - [CollectionField and Grid(Multi)Select should implement HasLabel](https://github.com/vaadin-miki/super-fields/issues/415)
* \#416 - [SuperCheckbox gets out of sync](https://github.com/vaadin-miki/super-fields/issues/416)
SuperFields version 0.17.0 # 0.17.0 - HasTooltip, HasLabel and Vaadin 23.3
## New features and enhancements
(nothing reported)
## Changes to API
* \#437 - [Use Vaadin's HasLabel](https://github.com/vaadin-miki/super-fields/issues/437)
* \#443 - [Java 8 / Vaadin 14 releases to Central](https://github.com/vaadin-miki/super-fields/issues/443)
* \#454 - [Replace HasTitle with HasTooltip](https://github.com/vaadin-miki/super-fields/issues/454)
* \#456 - [Bump Vaadin to 23.3](https://github.com/vaadin-miki/super-fields/issues/456)
## Bug fixes
* \#440 - [Text selection mixin should not log a warning for delayed init](https://github.com/vaadin-miki/super-fields/issues/440)
* \#448 - [Tooltip is not working in SuperLongField](https://github.com/vaadin-miki/super-fields/issues/448)