diff --git a/domino-ui-shared/pom.xml b/domino-ui-shared/pom.xml index bdf04d0dd..8dabbb838 100644 --- a/domino-ui-shared/pom.xml +++ b/domino-ui-shared/pom.xml @@ -5,7 +5,7 @@ domino-ui-parent org.dominokit - 2.0.0 + 2.0.1 jar 4.0.0 diff --git a/domino-ui-tools/mdi-icons-processor/pom.xml b/domino-ui-tools/mdi-icons-processor/pom.xml index 8b5ecf7e9..e2e7801ef 100644 --- a/domino-ui-tools/mdi-icons-processor/pom.xml +++ b/domino-ui-tools/mdi-icons-processor/pom.xml @@ -5,7 +5,7 @@ domino-ui-tools org.dominokit - 2.0.0 + 2.0.1 4.0.0 diff --git a/domino-ui-tools/pom.xml b/domino-ui-tools/pom.xml index 3846ae6db..1d008ed76 100644 --- a/domino-ui-tools/pom.xml +++ b/domino-ui-tools/pom.xml @@ -5,7 +5,7 @@ domino-ui-parent org.dominokit - 2.0.0 + 2.0.1 4.0.0 diff --git a/domino-ui-webjar/pom.xml b/domino-ui-webjar/pom.xml index ee41dbeb0..2e5972d55 100644 --- a/domino-ui-webjar/pom.xml +++ b/domino-ui-webjar/pom.xml @@ -5,7 +5,7 @@ domino-ui-parent org.dominokit - 2.0.0 + 2.0.1 jar 4.0.0 diff --git a/domino-ui/pom.xml b/domino-ui/pom.xml index efb92fdf7..d9b77dbee 100644 --- a/domino-ui/pom.xml +++ b/domino-ui/pom.xml @@ -6,7 +6,7 @@ org.dominokit domino-ui-parent - 2.0.0 + 2.0.1 domino-ui diff --git a/domino-ui/src/main/java/org/dominokit/domino/ui/config/SearchConfig.java b/domino-ui/src/main/java/org/dominokit/domino/ui/config/SearchConfig.java index f1d056e4a..e1d9e41cf 100644 --- a/domino-ui/src/main/java/org/dominokit/domino/ui/config/SearchConfig.java +++ b/domino-ui/src/main/java/org/dominokit/domino/ui/config/SearchConfig.java @@ -31,4 +31,16 @@ public interface SearchConfig extends ComponentConfig { default int getAutoSearchDelay() { return 200; } + + /** + * Use this method to define the default auto search delay for datatable DelayedHeaderFilter in + * milliseconds + * + *

Defaults to : {@link #getAutoSearchDelay()}> + * + * @return an integer delay in milliseconds + */ + default int getTableTextHeaderFilterSearchDelay() { + return getAutoSearchDelay(); + } } diff --git a/domino-ui/src/main/java/org/dominokit/domino/ui/datatable/ColumnConfig.java b/domino-ui/src/main/java/org/dominokit/domino/ui/datatable/ColumnConfig.java index 490b9116c..a636f4813 100644 --- a/domino-ui/src/main/java/org/dominokit/domino/ui/datatable/ColumnConfig.java +++ b/domino-ui/src/main/java/org/dominokit/domino/ui/datatable/ColumnConfig.java @@ -601,12 +601,12 @@ public CellStyler getCellStyler() { } /** - * Checks if tooltips are shown for the column. + * Checks if tooltips are shown for the column and the column has a tooltip node or has a title. * - * @return true if tooltips are shown, false otherwise + * @return true if tooltips are shown and there is a tooltip node or a title, false otherwise */ public boolean isShowTooltip() { - return showTooltip; + return showTooltip && (nonNull(tooltipNode) || (nonNull(title) && !title.trim().isEmpty())); } /** diff --git a/domino-ui/src/main/java/org/dominokit/domino/ui/datatable/TableConfig.java b/domino-ui/src/main/java/org/dominokit/domino/ui/datatable/TableConfig.java index f679f5871..43a42c643 100644 --- a/domino-ui/src/main/java/org/dominokit/domino/ui/datatable/TableConfig.java +++ b/domino-ui/src/main/java/org/dominokit/domino/ui/datatable/TableConfig.java @@ -68,6 +68,7 @@ public class TableConfig private String minWidth; private Consumer> onRowEditHandler = (tableRow) -> {}; + private Consumer> onRowFinishEditHandler = (tableRow) -> {}; private final ColumnConfig pluginUtilityColumn = ColumnConfig.create("plugin-utility-column") @@ -582,6 +583,26 @@ Consumer> getOnRowEditHandler() { return onRowEditHandler; } + /** + * Use this to set a handler that will be called when ever a row editing finished. + * + * @param handler The handler to be called. + * @return same TableConfig instance. + */ + public TableConfig setOnRowFinishEditHandler(Consumer> handler) { + if (isNull(handler)) { + this.onRowFinishEditHandler = tableRow -> {}; + } else { + this.onRowFinishEditHandler = handler; + } + return this; + } + + /** @return the handler to be called when a row editing finished. */ + Consumer> getOnRowFinishEditHandler() { + return onRowFinishEditHandler; + } + /** A functional interface defining the behavior for appending rows. */ @FunctionalInterface public interface RowAppender { diff --git a/domino-ui/src/main/java/org/dominokit/domino/ui/datatable/TableRow.java b/domino-ui/src/main/java/org/dominokit/domino/ui/datatable/TableRow.java index c002422f9..a168631b8 100644 --- a/domino-ui/src/main/java/org/dominokit/domino/ui/datatable/TableRow.java +++ b/domino-ui/src/main/java/org/dominokit/domino/ui/datatable/TableRow.java @@ -65,6 +65,7 @@ public class TableRow extends BaseDominoElement dataTable, ColumnConfig column) { */ @Override public void onRowAdded(DataTable dataTable, TableRow tableRow) { - dragSource.addDraggable(Draggable.of(tableRow)); + Draggable> draggable = Draggable.of(tableRow); + draggable.setConfig(tableRow::isDraggable); + dragSource.addDraggable(draggable); dropZone.addDropTarget( tableRow, draggableId -> moveItem(dataTable, tableRow.getRecord(), draggableId)); } diff --git a/domino-ui/src/main/java/org/dominokit/domino/ui/datatable/plugins/filter/header/DelayedHeaderFilterInput.java b/domino-ui/src/main/java/org/dominokit/domino/ui/datatable/plugins/filter/header/DelayedHeaderFilterInput.java index e5eff8e09..a84d746b2 100644 --- a/domino-ui/src/main/java/org/dominokit/domino/ui/datatable/plugins/filter/header/DelayedHeaderFilterInput.java +++ b/domino-ui/src/main/java/org/dominokit/domino/ui/datatable/plugins/filter/header/DelayedHeaderFilterInput.java @@ -30,6 +30,7 @@ import org.dominokit.domino.ui.datatable.plugins.column.ColumnHeaderFilterPlugin; import org.dominokit.domino.ui.forms.InputFormField; import org.dominokit.domino.ui.utils.DelayedTextInput; +import org.dominokit.domino.ui.utils.DominoUIConfig; import org.dominokit.domino.ui.utils.HasPlaceHolder; /** @@ -65,7 +66,10 @@ public DelayedHeaderFilterInput(String placeHolder) { ((HasPlaceHolder) input).setPlaceholder(placeHolder); } - delayedTextInput = DelayedTextInput.create(getInputElement(), 200); + delayedTextInput = + DelayedTextInput.create( + getInputElement(), + DominoUIConfig.CONFIG.getUIConfig().getTableTextHeaderFilterSearchDelay()); } /** diff --git a/domino-ui/src/main/java/org/dominokit/domino/ui/datatable/plugins/filter/header/TextHeaderFilter.java b/domino-ui/src/main/java/org/dominokit/domino/ui/datatable/plugins/filter/header/TextHeaderFilter.java index 37d136b33..436c738b8 100644 --- a/domino-ui/src/main/java/org/dominokit/domino/ui/datatable/plugins/filter/header/TextHeaderFilter.java +++ b/domino-ui/src/main/java/org/dominokit/domino/ui/datatable/plugins/filter/header/TextHeaderFilter.java @@ -16,8 +16,6 @@ package org.dominokit.domino.ui.datatable.plugins.filter.header; -import static org.dominokit.domino.ui.utils.Domino.*; - import elemental2.dom.HTMLInputElement; import org.dominokit.domino.ui.datatable.model.FilterTypes; import org.dominokit.domino.ui.forms.TextBox; diff --git a/domino-ui/src/main/java/org/dominokit/domino/ui/datatable/plugins/selection/SelectionPlugin.java b/domino-ui/src/main/java/org/dominokit/domino/ui/datatable/plugins/selection/SelectionPlugin.java index c33c05de3..6c56b7f6f 100644 --- a/domino-ui/src/main/java/org/dominokit/domino/ui/datatable/plugins/selection/SelectionPlugin.java +++ b/domino-ui/src/main/java/org/dominokit/domino/ui/datatable/plugins/selection/SelectionPlugin.java @@ -21,7 +21,6 @@ import static java.util.Objects.nonNull; import static org.dominokit.domino.ui.datatable.DataTableStyles.dui_datatable_row_selected; import static org.dominokit.domino.ui.forms.FormsStyles.dui_form_select_check_box; -import static org.dominokit.domino.ui.utils.Domino.*; import elemental2.dom.Element; import elemental2.dom.HTMLElement; @@ -34,6 +33,7 @@ import jsinterop.base.Js; import org.dominokit.domino.ui.datatable.*; import org.dominokit.domino.ui.datatable.events.OnBeforeDataChangeEvent; +import org.dominokit.domino.ui.datatable.events.TableDataUpdatedEvent; import org.dominokit.domino.ui.datatable.events.TableEvent; import org.dominokit.domino.ui.datatable.plugins.DataTablePlugin; import org.dominokit.domino.ui.forms.CheckBox; @@ -58,6 +58,7 @@ public class SelectionPlugin implements DataTablePlugin { private DataTable datatable; private List oldSelection = new ArrayList<>(); private boolean retainSelectionOnDataChange = false; + private CheckBox headerCheckBox; /** Creates a new `SelectionPlugin` with default settings. */ public SelectionPlugin() {} @@ -300,8 +301,8 @@ private void deselectRow(DataTable dataTable, TableRow tableRow) { * @return The selection indicator element for a multi-selection header. */ private HTMLElement createMultiSelectHeader(DataTable dataTable) { - CheckBox checkBox = createCheckBox(Optional.empty()); - checkBox.addChangeListener( + headerCheckBox = createCheckBox(Optional.empty()); + headerCheckBox.addChangeListener( (oldValue, checked) -> { if (checked) { dataTable.selectAll(selectionCondition); @@ -312,20 +313,24 @@ private HTMLElement createMultiSelectHeader(DataTable dataTable) { dataTable.addSelectionDeselectionListener( (source, selectedRows) -> { - long selectableCount = - dataTable.getRows().stream() - .filter(tableRow -> selectionCondition.isAllowSelection(dataTable, tableRow)) - .count(); - if (selectedRows.size() > 0 && selectedRows.size() < selectableCount) { - checkBox.indeterminate(); - } else if (selectedRows.size() == selectableCount) { - checkBox.check(true); - } else if (selectedRows.isEmpty()) { - checkBox.uncheck(true); - } + updateHeaderCheckBox(selectedRows); }); - return checkBox.element(); + return headerCheckBox.element(); + } + + private void updateHeaderCheckBox(List> selectedRows) { + long selectableCount = + this.datatable.getRows().stream() + .filter(tableRow -> selectionCondition.isAllowSelection(this.datatable, tableRow)) + .count(); + if (selectedRows.size() > 0 && selectedRows.size() < selectableCount) { + headerCheckBox.indeterminate(); + } else if (selectedRows.size() == selectableCount) { + headerCheckBox.check(true); + } else if (selectedRows.isEmpty()) { + headerCheckBox.uncheck(true); + } } /** @@ -402,6 +407,12 @@ public void handleEvent(TableEvent event) { this.oldSelection = this.datatable.getSelectedRecords(); } } + + if (TableDataUpdatedEvent.DATA_UPDATED.equals(event.getType())) { + if (this.datatable.getTableConfig().isMultiSelect()) { + updateHeaderCheckBox(this.datatable.getSelectedItems()); + } + } } /** diff --git a/domino-ui/src/main/java/org/dominokit/domino/ui/datatable/plugins/tree/TreeGridPlugin.java b/domino-ui/src/main/java/org/dominokit/domino/ui/datatable/plugins/tree/TreeGridPlugin.java index 5a15349d8..b504b0021 100644 --- a/domino-ui/src/main/java/org/dominokit/domino/ui/datatable/plugins/tree/TreeGridPlugin.java +++ b/domino-ui/src/main/java/org/dominokit/domino/ui/datatable/plugins/tree/TreeGridPlugin.java @@ -335,9 +335,11 @@ private void expand(TableRow row, boolean recursive) { Optional iconMeta = row.getMeta(TREE_GRID_ROW_TOGGLE_ICON); iconMeta.ifPresent( meta -> { - ToggleIcon icon = Js.uncheckedCast(meta.icon); - if (!icon.isToggled()) { - icon.toggle(); + if (!row.getChildren().isEmpty()) { + ToggleIcon icon = Js.uncheckedCast(meta.icon); + if (!icon.isToggled()) { + icon.toggle(); + } } }); } @@ -355,8 +357,6 @@ private void showRow(TableRow row) { * Collapses a specific TableRow, hiding it, and optionally collapsing its child rows recursively. * * @param row The TableRow to collapse. - * @param recursive If true, child rows are collapsed recursively; otherwise, only the direct - * child rows are collapsed. */ private void collapse(TableRow row) { this.dataTable.fireTableEvent(new TreeRowOnBeforeCollapseEvent<>(row)); diff --git a/domino-ui/src/main/java/org/dominokit/domino/ui/dialogs/Window.java b/domino-ui/src/main/java/org/dominokit/domino/ui/dialogs/Window.java index 5a7d1db54..eb77a3117 100644 --- a/domino-ui/src/main/java/org/dominokit/domino/ui/dialogs/Window.java +++ b/domino-ui/src/main/java/org/dominokit/domino/ui/dialogs/Window.java @@ -24,6 +24,8 @@ import org.dominokit.domino.ui.icons.MdiIcon; import org.dominokit.domino.ui.icons.lib.Icons; import org.dominokit.domino.ui.layout.NavBar; +import org.dominokit.domino.ui.utils.ChildHandler; +import org.dominokit.domino.ui.utils.Domino; import org.dominokit.domino.ui.utils.PostfixAddOn; /** @@ -200,7 +202,7 @@ private void updatePosition() { if (windowTop < (windowHeight - initialHeight)) { modalElement.element().style.top = windowTop + "px"; } else { - modalElement.element().style.left = + modalElement.element().style.top = windowTop - ((windowLeft + initialHeight) - windowHeight - DomGlobal.window.pageYOffset) + "px"; @@ -255,8 +257,8 @@ private void addMoveListeners() { "mousedown", "touchstart"); - headerElement.element().addEventsListener(stopMoveListener, true, "mouseup", "touchend"); - headerElement.element().addEventsListener(moveListener, true, "mousemove", "touchmove"); + Domino.body().addEventsListener(stopMoveListener, true, "mouseup", "touchend"); + Domino.body().addEventsListener(moveListener, true, "mousemove", "touchmove"); body().addEventsListener(stopMoveListener, "mouseup", "touchend"); } @@ -458,4 +460,20 @@ public MdiIcon getMaximizeIcon() { public MdiIcon getCloseIcon() { return closeIcon; } + + /** @return the NavBar of this window */ + public NavBar getNavHeader() { + return navHeader; + } + + /** + * Allows customization of the window NavBar using a {@code ChildHandler}. + * + * @param handler The handler for customizing the NavBar. + * @return This Window instance for method chaining. + */ + public Window withNavBar(ChildHandler handler) { + handler.apply(this, navHeader); + return this; + } } 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 ac8a653ed..a1840fc04 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 @@ -15,7 +15,7 @@ */ package org.dominokit.domino.ui.dnd; -import static org.dominokit.domino.ui.utils.Domino.*; +import static java.util.Objects.nonNull; import static org.dominokit.domino.ui.utils.ElementsFactory.elements; import elemental2.dom.*; @@ -44,6 +44,7 @@ public class Draggable> { private final E element; private final EventListener eventListener; private final Consumer dragStartListener; + private DraggableConfig config = () -> true; /** * Creates a draggable instance for the specified element. @@ -119,11 +120,33 @@ public static > Draggable of( } private void onDragStart(Event evt, E draggable, String id) { - DragEvent e = (DragEvent) evt; - e.dataTransfer.setData("draggable_id", id); - e.dataTransfer.dropEffect = "move"; - draggable.element().classList.add(DragSource.DRAGGING); - dragStartListener.accept(draggable); + if (config.isEnabled()) { + DragEvent e = (DragEvent) evt; + e.dataTransfer.setData("draggable_id", id); + e.dataTransfer.dropEffect = "move"; + draggable.element().classList.add(DragSource.DRAGGING); + dragStartListener.accept(draggable); + } else { + evt.preventDefault(); + } + } + + /** @return Draggble item DraggableConfig */ + public DraggableConfig getConfig() { + return config; + } + + /** + * Sets the configuration for the draggble item, if null use a default config + * + * @param config DraggableConfig + */ + public void setConfig(DraggableConfig config) { + if (nonNull(config)) { + this.config = config; + } else { + this.config = () -> true; + } } /** Detaches the draggable feature from the element. */ @@ -140,4 +163,8 @@ public void detach() { public String getId() { return id; } + + public interface DraggableConfig { + boolean isEnabled(); + } } diff --git a/domino-ui/src/main/java/org/dominokit/domino/ui/forms/NumberBox.java b/domino-ui/src/main/java/org/dominokit/domino/ui/forms/NumberBox.java index 103b6f25e..75f486f31 100644 --- a/domino-ui/src/main/java/org/dominokit/domino/ui/forms/NumberBox.java +++ b/domino-ui/src/main/java/org/dominokit/domino/ui/forms/NumberBox.java @@ -26,6 +26,7 @@ import elemental2.dom.HTMLInputElement; import elemental2.dom.KeyboardEvent; import java.util.Objects; +import java.util.function.Function; import jsinterop.base.Js; import org.dominokit.domino.ui.elements.DivElement; import org.dominokit.domino.ui.events.EventType; @@ -59,7 +60,16 @@ public abstract class NumberBox, V extends Number> protected final LazyChild postfixElement; private final ChangeListener formatValueChangeListener = (oldValue, newValue) -> formatValue(newValue); - private java.util.function.Function valueParser = defaultValueParser(); + private Function valueParser = defaultValueParser(); + private final NumberFormatSupplier defaultFormatSupplier = + formatPattern -> { + if (nonNull(getPattern())) { + return NumberFormat.getFormat(getPattern()); + } else { + return NumberFormat.getDecimalFormat(); + } + }; + private NumberFormatSupplier numberFormatSupplier = defaultFormatSupplier; private String maxValueErrorMessage; private String minValueErrorMessage; @@ -541,11 +551,22 @@ private T setFormattingEnabled(boolean formattingEnabled) { * @return The NumberFormat instance corresponding to the current format. */ protected NumberFormat getNumberFormat() { - if (nonNull(getPattern())) { - return NumberFormat.getFormat(getPattern()); + return numberFormatSupplier.get(getPattern()); + } + + /** + * Sets a supplier to use to get a custom number format to be used by this NumberBox. if null is + * provided, then use default supplier. + * + * @return same component. + */ + public T setNumberFormat(NumberFormatSupplier numberFormatSupplier) { + if (nonNull(numberFormatSupplier)) { + this.numberFormatSupplier = numberFormatSupplier; } else { - return NumberFormat.getDecimalFormat(); + this.numberFormatSupplier = defaultFormatSupplier; } + return (T) this; } /** @@ -833,4 +854,9 @@ public T setName(String name) { getInputElement().element().name = name; return (T) this; } + + @FunctionalInterface + public interface NumberFormatSupplier { + NumberFormat get(String pattern); + } } diff --git a/domino-ui/src/main/java/org/dominokit/domino/ui/forms/Radio.java b/domino-ui/src/main/java/org/dominokit/domino/ui/forms/Radio.java index b18dfbcaf..beb23542f 100644 --- a/domino-ui/src/main/java/org/dominokit/domino/ui/forms/Radio.java +++ b/domino-ui/src/main/java/org/dominokit/domino/ui/forms/Radio.java @@ -100,6 +100,14 @@ public Radio(T value, String label) { radioElement.addEventListener("click", listener); inputElement.addEventListener( "change", + evt -> { + DomGlobal.console.info("CHANGEEEEEEEED.!"); + if (isEnabled() && !isReadOnly()) { + setChecked(isChecked(), isChangeListenersPaused()); + } + }); + inputElement.addEventListener( + "checked", evt -> { if (isEnabled() && !isReadOnly()) { setChecked(isChecked(), isChangeListenersPaused()); @@ -262,6 +270,7 @@ public Radio toggleChecked() { private Radio setChecked(boolean value, boolean silent) { boolean oldState = isChecked(); if (value == oldState) { + onChanged(silent); return this; } if (nonNull(radioGroup)) { @@ -286,6 +295,22 @@ private Radio setChecked(boolean value, boolean silent) { return this; } + private Radio onChanged(boolean silent) { + if (nonNull(radioGroup)) { + if (!(radioGroup.isReadOnly() || radioGroup.isDisabled())) { + if (!silent) { + triggerChangeListeners(!isChecked(), isChecked()); + } + radioGroup.onSelectionChanged((T) radioGroup.getValue(), this, silent); + } + } else { + if (!silent) { + triggerChangeListeners(!isChecked(), isChecked()); + } + } + return this; + } + /** * Checks if the radio button is currently checked. * diff --git a/domino-ui/src/main/java/org/dominokit/domino/ui/forms/suggest/AbstractSelect.java b/domino-ui/src/main/java/org/dominokit/domino/ui/forms/suggest/AbstractSelect.java index ae89b97c4..04d1b98f4 100644 --- a/domino-ui/src/main/java/org/dominokit/domino/ui/forms/suggest/AbstractSelect.java +++ b/domino-ui/src/main/java/org/dominokit/domino/ui/forms/suggest/AbstractSelect.java @@ -262,7 +262,15 @@ protected C clearValue(boolean silent) { true, field -> { List> selection = optionsMenu.getSelection(); - new ArrayList<>(selection).forEach(AbstractMenuItem::deselect); + new ArrayList<>(selection) + .forEach( + item -> { + item.deselect(silent); + if (silent) { + OptionMeta.get(item) + .ifPresent(meta -> onOptionDeselected((O) meta.getOption(), silent)); + } + }); }); if (!silent) { @@ -850,6 +858,12 @@ public Optional findOptionByKey(String key) { .findFirst(); } + private Optional> findMenuItemByKey(String key) { + return optionsMenu.getFlatMenuItems().stream() + .filter(menuItem -> Objects.equals(key, menuItem.getKey())) + .findFirst(); + } + /** * Searches for an option by its value within the select component. * @@ -864,6 +878,12 @@ public Optional findOptionByValue(T value) { .findFirst(); } + private Optional> findMenuItemByValue(T value) { + return optionsMenu.getFlatMenuItems().stream() + .filter(menuItem -> Objects.equals(value, menuItem.getValue())) + .findFirst(); + } + /** * Searches for an option by its index within the select component. * @@ -872,9 +892,12 @@ public Optional findOptionByValue(T value) { * found. */ public Optional findOptionByIndex(int index) { + return findMenuItemByIndex(index).map(item -> OptionMeta.get(item).get().getOption()); + } + + private Optional> findMenuItemByIndex(int index) { if (index < optionsMenu.getFlatMenuItems().size() && index >= 0) { - AbstractMenuItem menuItem = optionsMenu.getFlatMenuItems().get(index); - return Optional.ofNullable(OptionMeta.get(menuItem).get().getOption()); + return Optional.ofNullable(optionsMenu.getFlatMenuItems().get(index)); } return Optional.empty(); } @@ -993,7 +1016,7 @@ public C deselectAt(int index) { * @return an instance of the concrete class. */ public C deselectAt(int index, boolean silent) { - findOptionByIndex(index).ifPresent(o -> onOptionDeselected(o, silent)); + findMenuItemByIndex(index).ifPresent(item -> item.deselect(silent)); return (C) this; } @@ -1018,7 +1041,7 @@ public C deselectByKey(String key) { * @return an instance of the concrete class. */ public C deselectByKey(String key, boolean silent) { - findOptionByKey(key).ifPresent(o -> onOptionDeselected(o, silent)); + findMenuItemByKey(key).ifPresent(item -> item.deselect(silent)); return (C) this; } @@ -1042,7 +1065,7 @@ public C deselectByValue(T value) { * @return an instance of the concrete class. */ public C deselectByValue(T value, boolean silent) { - findOptionByValue(value).ifPresent(o -> onOptionDeselected(o, silent)); + findMenuItemByValue(value).ifPresent(item -> item.deselect(silent)); return (C) this; } diff --git a/domino-ui/src/main/java/org/dominokit/domino/ui/menu/AbstractMenuItem.java b/domino-ui/src/main/java/org/dominokit/domino/ui/menu/AbstractMenuItem.java index 9e1ce2aa8..2cc99b7b3 100644 --- a/domino-ui/src/main/java/org/dominokit/domino/ui/menu/AbstractMenuItem.java +++ b/domino-ui/src/main/java/org/dominokit/domino/ui/menu/AbstractMenuItem.java @@ -19,6 +19,7 @@ import static java.util.Objects.nonNull; import static org.dominokit.domino.ui.utils.Domino.*; +import elemental2.core.JsDate; import elemental2.dom.Element; import elemental2.dom.Event; import elemental2.dom.HTMLElement; @@ -100,17 +101,33 @@ public AbstractMenuItem() { indicatorIcon = createIndicator(Icons.menu_right()); init(this); + double[] startTime = new double[] {0}; this.addEventListener( EventType.touchstart.getName(), evt -> { - evt.stopPropagation(); - evt.preventDefault(); + startTime[0] = JsDate.now(); focus(); openSubMenu(); }); - this.addEventListener(EventType.touchend.getName(), this::onSelected); - this.addEventListener(EventType.click.getName(), this::onSelected); + this.addEventListener( + EventType.touchend.getName(), + evt -> { + evt.stopPropagation(); + double endTime = JsDate.now(); + double diff = endTime - startTime[0]; + if (diff < 200) { + evt.preventDefault(); + onSelected(evt); + } + }); + this.addEventListener( + EventType.click.getName(), + evt -> { + evt.stopPropagation(); + evt.preventDefault(); + onSelected(evt); + }); this.addEventListener(EventType.mouseenter.getName(), evt -> openSubMenu()); } @@ -148,8 +165,6 @@ public > T setSelectable(boolean selectable) { } private void onSelected(Event evt) { - evt.stopPropagation(); - evt.preventDefault(); if (parent.isMultiSelect() && isSelected()) { deselect(); } else { diff --git a/domino-ui/src/main/java/org/dominokit/domino/ui/menu/Menu.java b/domino-ui/src/main/java/org/dominokit/domino/ui/menu/Menu.java index 25cff8e98..1bb8ed0c7 100644 --- a/domino-ui/src/main/java/org/dominokit/domino/ui/menu/Menu.java +++ b/domino-ui/src/main/java/org/dominokit/domino/ui/menu/Menu.java @@ -402,6 +402,9 @@ public Menu() { 0); } }; + + this.addEventListener(EventType.touchstart.getName(), Event::stopPropagation); + this.addEventListener(EventType.touchend.getName(), Event::stopPropagation); } public void focusFirstMatch(String token) { diff --git a/domino-ui/src/main/java/org/dominokit/domino/ui/search/SearchBox.java b/domino-ui/src/main/java/org/dominokit/domino/ui/search/SearchBox.java index 5d3ccca96..04f2bc04b 100644 --- a/domino-ui/src/main/java/org/dominokit/domino/ui/search/SearchBox.java +++ b/domino-ui/src/main/java/org/dominokit/domino/ui/search/SearchBox.java @@ -33,6 +33,7 @@ import org.dominokit.domino.ui.icons.Icon; import org.dominokit.domino.ui.icons.lib.Icons; import org.dominokit.domino.ui.keyboard.KeyboardEventOptions; +import org.dominokit.domino.ui.menu.direction.DropDirection; import org.dominokit.domino.ui.utils.BaseDominoElement; import org.dominokit.domino.ui.utils.ChildHandler; import org.dominokit.domino.ui.utils.PostfixAddOn; @@ -103,12 +104,12 @@ public SearchBox() { autoSearchTimer.cancel(); doSearch(); }) - .setTooltip(getLabels().defaultQuickSearchPlaceHolder()); + .setTooltip(getLabels().defaultQuickSearchPlaceHolder(), DropDirection.BEST_FIT_SIDE); clearIcon = Icons.close() .clickable() - .setTooltip(getLabels().defaultQuickSearchClearToolTip()) + .setTooltip(getLabels().defaultQuickSearchClearToolTip(), DropDirection.BEST_FIT_SIDE) .addClickListener( evt -> { clearSearch(); diff --git a/domino-ui/src/main/resources/org/dominokit/domino/ui/public/css/domino-ui/dui-components/domino-ui-carousel.css b/domino-ui/src/main/resources/org/dominokit/domino/ui/public/css/domino-ui/dui-components/domino-ui-carousel.css index 94c597e9b..557d7c3f6 100644 --- a/domino-ui/src/main/resources/org/dominokit/domino/ui/public/css/domino-ui/dui-components/domino-ui-carousel.css +++ b/domino-ui/src/main/resources/org/dominokit/domino/ui/public/css/domino-ui/dui-components/domino-ui-carousel.css @@ -33,6 +33,9 @@ position: relative; width: 100%; overflow: hidden; + display: flex; + justify-content: center; + max-height: 100%; } .dui-carousel-inner>.dui-slide { @@ -99,6 +102,9 @@ position: absolute; top: 0; width: 100%; + height: 100%; + margin: auto; + object-fit: contain; } .dui-carousel-inner>.dui-slide-next { @@ -129,9 +135,11 @@ display: block; max-width: 100%; width: 100%; - height: auto; + height: 100%; vertical-align: middle; border: 0; + margin: auto; + object-fit: contain; } .dui-carousel-control { 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 78b038ff4..8e3882a58 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 @@ -216,6 +216,11 @@ fieldset.dui { --dui-form-field-input-whitespace:unset; } +.dui-form-text-area .dui-field-input[disabled], +.dui-form-text-area .dui-field-input[readonly] { + white-space: pre-wrap; +} + .dui-field-input:focus { outline: none; } diff --git a/domino-ui/src/main/resources/org/dominokit/domino/ui/public/css/domino-ui/dui-components/domino-ui-menu.css b/domino-ui/src/main/resources/org/dominokit/domino/ui/public/css/domino-ui/dui-components/domino-ui-menu.css index a0184db50..3e67dca78 100644 --- a/domino-ui/src/main/resources/org/dominokit/domino/ui/public/css/domino-ui/dui-components/domino-ui-menu.css +++ b/domino-ui/src/main/resources/org/dominokit/domino/ui/public/css/domino-ui/dui-components/domino-ui-menu.css @@ -79,6 +79,7 @@ .dui-menu-body { order: 40; flex-grow: 1; + border-radius: inherit; } .dui-menu-item { diff --git a/pom.xml b/pom.xml index 0e10ebc6f..a0bd89b7f 100644 --- a/pom.xml +++ b/pom.xml @@ -5,7 +5,7 @@ org.dominokit domino-ui-parent - 2.0.0 + 2.0.1 pom domino-ui-parent @@ -68,7 +68,7 @@ HEAD-SNAPSHOT - 2.0.0 + 2.0.1 11 11 @@ -84,7 +84,7 @@ UTF-8 UTF-8 1.2.1 - 2.10.0 + 2.11.0 1.0.4 1.0.2 1.0.0