Skip to content

Commit

Permalink
Release 0.13.0 ready (#368)
Browse files Browse the repository at this point in the history
* #356 #357 #359 #360 #361 done 
* #358 hopefully fixed (#363)
* #364 done (#365)
* (bot) release notes updated for 0.13.0
* (bot) version updated to 0.13.0

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: vaadin-miki <vaadin-miki@users.noreply.github.com>
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
  • Loading branch information
4 people authored Apr 19, 2022
1 parent 804004b commit 2254090
Show file tree
Hide file tree
Showing 29 changed files with 2,707 additions and 5,184 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ This is the relevant dependency:
<dependency>
<groupId>org.vaadin.miki</groupId>
<artifactId>superfields</artifactId>
<version>0.12.0</version>
<version>0.13.0</version>
</dependency>
```

Expand Down
6,586 changes: 1,464 additions & 5,122 deletions demo-v23/package-lock.json

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions demo-v23/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -395,10 +395,10 @@
"@vaadin/vaadin-crud": "$@vaadin/vaadin-crud",
"@vaadin/vaadin-grid-pro": "$@vaadin/vaadin-grid-pro",
"@vaadin/vaadin-rich-text-editor": "$@vaadin/vaadin-rich-text-editor",
"@polymer/polymer": "$@polymer/polymer",
"construct-style-sheets-polyfill": "$construct-style-sheets-polyfill",
"@vaadin/common-frontend": "$@vaadin/common-frontend",
"construct-style-sheets-polyfill": "$construct-style-sheets-polyfill",
"lit": "$lit",
"@polymer/polymer": "$@polymer/polymer",
"chokidar": "$chokidar",
"date-fns": "$date-fns"
}
Expand Down
6 changes: 3 additions & 3 deletions demo-v23/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@
<parent>
<artifactId>superfields-parent</artifactId>
<groupId>org.vaadin.miki</groupId>
<version>0.12.0</version>
<version>0.13.0</version>
</parent>

<artifactId>superfields-demo-v23</artifactId>
<version>0.12.0</version>
<version>0.13.0</version>
<name>V23+ demo app for SuperFields</name>
<description>Showcase application for V23+ and SuperFields.</description>
<packaging>war</packaging>
Expand All @@ -23,7 +23,7 @@
<dependency>
<groupId>org.vaadin.miki</groupId>
<artifactId>superfields</artifactId>
<version>0.12.0</version>
<version>0.13.0</version>
</dependency>
<dependency>
<groupId>javax.servlet</groupId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
* @since 2021-09-10
*/
@Order(5)
public class HasCollectionValueComponentProviderBuilder implements ContentBuilder<CollectionField<String, List<String>>> {
public class CollectionFieldBuilder implements ContentBuilder<CollectionField<String, List<String>>> {

@Override
public void buildContent(CollectionField<String, List<String>> component, Consumer<Component[]> callback) {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
package org.vaadin.miki.demo.builders;

import com.vaadin.flow.component.Component;
import com.vaadin.flow.component.combobox.ComboBox;
import org.vaadin.miki.demo.ContentBuilder;
import org.vaadin.miki.demo.Order;
import org.vaadin.miki.superfields.collections.CollectionValueComponentProvider;
import org.vaadin.miki.superfields.collections.MapEntryField;
import org.vaadin.miki.superfields.collections.MapField;
import org.vaadin.miki.superfields.numbers.SuperIntegerField;
import org.vaadin.miki.superfields.text.SuperTextField;
import org.vaadin.miki.superfields.util.CollectionComponentProviders;

import java.util.LinkedHashMap;
import java.util.Map;
import java.util.function.Consumer;

/**
* Builds content for {@link MapField}.
*
* @author miki
* @since 2022-04-12
*/
@Order(5)
public class MapFieldBuilder implements ContentBuilder<MapField<String, Integer>> {
@Override
public void buildContent(MapField<String, Integer> component, Consumer<Component[]> callback) {
final Map<CollectionValueComponentProvider<Map.Entry<String, Integer>, ?>, String> providersWithCaptions = new LinkedHashMap<>();

final CollectionValueComponentProvider<Map.Entry<String, Integer>, MapEntryField<String, Integer>> fieldsOnly = CollectionComponentProviders.mapEntryField(SuperTextField::new, SuperIntegerField::new);
providersWithCaptions.put(fieldsOnly, "Unlabelled text and integer fields");
providersWithCaptions.put(CollectionComponentProviders.rowWithRemoveButtonFirst(
CollectionComponentProviders.mapEntryField("Key", SuperTextField::new, "Value", SuperIntegerField::new)
, "Remove"
), "Remove button and labelled text and integer fields");

// configure the combo box
final ComboBox<CollectionValueComponentProvider<Map.Entry<String, Integer>, ?>> box = new ComboBox<>("Choose item layout:", providersWithCaptions.keySet());
box.setItemLabelGenerator(providersWithCaptions::get);
box.addValueChangeListener(event -> component.setCollectionValueComponentProvider(event.getValue()));
box.setAllowCustomValue(false);
box.setValue(fieldsOnly);

callback.accept(new Component[]{box});

}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
package org.vaadin.miki.demo.builders;

import com.vaadin.flow.component.Component;
import com.vaadin.flow.component.button.Button;
import com.vaadin.flow.component.orderedlayout.HorizontalLayout;
import org.vaadin.miki.demo.ContentBuilder;
import org.vaadin.miki.demo.Order;
import org.vaadin.miki.superfields.variant.VariantField;

import java.time.LocalDate;
import java.util.function.Consumer;
import java.util.stream.Stream;

/**
* Builds content for {@link VariantField}.
*
* @author miki
* @since 2022-04-11
*/
@Order(80)
public class VariantFieldBuilder implements ContentBuilder<VariantField> {

@Override
public void buildContent(VariantField component, Consumer<Component[]> callback) {
final HorizontalLayout layout = new HorizontalLayout(
Stream.of(new Object[]{"LocalDate", LocalDate.now()},
new Object[]{"number (Integer)", 42},
new Object[]{"String", "Pay no mind to the distant thunder"})
.map(data -> new Button("Set a " + data[0].toString(), event -> component.setValue(data[1])))
.toArray(Component[]::new)
);
layout.add(new Button("Set null (clear value)", event -> component.clear()));
callback.accept(new Component[]{layout});
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
package org.vaadin.miki.demo.providers;

import org.vaadin.miki.demo.ComponentProvider;
import org.vaadin.miki.demo.Order;
import org.vaadin.miki.superfields.collections.MapEntryField;
import org.vaadin.miki.superfields.collections.MapField;
import org.vaadin.miki.superfields.numbers.SuperIntegerField;
import org.vaadin.miki.superfields.text.SuperTextField;
import org.vaadin.miki.superfields.util.CollectionComponentProviders;

import java.util.Arrays;
import java.util.Collections;
import java.util.LinkedHashMap;

/**
* Provides a {@link MapField}.
* @author miki
* @since 2022-04-08
*/
@Order(147)
public class MapFieldProvider implements ComponentProvider<MapField<String, Integer>> {

@Override
public MapField<String, Integer> getComponent() {
return new MapField<>(LinkedHashMap::new,
CollectionComponentProviders.columnWithHeaderAndFooterRows(
Arrays.asList(
CollectionComponentProviders.removeAllButton("Clear"),
CollectionComponentProviders.addFirstButton("Add as first")
),
Collections.singletonList(CollectionComponentProviders.addLastButton("Add as last"))),
CollectionComponentProviders.rowWithRemoveButtonFirst((i, c) -> new MapEntryField<>(
() -> new SuperTextField("Any text:"), () -> new SuperIntegerField("Any integer:")
), "Remove"))
.withHelperText("(this is a Map<String, Integer>)");
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
package org.vaadin.miki.demo.providers;

import com.vaadin.flow.data.binder.ValidationResult;
import com.vaadin.flow.data.binder.Validator;
import com.vaadin.flow.data.binder.ValueContext;
import org.vaadin.miki.demo.ComponentProvider;
import org.vaadin.miki.demo.Order;
import org.vaadin.miki.superfields.dates.SuperDatePicker;
import org.vaadin.miki.superfields.numbers.SuperIntegerField;
import org.vaadin.miki.superfields.text.LabelField;
import org.vaadin.miki.superfields.text.SuperTextField;
import org.vaadin.miki.superfields.variant.TypedFieldProvider;
import org.vaadin.miki.superfields.variant.VariantField;

import java.time.LocalDate;

/**
* Provides a {@link VariantField}.
*
* @author miki
* @since 2022-04-11
*/
@Order(85)
public class VariantFieldProvider implements ComponentProvider<VariantField>, Validator<Object> {

@Override
public ValidationResult apply(Object o, ValueContext valueContext) {
return o != null && o.toString().length() > 5 ? ValidationResult.ok() : ValidationResult.error("(toString() on the value must be longer than 5 characters)");
}

@Override
public VariantField getComponent() {
return new VariantField()
.withTypedFieldProvider(TypedFieldProvider.of(Integer.class, SuperIntegerField::new),
TypedFieldProvider.of(String.class, SuperTextField::new),
TypedFieldProvider.of(LocalDate.class, SuperDatePicker::new))
.withNullComponentProvider(() -> new LabelField<>().withNullRepresentation("(no value specified)"))
.withHelperText("(this is a CustomField<Object>)")
.withLabel("Choose a value type below, then edit it here:");
}
}
1 change: 1 addition & 0 deletions demo-v23/src/main/resources/MapField.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
A field that works with any `Map<K, V>` allowing different components for keys and values. Uses a `CollectionField` to produce a `Map` from a list of `Map.Entry`.
1 change: 1 addition & 0 deletions demo-v23/src/main/resources/VariantField.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
An extendable `CustomField<Object>` that displays values in components that match the registered type(s).
51 changes: 21 additions & 30 deletions demo-v23/webpack.config.js
Original file line number Diff line number Diff line change
@@ -1,41 +1,32 @@
/**
* This file contains project specific customizations for the webpack build.
* This file contains project specific customizations for the webpack build.
* It is autogenerated if it didn't exist or if it was made for an older
* incompatible version.
*
* Defaults are provided in an autogenerated webpack.generated.js file and used by this file.
* Defaults are provided in an autogenerated webpack.generated.js file and used by this file.
* The webpack.generated.js file is overwritten on each build and no customization can be done there.
*/
const merge = require('webpack-merge');
const flowDefaults = require('./webpack.generated.js');

module.exports = merge(flowDefaults, {

});

/**
* This file can be used to configure the flow plugin defaults.
* <code>
* // Add a custom plugin
* flowDefaults.plugins.push(new MyPlugin());
*
* // Update the rules to also transpile `.mjs` files
* if (!flowDefaults.module.rules[0].test) {
* throw "Unexpected structure in generated webpack config";
* }
* flowDefaults.module.rules[0].test = /\.m?js$/
*
* // Include a custom JS in the entry point in addition to generated-flow-imports.js
* if (typeof flowDefaults.entry.index != "string") {
* throw "Unexpected structure in generated webpack config";
* }
* flowDefaults.entry.index = [flowDefaults.entry.index, "myCustomFile.js"];
* </code>
* or add new configuration in the merge block.
* <code>
* module.exports = merge(flowDefaults, {
* mode: 'development',
* devtool: 'inline-source-map'
* });
* </code>
* To change the webpack config, add a new configuration object in
* the merge arguments below:
*/
module.exports = merge(flowDefaults,
// Override default configuration
// {
// mode: 'development',
// devtool: 'inline-source-map',
// },

// Add a custom plugin
// (install the plugin with `npm install --save-dev webpack-bundle-analyzer`)
// {
// plugins: [
// new require('webpack-bundle-analyzer').BundleAnalyzerPlugin({
// analyzerMode: 'static'
// })
// ]
// },
);
4 changes: 2 additions & 2 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>org.vaadin.miki</groupId>
<artifactId>superfields-parent</artifactId>
<version>0.12.0</version>
<version>0.13.0</version>
<modules>
<module>superfields</module>
<module>demo-v23</module>
Expand All @@ -16,7 +16,7 @@
<maven.compiler.source>11</maven.compiler.source>
<maven.compiler.target>11</maven.compiler.target>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<vaadin.version>23.0.3</vaadin.version>
<vaadin.version>23.0.6</vaadin.version>
</properties>

</project>
24 changes: 20 additions & 4 deletions superfields/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -68,9 +68,9 @@ In addition to the above, both components allow setting custom date display patt

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.
**Please note:** only `SuperDatePicker` has support for text selection API.

## `CollectionField` and related helpers
## `CollectionField`, `MapField` and related helpers

### `CollectionField`

Expand All @@ -82,6 +82,12 @@ To help navigate around functional interfaces `CollectionComponentProviders` con

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<K, V>`. It is based on `CollectionField` and works with any field capable of displaying value of type `Map.Entry<K, V>`.

`MapEntryField` is a component that is a `CustomField` for `Map.Entry<K, V>`. 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:
Expand All @@ -90,6 +96,16 @@ A three-part layout, with header, content and footer, is quite common in UX desi

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<Object>`. It checks the type of the value passed to it and attempts to display it using a known mapping to a field (e.g. by registering `SuperIntegerField` and `SuperDatePicker` it will be able to show integers and dates). No events or details - other than value change - are propagated or exposed from the inner field.

## Select fields

### `ItemGrid`
Expand All @@ -98,9 +114,9 @@ A highly configurable grid that allows single selection. Each cell in the grid c

### `GridSelect` and `GridMultiSelect`

A single- and multi-selection `Grid`s that are value components, meaning it broadcast value change events (rather than selection events). Both allow access to the underlying `Grid`, except changing selection mode.
A single- and multi-selection `Grid`s that are value components, meaning they broadcast value change events (rather than selection events). Both allow access to the underlying `Grid`, except changing selection mode.

`GridMultiSelect` operates on `Set` and it has an option to limit the size of the selection.
`GridMultiSelect` operates on `Set` and has an option to limit the size of the selection.

### `SuperTabs`

Expand Down
2 changes: 1 addition & 1 deletion superfields/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
<artifactId>superfields</artifactId>
<name>SuperFields</name>
<description>Code for various V14+ fields and other components.</description>
<version>0.12.0</version>
<version>0.13.0</version>

<properties>
<maven.compiler.source>11</maven.compiler.source>
Expand Down
12 changes: 11 additions & 1 deletion superfields/release-notes.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,13 @@
# 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)
## Bug fixes
* \#358 - [DecimalFormat divide /0 - SuperBigDecimalField](https://github.com/vaadin-miki/super-fields/issues/358)
* \#360 - [CollectionField does not focus()](https://github.com/vaadin-miki/super-fields/issues/360)
# 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)
Expand Down Expand Up @@ -221,4 +231,4 @@
## Changes to API
(nothing reported)
## Bug fixes
* \#10 - [Max integer length does not work if it is a multiplication of grouping size](https://www.github.com/vaadin-miki/super-fields/issues/10)
* \#10 - [Max integer length does not work if it is a multiplication of grouping size](https://www.github.com/vaadin-miki/super-fields/issues/10)
Loading

0 comments on commit 2254090

Please sign in to comment.