refactor
This commit is contained in:
@@ -17,7 +17,7 @@ const normalizeEntries = (entries) =>
|
||||
}
|
||||
const id = entry.id ?? entry.value ?? index;
|
||||
const label = entry.label ?? entry.name ?? entry.title ?? '';
|
||||
const onClick = typeof entry.onClick === 'function' ? entry.onClick : null;
|
||||
const onClick = entry.onClick ? entry.onClick : null;
|
||||
return label ? { id, label, onClick, raw: entry } : null;
|
||||
})
|
||||
.filter(Boolean);
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import { useCallback, useEffect, useMemo, useRef, useState } from 'react';
|
||||
import type { CSSProperties, ReactNode, FormEvent, MutableRefObject } from 'react';
|
||||
import { PlusIcon } from './icons';
|
||||
import { isPlainObject } from '../utils/typeGuards';
|
||||
import useFloatingMenu from './useFloatingMenu';
|
||||
|
||||
type QuickAddOption = string | number | { id?: string | number; label?: string; name?: string; [key: string]: unknown };
|
||||
@@ -16,7 +17,7 @@ const normalizeOption = (option: QuickAddOption | null | undefined, index: numbe
|
||||
if (option == null) {
|
||||
return null;
|
||||
}
|
||||
if (typeof option === 'object') {
|
||||
if (isPlainObject(option)) {
|
||||
const label = option.label ?? option.name;
|
||||
if (label == null) {
|
||||
return null;
|
||||
|
||||
@@ -87,7 +87,7 @@ export const EditIcon: TablerIconComponent = ({ className, size = '1em', stroke
|
||||
);
|
||||
|
||||
export const FolderIcon: TablerIconComponent = ({ className, size = 16, title, ...rest }) => {
|
||||
const dimensionProps = typeof size === 'number' ? { width: size, height: size } : {};
|
||||
const dimensionProps = Number.isFinite(size) ? { width: Number(size), height: Number(size) } : {};
|
||||
|
||||
return (
|
||||
<FolderSvg
|
||||
|
||||
Reference in New Issue
Block a user