mirror of
https://github.com/mauriceboe/TREK.git
synced 2026-12-02 17:26:24 +00:00
fix(deps): keep Lucide SVG markup and Undici tests compatible
Build standalone SVG icons without a React context. Use accessible actions in tests and give the mocked dispatchers the interface the adapter expects.
This commit is contained in:
@@ -1,19 +1,6 @@
|
||||
import type { CSSProperties } from 'react'
|
||||
import * as LucideIcons from 'lucide-react'
|
||||
import { Blocks, type LucideIcon } from 'lucide-react'
|
||||
import { legacyLucideIcons } from './legacyLucideIcons'
|
||||
|
||||
// Lucide names are PascalCase. Restricting the lookup to that shape keeps a manifest
|
||||
// from reaching lucide's non-icon exports (`createLucideIcon`, `icons`, `default`,
|
||||
// `module.exports`), which are all lowercase-initial.
|
||||
const LUCIDE_ICON_NAME = /^[A-Z][A-Za-z0-9]*$/
|
||||
|
||||
export function findLucideIcon(name: string | null | undefined): LucideIcon | undefined {
|
||||
if (!name || !LUCIDE_ICON_NAME.test(name) || name === 'Icon') return undefined
|
||||
const icon = (LucideIcons as unknown as Record<string, LucideIcon | undefined>)[name]
|
||||
if (typeof icon === 'object') return icon
|
||||
return legacyLucideIcons.get(name.replace(/^Lucide/, '').replace(/Icon$/, ''))
|
||||
}
|
||||
import { lucideIconByName } from './lucideIconLookup'
|
||||
|
||||
/**
|
||||
* Resolves a plugin manifest's `icon` (a lucide icon name, e.g. "Stethoscope") to the
|
||||
@@ -25,7 +12,7 @@ export function findLucideIcon(name: string | null | undefined): LucideIcon | un
|
||||
* building nav/tab arrays.
|
||||
*/
|
||||
export function resolvePluginIcon(name: string | null | undefined): LucideIcon {
|
||||
return findLucideIcon(name) ?? Blocks
|
||||
return lucideIconByName[name ?? ''] ?? Blocks
|
||||
}
|
||||
|
||||
/** Renders the lucide icon a plugin declares in its manifest (Blocks if unknown). */
|
||||
|
||||
Reference in New Issue
Block a user