From 7ffed095a0ae23721915e52e820be5557a8f5708 Mon Sep 17 00:00:00 2001 From: "Ahmad K. Bawaneh" Date: Sun, 29 Dec 2024 19:33:27 +0300 Subject: [PATCH] general enhancements --- .../dominokit/domino/ui/dnd/Draggable.java | 15 +++++++++++ .../domino/ui/utils/meta/AttributeMeta.java | 26 ++++++++++++++++++- .../dui-components/domino-ui-forms.css | 5 ++++ 3 files changed, 45 insertions(+), 1 deletion(-) diff --git a/domino-ui/src/main/java/org/dominokit/domino/ui/dnd/Draggable.java b/domino-ui/src/main/java/org/dominokit/domino/ui/dnd/Draggable.java index a1840fc04..aa8a0456f 100644 --- a/domino-ui/src/main/java/org/dominokit/domino/ui/dnd/Draggable.java +++ b/domino-ui/src/main/java/org/dominokit/domino/ui/dnd/Draggable.java @@ -19,6 +19,7 @@ import static org.dominokit.domino.ui.utils.ElementsFactory.elements; import elemental2.dom.*; +import java.util.Objects; import java.util.function.Consumer; import org.dominokit.domino.ui.IsElement; import org.dominokit.domino.ui.utils.DominoElement; @@ -167,4 +168,18 @@ public String getId() { public interface DraggableConfig { boolean isEnabled(); } + + @Override + public boolean equals(Object o) { + if (!(o instanceof Draggable)) { + return false; + } + Draggable draggable = (Draggable) o; + return Objects.equals(id, draggable.id); + } + + @Override + public int hashCode() { + return Objects.hashCode(id); + } } diff --git a/domino-ui/src/main/java/org/dominokit/domino/ui/utils/meta/AttributeMeta.java b/domino-ui/src/main/java/org/dominokit/domino/ui/utils/meta/AttributeMeta.java index 245b903d4..d64d52785 100644 --- a/domino-ui/src/main/java/org/dominokit/domino/ui/utils/meta/AttributeMeta.java +++ b/domino-ui/src/main/java/org/dominokit/domino/ui/utils/meta/AttributeMeta.java @@ -15,7 +15,12 @@ */ package org.dominokit.domino.ui.utils.meta; +import static java.util.Objects.nonNull; + +import java.util.HashSet; import java.util.Optional; +import java.util.Set; +import java.util.function.Consumer; import org.dominokit.domino.ui.utils.ComponentMeta; import org.dominokit.domino.ui.utils.HasMeta; @@ -29,7 +34,8 @@ public class AttributeMeta implements ComponentMeta { private String key; - private final T value; + private T value; + private Set> changeHandlers = new HashSet<>(); /** * Creates a new instance of {@code AttributeMeta} with the specified key and value. @@ -76,6 +82,17 @@ public T getValue() { return value; } + /** + * Gets the value stored as metadata. + * + * @return The value associated with this metadata item. + */ + public AttributeMeta setValue(T value) { + this.value = value; + this.changeHandlers.forEach(c -> c.accept(this.value)); + return this; + } + /** * Gets the key associated with this metadata item. * @@ -85,4 +102,11 @@ public T getValue() { public String getKey() { return key; } + + public AttributeMeta onValueChanged(Consumer handler) { + if (nonNull(handler)) { + this.changeHandlers.add(handler); + } + return this; + } } diff --git a/domino-ui/src/main/resources/org/dominokit/domino/ui/public/css/domino-ui/dui-components/domino-ui-forms.css b/domino-ui/src/main/resources/org/dominokit/domino/ui/public/css/domino-ui/dui-components/domino-ui-forms.css index 36357087e..730acb06a 100644 --- a/domino-ui/src/main/resources/org/dominokit/domino/ui/public/css/domino-ui/dui-components/domino-ui-forms.css +++ b/domino-ui/src/main/resources/org/dominokit/domino/ui/public/css/domino-ui/dui-components/domino-ui-forms.css @@ -388,6 +388,11 @@ textarea.dui-field-input { outline-offset: var(--dui-form-field-checkbox-outline-offset); } +.dui-form-radio-group[readonly] .dui-form-radio, +.dui-form-radio[readonly] { + pointer-events: none; +} + .dui-disable-transition .dui-form-checkbox .dui-checkbox-label:before, .dui-form-checkbox .dui-checkbox-label.dui-disable-transition :before, .dui-form-checkbox.dui-disable-transition .dui-checkbox-label:before {