Skip to content

Commit

Permalink
Merge pull request #975 from GwtMaterialDesign/release_2.4.0
Browse files Browse the repository at this point in the history
Release 2.4.0-rc2
  • Loading branch information
kevzlou7979 committed Aug 10, 2020
2 parents c0d2e7c + da63940 commit c4bfcaa
Show file tree
Hide file tree
Showing 10 changed files with 92 additions and 23 deletions.
4 changes: 2 additions & 2 deletions README.md
Expand Up @@ -20,12 +20,12 @@ We created <a href="http://gwtmaterialdesign.github.io/gwt-material-demo/apidocs


## Maven
### Current Version 2.4.0-rc1
### Current Version 2.4.0-rc2
```xml
<dependency>
<groupId>com.github.gwtmaterialdesign</groupId>
<artifactId>gwt-material</artifactId>
<version>2.4.0-rc1</version>
<version>2.4.0-rc2</version>
</dependency>
```
### Snapshot Version 2.4.0-SNAPSHOT
Expand Down
2 changes: 1 addition & 1 deletion gwt-material/pom.xml
Expand Up @@ -4,7 +4,7 @@
<parent>
<artifactId>gwt-material-parent</artifactId>
<groupId>com.github.gwtmaterialdesign</groupId>
<version>2.4.0-rc1</version>
<version>2.4.0-rc2</version>
</parent>
<modelVersion>4.0.0</modelVersion>

Expand Down
Expand Up @@ -19,9 +19,16 @@
*/
package gwt.material.design.client.base;

import gwt.material.design.client.constants.Autocomplete;

/**
* The autocomplete attribute specifies whether or not an input field should have autocomplete enabled.
*
* <a href="https://developer.mozilla.org/en-US/docs/Web/Security/Securing_your_site/Turning_off_form_autocompletion">Documentation</a>
*/
public interface HasAutocomplete {

void setAutocomplete(boolean value);
void setAutocomplete(Autocomplete autocomplete);

boolean isAutocomplete();
Autocomplete getAutocomplete();
}
@@ -0,0 +1,43 @@
/*
* #%L
* GwtMaterial
* %%
* Copyright (C) 2015 - 2020 GwtMaterialDesign
* %%
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* #L%
*/
package gwt.material.design.client.constants;

import java.util.Arrays;

public enum Autocomplete {

ON("on"),
OFF("off"),
NEW_PASSWORD("new-password");

private String name;

Autocomplete(String name) {
this.name = name;
}

public String getName() {
return name;
}

public static Autocomplete get(String name) {
return name != null && !name.isEmpty() ? Arrays.stream(values()).filter(autocomplete -> autocomplete.getName().equals(name)).findAny().orElse(null) : null;
}
}
Expand Up @@ -29,10 +29,7 @@
import gwt.material.design.client.base.HasActive;
import gwt.material.design.client.base.HasSearchHandlers;
import gwt.material.design.client.base.SearchObject;
import gwt.material.design.client.constants.Color;
import gwt.material.design.client.constants.CssName;
import gwt.material.design.client.constants.IconType;
import gwt.material.design.client.constants.InputType;
import gwt.material.design.client.constants.*;
import gwt.material.design.client.events.SearchFinishEvent;
import gwt.material.design.client.events.SearchNoResultEvent;
import gwt.material.design.client.ui.html.Label;
Expand Down Expand Up @@ -134,7 +131,7 @@ protected void onLoad() {
super.onLoad();

setType(InputType.SEARCH);
setAutocomplete(false);
setAutocomplete(Autocomplete.OFF);
label.add(iconSearch);
label.getElement().setAttribute("for", "search");
add(label);
Expand Down
Expand Up @@ -70,7 +70,7 @@
public class MaterialValueBox<T> extends AbstractValueWidget<T> implements HasChangeHandlers, HasName,
HasDirectionEstimator, HasText, AutoDirectionHandler.Target, IsEditor<ValueBoxEditor<T>>, HasIcon,
HasInputType, HasPlaceholder, HasCounter, HasReadOnly, HasActive, HasFieldTypes,
HasAutocomplete, HasPasteHandlers, HasFieldSensitivity, HasLabel {
HasToggleReadOnlyHandler, HasAutocomplete, HasPasteHandlers, HasFieldSensitivity, HasLabel {


private boolean returnBlankAsNull;
Expand Down Expand Up @@ -122,7 +122,7 @@ public MaterialValueBox(ValueBoxBase<T> tValueBox) {
public void setup(ValueBoxBase<T> tValueBox) {
valueBoxBase = tValueBox;
add(valueBoxBase);
setAutocomplete(false);
setAutocomplete(Autocomplete.OFF);
}

@Deprecated
Expand Down Expand Up @@ -565,13 +565,13 @@ public void setFieldWidth(double percentWidth) {
}

@Override
public void setAutocomplete(boolean value) {
valueBoxBase.getElement().setAttribute("autocomplete", value ? "on" : "off");
public void setAutocomplete(Autocomplete value) {
valueBoxBase.getElement().setAttribute("autocomplete", value.getName());
}

@Override
public boolean isAutocomplete() {
return valueBoxBase.getElement().getAttribute("autocomplete").equals("on");
public Autocomplete getAutocomplete() {
return Autocomplete.get(valueBoxBase.getElement().getAttribute("autocomplete"));
}

@Override
Expand Down Expand Up @@ -881,6 +881,11 @@ public HandlerRegistration addPasteHandler(PasteEvent.PasteEventHandler handler)
return addHandler(handler, PasteEvent.getType());
}

@Override
public HandlerRegistration addToggleReadOnlyHandler(ToggleReadOnlyEvent.ToggleReadOnlyHandler handler) {
return addHandler(handler, ToggleReadOnlyEvent.getType());
}

@Override
protected FocusableMixin<MaterialWidget> getFocusableMixin() {
if (focusableMixin == null) {
Expand Down
Expand Up @@ -588,4 +588,16 @@ blockquote {

pre {
background: #323232 !important
}

/** Autocomplete **/
input:-webkit-autofill,
input:-webkit-autofill:hover,
input:-webkit-autofill:focus,
textarea:-webkit-autofill,
textarea:-webkit-autofill:hover,
textarea:-webkit-autofill:focus {
-webkit-text-fill-color: white;
-webkit-box-shadow: 0 0 0px 1000px #2f2f2f inset !important;
transition: background-color 5000s ease-in-out 0s;
}

Large diffs are not rendered by default.

Expand Up @@ -22,6 +22,7 @@
import com.google.gwt.event.shared.HasHandlers;
import com.google.gwt.user.client.ui.IsWidget;
import com.google.gwt.user.client.ui.ValueBoxBase;
import gwt.material.design.client.constants.Autocomplete;
import gwt.material.design.client.constants.StatusDisplayType;
import gwt.material.design.client.ui.base.AbstractValueWidgetTest;

Expand Down Expand Up @@ -120,14 +121,18 @@ protected <W extends MaterialValueBox> void checkMandatoryField(W widget) {
protected <W extends MaterialValueBox> void checkAutocomplete(W widget) {
ValueBoxBase valueBoxBase = widget.getValueBoxBase();

widget.setAutocomplete(true);
assertTrue(widget.isAutocomplete());
widget.setAutocomplete(Autocomplete.ON);
assertEquals(Autocomplete.ON, widget.getAutocomplete());
assertEquals(valueBoxBase.getElement().getAttribute("autocomplete"), "on");

widget.setAutocomplete(false);
assertFalse(widget.isAutocomplete());
widget.setAutocomplete(Autocomplete.OFF);
assertEquals(Autocomplete.OFF, widget.getAutocomplete());
assertEquals(valueBoxBase.getElement().getAttribute("autocomplete"), "off");

widget.setAutocomplete(Autocomplete.NEW_PASSWORD);
assertEquals(Autocomplete.NEW_PASSWORD, widget.getAutocomplete());
assertEquals(valueBoxBase.getElement().getAttribute("autocomplete"), "new-password");

valueBoxBase.getElement().removeAttribute("autocomplete");
}

Expand Down
4 changes: 2 additions & 2 deletions pom.xml
Expand Up @@ -5,7 +5,7 @@

<groupId>com.github.gwtmaterialdesign</groupId>
<artifactId>gwt-material-parent</artifactId>
<version>2.4.0-rc1</version>
<version>2.4.0-rc2</version>
<packaging>pom</packaging>
<modules>
<module>gwt-material</module>
Expand Down Expand Up @@ -69,7 +69,7 @@
<connection>scm:git:git@github.com:GwtMaterialDesign/gwt-material.git</connection>
<developerConnection>scm:git:git@github.com:GwtMaterialDesign/gwt-material.git</developerConnection>
<url>http://github.com/GwtMaterialDesign/gwt-material</url>
<tag>v2.4.0-rc1</tag>
<tag>v2.4.0-rc2</tag>
</scm>

<licenses>
Expand Down

0 comments on commit c4bfcaa

Please sign in to comment.