com.github.fluorumlabs.disconnect.vaadin.Checkbox Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of disconnect-vaadin Show documentation
Show all versions of disconnect-vaadin Show documentation
Vaadin components bindings for Disconnect Zero
The newest version!
package com.github.fluorumlabs.disconnect.vaadin;
import com.github.fluorumlabs.disconnect.core.annotations.WebComponent;
import com.github.fluorumlabs.disconnect.polymer.mixins.HasGestureEventListeners;
import com.github.fluorumlabs.disconnect.polymer.types.BooleanPropertyChangeEvent;
import com.github.fluorumlabs.disconnect.vaadin.elements.CheckboxElement;
import com.github.fluorumlabs.disconnect.vaadin.mixins.HasControlStateMixin;
import com.github.fluorumlabs.disconnect.vaadin.mixins.HasElementMixin;
import com.github.fluorumlabs.disconnect.zero.component.AbstractComponent;
import com.github.fluorumlabs.disconnect.zero.component.Component;
import com.github.fluorumlabs.disconnect.zero.component.HasComponents;
import com.github.fluorumlabs.disconnect.zero.component.HasStyle;
import com.github.fluorumlabs.disconnect.zero.observable.ObservableEvent;
import com.github.fluorumlabs.disconnect.zero.observable.ObservableValue;
import javax.annotation.Nullable;
/**
* <vaadin-checkbox>
is a Web Component for customized checkboxes.
*
* <vaadin-checkbox>
* Make my profile visible
* </vaadin-checkbox>
*
* Styling
* The following shadow DOM parts are available for styling:
*
*
*
* Part name Description
*
*
* checkbox
The wrapper element for the native
* label
The wrapper element in which the component's children, namely the label, is
* slotted
*
*
* The following state attributes are available for styling:
*
*
*
* Attribute Description Part name
*
*
* active
Set when the checkbox is pressed down, either with mouse, touch or the
* keyboard. :host
* disabled
Set when the checkbox is disabled. :host
* focus-ring
Set when the checkbox is focused using the keyboard
* . :host
* focused
Set when the checkbox is focused. :host
* indeterminate
Set when the checkbox is in indeterminate mode
* . :host
* checked
Set when the checkbox is checked. :host
* empty
Set when there is no label provided. label
*
*
* See
* ThemableMixin – how to apply styles for shadow parts
*/
@WebComponent
public class Checkbox extends AbstractComponent
implements HasElementMixin,
HasControlStateMixin,
HasGestureEventListeners,
HasStyle, HasComponents> {
public Checkbox() {
super(CheckboxElement.TAGNAME());
}
public Checkbox(String value) {
this();
value(value).text(value);
}
public Checkbox(String value, Component>... components) {
this();
value(value).add(components);
}
/**
* Name of the element.
*/
public String name() {
return getNode().getName();
}
/**
* Name of the element.
*/
public Checkbox name(String name) {
getNode().setName(name);
return this;
}
/**
* True if the checkbox is checked.
*/
public ObservableValue checked() {
return createObservableValue(getNode()::isChecked, getNode()::setChecked, checkedChangedEvent());
}
/**
* Indeterminate state of the checkbox when it's neither checked nor unchecked, but undetermined.
* https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input/checkbox#Indeterminate_state_checkboxes
*/
public ObservableValue indeterminate() {
return createObservableValue(() -> getNode().isIndeterminate(), v -> getNode().setIndeterminate(v), indeterminateChangedEvent());
}
// /**
// * True if the checkbox is checked.
// */
// public boolean checked() {
// return getNode().isChecked();
// }
//
// /**
// * True if the checkbox is checked.
// */
// public Checkbox checked(boolean checked) {
// getNode().setChecked(checked);
// return this;
// }
//
// /**
// * Indeterminate state of the checkbox when it's neither checked nor unchecked, but undetermined.
// * https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input/checkbox#Indeterminate_state_checkboxes
// */
// public boolean indeterminate() {
// return getNode().isIndeterminate();
// }
//
// /**
// * Indeterminate state of the checkbox when it's neither checked nor unchecked, but undetermined.
// * https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input/checkbox#Indeterminate_state_checkboxes
// */
// public Checkbox indeterminate(boolean indeterminate) {
// getNode().setIndeterminate(indeterminate);
// return this;
// }
/**
* The value given to the data submitted with the checkbox's name to the server when the control is inside a form.
*/
@Nullable
public String value() {
return getNode().getValue();
}
/**
* The value given to the data submitted with the checkbox's name to the server when the control is inside a form.
*/
public Checkbox value(String value) {
getNode().setValue(value);
return this;
}
/**
* Fired when the checked
property changes.
*/
public ObservableEvent checkedChangedEvent() {
return createEvent("checked-changed");
}
/**
* Fired when the indeterminate
property changes.
*/
public ObservableEvent indeterminateChangedEvent() {
return createEvent("indeterminate-changed");
}
}