Skip to content

Commit

Permalink
release 0.19.0-vaadin14
Browse files Browse the repository at this point in the history
  • Loading branch information
vaadin-miki committed Dec 22, 2023
1 parent 1266fed commit 5c064ea
Show file tree
Hide file tree
Showing 43 changed files with 104 additions and 122 deletions.
10 changes: 0 additions & 10 deletions demo-v24/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -163,16 +163,6 @@
</configuration>
</plugin>

<!-- heroku https://devcenter.heroku.com/articles/deploying-java-applications-with-the-heroku-maven-plugin -->
<plugin>
<groupId>com.heroku.sdk</groupId>
<artifactId>heroku-maven-plugin</artifactId>
<version>3.0.2</version>
<configuration>
<jdkVersion>11</jdkVersion>
<appName>superfields</appName>
</configuration>
</plugin>
</plugins>
</build>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@
import org.vaadin.miki.superfields.componentselect.ComponentSelectHelpers;
import org.vaadin.miki.superfields.layouts.FlexLayoutHelpers;

import java.util.Arrays;
import java.util.LinkedHashSet;
import java.util.Set;

/**
Expand All @@ -22,15 +24,15 @@
@Order(92)
public class ComponentMultiSelectProvider implements ComponentProvider<ComponentMultiSelect<Button, String>>, Validator<Set<String>> {

private static final Set<String> ANSWER = Set.of("Athens", "Berlin", "Rome", "Tallinn", "Warsaw");
private static final Set<String> ANSWER = new LinkedHashSet<>(Arrays.asList("Athens", "Berlin", "Rome", "Tallinn", "Warsaw"));

@Override
public ComponentMultiSelect<Button, String> getComponent() {
return new ComponentMultiSelect<Button, String>(
FlexLayoutHelpers::row,
ComponentSelectHelpers.simpleComponentFactory(Button::new),
ComponentSelectHelpers.addVariant(ButtonVariant.LUMO_ERROR),
ComponentSelectHelpers.removeVariant(ButtonVariant.LUMO_ERROR),
(index, button) -> button.addThemeVariants(ButtonVariant.LUMO_ERROR),
(index, button) -> button.removeThemeVariants(ButtonVariant.LUMO_ERROR),
"Athens", "Belgrade", "Berlin", "London", "Rome", "Tallinn", "Warsaw"
)
.withHelperText("(EU as of the end of 2023)")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
import org.vaadin.miki.demo.Order;
import org.vaadin.miki.demo.data.Format;
import org.vaadin.miki.superfields.componentselect.ComponentSelect;
import org.vaadin.miki.superfields.componentselect.ComponentSelectHelpers;
import org.vaadin.miki.superfields.layouts.FlexLayoutHelpers;

import java.util.Locale;
Expand All @@ -22,12 +21,12 @@ public class ComponentSelectProvider implements ComponentProvider<ComponentSelec
@Override
public ComponentSelect<Button, Format> getComponent() {
return new ComponentSelect<>(FlexLayoutHelpers::row,
(integer, format) -> new Button("%d. %s".formatted(integer + 1, format.name().toLowerCase(Locale.ROOT).replace('_', ' '))),
(integer, format) -> new Button(String.format("%d. %s", integer + 1, format.name().toLowerCase(Locale.ROOT).replace('_', ' '))),
Format.values()
)
.withHelperText("(click a button to select the corresponding option)")
.withComponentSelectedAction(ComponentSelectHelpers.addVariant(ButtonVariant.LUMO_PRIMARY))
.withComponentDeselectedAction(ComponentSelectHelpers.removeVariant(ButtonVariant.LUMO_PRIMARY))
.withComponentSelectedAction((index, button) -> button.addThemeVariants(ButtonVariant.LUMO_PRIMARY))
.withComponentDeselectedAction((index, button) -> button.removeThemeVariants(ButtonVariant.LUMO_PRIMARY))
.withLabel("Select your favourite book format:");
}
}
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
<maven.compiler.source>8</maven.compiler.source>
<maven.compiler.target>8</maven.compiler.target>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<vaadin.version>14.10.4</vaadin.version>
<vaadin.version>14.11.0</vaadin.version>
</properties>

</project>
2 changes: 1 addition & 1 deletion superfields/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
<maven.compiler.source>8</maven.compiler.source>
<maven.compiler.target>8</maven.compiler.target>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<vaadin.version>14.10.4</vaadin.version>
<vaadin.version>14.11.0</vaadin.version>
<maven.jar.plugin.version>3.1.2</maven.jar.plugin.version>
<javadoc.plugin.version>3.4.1</javadoc.plugin.version>
</properties>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
package org.vaadin.miki.markers;

/**
* Marker interface for components that have a placeholder text.
* This is a workaround for <a href="https://github.com/vaadin/flow/issues/4068">issue #4068 in Vaadin Flow</a>.
* @author miki
* @since 2020-04-07
*/
public interface HasPlaceholder {

/**
* Returns current placeholder text for this object.
* @return Current placeholder text. Can be {@code null}, meaning no placeholder.
*/
String getPlaceholder();

/**
* Sets the placeholder text for this object.
* @param placeholder Placeholder text. Can be {@code null}, meaning no placeholder.
*/
void setPlaceholder(String placeholder);

}
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
package org.vaadin.miki.markers;

import com.vaadin.flow.component.HasPlaceholder;

/**
* Mixin interface to support chaining {@link #setPlaceholder(String)}.
* @param <SELF> Self type.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,8 @@ public <L extends Component & HasComponents> ButtonMultiSelect(Supplier<L> layou
@SafeVarargs
public <L extends Component & HasComponents> ButtonMultiSelect(Supplier<L> layoutProvider, ButtonVariant selectedVariant, T... items) {
this(layoutProvider, ComponentSelectHelpers.simpleComponentFactory(Button::new, Object::toString),
ComponentSelectHelpers.addVariant(selectedVariant),
ComponentSelectHelpers.removeVariant(selectedVariant),
(integer, button) -> button.addThemeVariants(selectedVariant),
(integer, button) -> button.removeThemeVariants(selectedVariant),
items);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,8 @@ public <L extends Component & HasComponents> ButtonSelect(Supplier<L> layoutProv
@SafeVarargs
public <L extends Component & HasComponents> ButtonSelect(Supplier<L> layoutProvider, ButtonVariant selectedVariant, T... items) {
this(layoutProvider, ComponentSelectHelpers.simpleComponentFactory(Button::new, Object::toString),
ComponentSelectHelpers.addVariant(selectedVariant),
ComponentSelectHelpers.removeVariant(selectedVariant),
(integer, button) -> button.addThemeVariants(selectedVariant),
(integer, button) -> button.removeThemeVariants(selectedVariant),
items);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
* @param <C> Type of the collection.
*/
@Tag("collection-field")
@CssImport(value = "./styles/label-positions.css", themeFor = "collection-field")
@CssImport(value = "./styles/label-positions-custom-field.css", themeFor = "collection-field")
@JsModule("./collection-field.js")
public class CollectionField<T, C extends Collection<T>> extends CustomField<C>
implements CollectionController, WithIdMixin<CollectionField<T, C>>, HasStyle,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
* @author miki
* @since 2022-04-08
*/
@CssImport(value = "./styles/label-positions.css", themeFor = "vaadin-custom-field")
@CssImport(value = "./styles/label-positions-custom-field.css", themeFor = "vaadin-custom-field")
@Tag("map-field")
@JsModule("./map-field.js")
public class MapField<K, V> extends CustomField<Map<K, V>> implements HasStyle,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,7 @@ public final SELF withComponentFactory(SerializableBiFunction<Integer, I, C> fac
* @param action Action to use. If {@code null} is passed, result of {@link #noOp()} will be used instead.
*/
public final void setComponentSelectedAction(SerializableBiConsumer<Integer, C> action) {
this.whenSelected = Objects.requireNonNullElseGet(action, ComponentSelect::noOp);
this.whenSelected = action == null ? ComponentSelect.noOp() : action;
this.rebuildComponents();
}

Expand Down Expand Up @@ -244,7 +244,7 @@ public final SELF withComponentSelectedAction(SerializableBiConsumer<Integer, C>
* @param action Action to use. If {@code null} is passed, result of {@link #noOp()} will be used instead.
*/
public final void setComponentDeselectedAction(SerializableBiConsumer<Integer, C> action) {
this.whenDeselected = Objects.requireNonNullElseGet(action, ComponentSelect::noOp);
this.whenDeselected = action == null ? ComponentSelect.noOp() : action;
this.rebuildComponents();
}

Expand Down Expand Up @@ -276,8 +276,8 @@ public void setItems(Collection<I> items) {

@Override
public void focus() {
if(!this.components.isEmpty() && this.components.get(0) instanceof Focusable<?> first)
first.focus();
if(!this.components.isEmpty() && this.components.get(0) instanceof Focusable)
((Focusable<?>)this.components.get(0)).focus();
else super.focus();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@

import java.util.Collections;
import java.util.LinkedHashSet;
import java.util.Objects;
import java.util.Set;
import java.util.function.Supplier;
import java.util.stream.Collectors;
Expand Down Expand Up @@ -87,7 +86,8 @@ protected Set<T> generateModelValue() {

@Override
protected void setPresentationValue(Set<T> newPresentationValue) {
newPresentationValue = Objects.requireNonNullElseGet(newPresentationValue, Collections::emptySet);
if(newPresentationValue == null)
newPresentationValue = Collections.emptySet();

this.selection.clear();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@
import com.vaadin.flow.component.Component;
import com.vaadin.flow.component.HasStyle;
import com.vaadin.flow.component.HasText;
import com.vaadin.flow.component.shared.HasThemeVariant;
import com.vaadin.flow.component.shared.ThemeVariant;
import com.vaadin.flow.function.SerializableBiConsumer;
import com.vaadin.flow.function.SerializableBiFunction;

Expand All @@ -30,39 +28,13 @@ public final class ComponentSelectHelpers {
*/
public static <C extends Component & ClickNotifier<C> & HasStyle> SerializableBiConsumer<Integer, C> changeStyle(final String fromStyle, final String toStyle) {
return (index, component) -> {
if (fromStyle != null && !fromStyle.isBlank())
if (fromStyle != null && !fromStyle.isEmpty())
component.removeClassName(fromStyle);
if (toStyle != null && !toStyle.isBlank())
if (toStyle != null && !toStyle.isEmpty())
component.addClassName(toStyle);
};
}

/**
* Returns an action that adds the given variant to the component.
*
* @param variant Variant to add.
* @param <V> Theme variant.
* @param <C> Type of component (must support the given theme variant).
* @return A {@link SerializableBiFunction}.
*/
@SuppressWarnings("unchecked") // not much can be done, Vaadin's code does not ensure safe varags
public static <V extends ThemeVariant, C extends Component & ClickNotifier<C> & HasThemeVariant<V>> SerializableBiConsumer<Integer, C> addVariant(final V variant) {
return (index, component) -> component.addThemeVariants(variant);
}

/**
* Returns an action that removes the given variant from the component.
*
* @param variant Variant to remove.
* @param <V> Theme variant.
* @param <C> Type of component (must support the given theme variant).
* @return A {@link SerializableBiFunction}.
*/
@SuppressWarnings("unchecked") // not much can be done, Vaadin's code does not ensure safe varags
public static <V extends ThemeVariant, C extends Component & ClickNotifier<C> & HasThemeVariant<V>> SerializableBiConsumer<Integer, C> removeVariant(final V variant) {
return (index, component) -> component.removeThemeVariants(variant);
}

/**
* Returns a simple component factory that uses {@link Object#toString()} to produce component text.
* @param constructor Reference to a constructor of a component.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,6 @@
* @author miki
* @since 2020-12-09
*/
@CssImport(value = "./styles/label-positions-custom-field.css", themeFor = "vaadin-custom-field")
@CssImport(value = "./styles/label-positions-grids.css", themeFor = "vaadin-custom-field")
public abstract class AbstractGridSelect<V, F> extends CustomField<F> {

private final Grid<V> grid;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@
* @since 2020-12-09
*/
@Tag("grid-multi-select")
@CssImport(value = "./styles/label-positions.css", themeFor = "grid-multi-select")
@CssImport(value = "./styles/label-positions-grids.css", themeFor = "grid-multi-select")
@JsModule("./grid-multi-select.js")
public class GridMultiSelect<V> extends AbstractGridSelect<V, Set<V>>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@
* @since 2020-08-07
*/
@Tag("grid-select")
@CssImport(value = "./styles/label-positions.css", themeFor = "grid-select")
@CssImport(value = "./styles/label-positions-grids.css", themeFor = "grid-select")
@JsModule("./grid-select.js")
public class GridSelect<V> extends AbstractGridSelect<V, V>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -157,9 +157,9 @@ public double getContentShownVisibilityRange() {
*/
public void setContentVisibilityRanges(double hiddenOnOrBelow, double visibleOnOrAbove) {
if(hiddenOnOrBelow < 0 || visibleOnOrAbove > 1)
throw new IllegalArgumentException("component visibility boundaries must be between 0 and 1 (inclusive), but were %.3f and %.3f".formatted(hiddenOnOrBelow, visibleOnOrAbove));
throw new IllegalArgumentException(String.format("component visibility boundaries must be between 0 and 1 (inclusive), but were %.3f and %.3f", hiddenOnOrBelow, visibleOnOrAbove));
else if(hiddenOnOrBelow > visibleOnOrAbove)
throw new IllegalArgumentException("visibility boundary for hiding the component (%.3f) must not be greater than the boundary for showing it (%.3f)".formatted(hiddenOnOrBelow, visibleOnOrAbove));
throw new IllegalArgumentException(String.format("visibility boundary for hiding the component (%.3f) must not be greater than the boundary for showing it (%.3f)", hiddenOnOrBelow, visibleOnOrAbove));
else {
this.shownVisibilityRange = visibleOnOrAbove;
this.hiddenVisibilityRange = hiddenOnOrBelow;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@
* @author miki
* @since 2022-05-16
*/
@CssImport(value = "./styles/label-positions.css", themeFor = "vaadin-custom-field")
@CssImport(value = "./styles/label-positions-custom-field.css", themeFor = "vaadin-custom-field")
@Tag("object-field")
@JsModule("./object-field.js")
public class ObjectField<T> extends CustomField<T>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
* @author miki
* @since 2022-04-08
*/
@CssImport(value = "./styles/label-positions.css", themeFor = "vaadin-custom-field")
@CssImport(value = "./styles/label-positions-custom-field.css", themeFor = "vaadin-custom-field")
@Tag("label-field")
@JsModule("./label-field.js")
public class LabelField<V> extends CustomField<V> implements HasStyle, WithLabelMixin<LabelField<V>>,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,7 @@
import com.vaadin.flow.component.Component;
import com.vaadin.flow.component.HasHelper;
import com.vaadin.flow.component.HasLabel;
import com.vaadin.flow.component.shared.HasPrefix;
import com.vaadin.flow.component.shared.HasSuffix;
import com.vaadin.flow.component.shared.HasTooltip;
import com.vaadin.flow.component.textfield.HasPrefixAndSuffix;
import org.vaadin.miki.markers.HasDatePattern;
import org.vaadin.miki.markers.HasHelperPositionable;
import org.vaadin.miki.markers.HasIcon;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import {CustomField} from '@vaadin/custom-field';
import {CustomFieldElement} from '@vaadin/vaadin-custom-field';

class ButtonMultiSelect extends CustomField {
class ButtonMultiSelect extends CustomFieldElement {

static get is() {return 'button-multi-select'}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import {CustomField} from '@vaadin/custom-field';
import {CustomFieldElement} from '@vaadin/vaadin-custom-field';

class ButtonSelect extends CustomField {
class ButtonSelect extends CustomFieldElement {

static get is() {return 'button-select'}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import {CustomField} from '@vaadin/custom-field';
import {CustomFieldElement} from '@vaadin/vaadin-custom-field';

class CollectionField extends CustomField {
class CollectionField extends CustomFieldElement {

static get is() {return 'collection-field'}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import {CustomField} from '@vaadin/custom-field';
import {CustomFieldElement} from '@vaadin/vaadin-custom-field';

class ComponentMultiSelect extends CustomField {
class ComponentMultiSelect extends CustomFieldElement {

static get is() {return 'component-multi-select'}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import {CustomField} from '@vaadin/custom-field';
import {CustomFieldElement} from '@vaadin/vaadin-custom-field';

class ComponentSelect extends CustomField {
class ComponentSelect extends CustomFieldElement {

static get is() {return 'component-select'}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,8 @@ export class DatePatternMixin {
// fixes #490 (only when some value is already there)
if (datepicker.value !== undefined && datepicker.value.length > 0) {
let parsed = datepicker.value.match(/^([0-9]{4})-([0-9]{2})-([0-9]{2})$/);
datepicker.inputElement.value = datepicker.i18n.formatDate({day: parseInt(parsed[3], 10), month: parseInt(parsed[2], 10)-1, year: parseInt(parsed[1], 10)});
// datepicker.inputElement does not work in v14, hence this query
datepicker.shadowRoot.querySelector('vaadin-date-picker-text-field').value = datepicker.i18n.formatDate({day: parseInt(parsed[3], 10), month: parseInt(parsed[2], 10)-1, year: parseInt(parsed[1], 10)});
}
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import {CustomField} from '@vaadin/custom-field';
import {CustomFieldElement} from '@vaadin/vaadin-custom-field';

class GridMultiSelect extends CustomField {
class GridMultiSelect extends CustomFieldElement {

static get is() {return 'grid-multi-select'}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import {CustomField} from '@vaadin/custom-field';
import {CustomFieldElement} from '@vaadin/vaadin-custom-field';

class GridSelect extends CustomField {
class GridSelect extends CustomFieldElement {

static get is() {return 'grid-select'}

Expand Down

0 comments on commit 5c064ea

Please sign in to comment.