All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.github.fluorumlabs.disconnect.vaadin.Checkbox Maven / Gradle / Ivy

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 nameDescription
checkboxThe wrapper element for the native
labelThe wrapper element in which the component's children, namely the label, is * slotted
* The following state attributes are available for styling: * * * * * * * * * * * * * * *
AttributeDescriptionPart name
activeSet when the checkbox is pressed down, either with mouse, touch or the * keyboard.:host
disabledSet when the checkbox is disabled.:host
focus-ringSet when the checkbox is focused using the keyboard * .:host
focusedSet when the checkbox is focused.:host
indeterminateSet when the checkbox is in indeterminate mode * .:host
checkedSet when the checkbox is checked.:host
emptySet 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"); } }




© 2015 - 2024 Weber Informatics LLC | Privacy Policy