4b3a46d953
- Removes the intermediate `CommandMenuItemConfig` / `CommandConfigContext` / `CommandMenuItemDisplay` abstraction layers, replacing them with a single `CommandMenuItemRenderer` that renders directly from the command menu items from the backend - Eliminates the server-items/ subdirectory by moving its contents (hooks/, contexts/, states/, display/, edit/) up into the parent command-menu-item/ module, removing an unnecessary nesting level.
25 lines
613 B
TypeScript
25 lines
613 B
TypeScript
import { isDefined } from 'twenty-shared/utils';
|
|
|
|
export const computeInsertPositionFromBounds = (
|
|
previousPosition: number | undefined,
|
|
nextPosition: number | undefined,
|
|
): number => {
|
|
if (!isDefined(previousPosition) && isDefined(nextPosition)) {
|
|
return nextPosition - 1;
|
|
}
|
|
|
|
if (isDefined(previousPosition) && !isDefined(nextPosition)) {
|
|
return previousPosition + 1;
|
|
}
|
|
|
|
if (isDefined(previousPosition) && isDefined(nextPosition)) {
|
|
if (previousPosition === nextPosition) {
|
|
return previousPosition - 1;
|
|
}
|
|
|
|
return (previousPosition + nextPosition) / 2;
|
|
}
|
|
|
|
return 0;
|
|
};
|