diff --git a/.gitignore b/.gitignore index c522463..7931151 100644 --- a/.gitignore +++ b/.gitignore @@ -17,3 +17,6 @@ types.d.ts /frontend/index.html vite.generated.ts /src/main/dev-bundle +/src/main/bundles +/src/main/frontend/generated +/src/main/frontend/index.html \ No newline at end of file diff --git a/pom.xml b/pom.xml index a4e43bd..1d18203 100644 --- a/pom.xml +++ b/pom.xml @@ -3,7 +3,7 @@ 4.0.0 com.flowingcode.vaadin.addons twincolgrid - 3.1.1-SNAPSHOT + 3.2.0-SNAPSHOT TwinColGrid add-on Dual list component based on Vaadin Grids https://www.flowingcode.com/en/open-source/ diff --git a/src/main/java/com/flowingcode/vaadin/addons/twincolgrid/Label.java b/src/main/java/com/flowingcode/vaadin/addons/twincolgrid/Label.java new file mode 100644 index 0000000..b70c4d3 --- /dev/null +++ b/src/main/java/com/flowingcode/vaadin/addons/twincolgrid/Label.java @@ -0,0 +1,49 @@ +/*- + * #%L + * TwinColGrid add-on + * %% + * Copyright (C) 2017 - 2025 Flowing Code + * %% + * 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 com.flowingcode.vaadin.addons.twincolgrid; + +import com.vaadin.flow.component.Component; +import com.vaadin.flow.component.HasStyle; +import com.vaadin.flow.component.HasText; +import com.vaadin.flow.component.Tag; +import com.vaadin.flow.component.Text; + +@Tag(Tag.LABEL) +class Label extends Component implements HasText, HasStyle { + + public Label() {} + + public Label(String text) { + getElement().appendChild(new Text(text).getElement()); + } + + public void setFor(Component forComponent) { + if (forComponent == null) { + throw new IllegalArgumentException("The provided component cannot be null"); + } + setFor(forComponent.getId() + .orElseThrow(() -> new IllegalArgumentException("The provided component must have an id"))); + } + + public void setFor(String forId) { + getElement().setAttribute("for", forId); + } + +} diff --git a/src/main/java/com/flowingcode/vaadin/addons/twincolgrid/TwinColGrid.java b/src/main/java/com/flowingcode/vaadin/addons/twincolgrid/TwinColGrid.java index c548c20..ac1a184 100644 --- a/src/main/java/com/flowingcode/vaadin/addons/twincolgrid/TwinColGrid.java +++ b/src/main/java/com/flowingcode/vaadin/addons/twincolgrid/TwinColGrid.java @@ -41,7 +41,6 @@ import com.vaadin.flow.component.grid.HeaderRow; import com.vaadin.flow.component.grid.dnd.GridDropLocation; import com.vaadin.flow.component.grid.dnd.GridDropMode; -import com.vaadin.flow.component.html.Label; import com.vaadin.flow.component.html.Span; import com.vaadin.flow.component.icon.VaadinIcon; import com.vaadin.flow.component.orderedlayout.HorizontalLayout;