/*! * SAPUI5 * Copyright (c) 2025 SAP SE or an SAP affiliate company. All rights reserved. */ /** * When the basket panel width (in percent of the total layout width) exceeds this threshold, * the basket is considered the dominant UI element. Non-basket search bar controls (search input, * filter button, sort, view switch, etc.) are then disabled to reflect that the user's focus * is on the basket rather than on searching or filtering. * * **Custom toolbar buttons**: If a custom toolbar button returned by `config.getCustomToolbar()` * does not already have an `enabled` binding, one is added automatically. However, if the button * already has an existing `enabled` binding (e.g. to reflect its own business logic), that binding * is preserved and the basket-dominance logic is NOT applied. In that case the custom toolbar * developer is responsible for incorporating the deactivation check into their own binding, e.g.: * * ```typescript * myButton.bindProperty("enabled", { * parts: [{ path: "/myCondition" }, { path: "/searchDeactivated" }], * formatter: (myCondition: boolean, searchDeactivated: boolean): boolean => * myCondition && !searchDeactivated, * }); * ``` */ export const BASKET_PANEL_DOMINANCE_THRESHOLD_PERCENT = 50; export function registerHandler( key: string, elements: Array, event: string, handler: EventListener ): Array { for (let i = 0; i < elements.length; ++i) { const element = elements[i]; if (element["es_" + key]) { continue; } element.addEventListener(event, handler); element["es_" + key] = true; } return elements; }