(args: {
storedValue: string | null;
defaultWidth: number;
minWidth: number;
maxWidth: number;
})
| 57 | } |
| 58 | |
| 59 | export function resolveInitialResizableSidebarWidth(args: { |
| 60 | storedValue: string | null; |
| 61 | defaultWidth: number; |
| 62 | minWidth: number; |
| 63 | maxWidth: number; |
| 64 | }): number { |
| 65 | const effectiveMaxWidth = Math.max(args.minWidth, args.maxWidth); |
| 66 | const fallbackWidth = Math.max(args.minWidth, Math.min(effectiveMaxWidth, args.defaultWidth)); |
| 67 | |
| 68 | if (!args.storedValue) { |
| 69 | return fallbackWidth; |
| 70 | } |
| 71 | |
| 72 | const parsedWidth = Number.parseInt(args.storedValue, 10); |
| 73 | if (!Number.isFinite(parsedWidth)) { |
| 74 | return fallbackWidth; |
| 75 | } |
| 76 | |
| 77 | return Math.max(args.minWidth, Math.min(effectiveMaxWidth, parsedWidth)); |
| 78 | } |
| 79 | |
| 80 | export function useResizableSidebar({ |
| 81 | enabled, |
no outgoing calls
no test coverage detected