svelte-ux
Version:
A large collection of Svelte components, actions, stores and utils to simplify creating highly interactive and visual applications. Built using Tailwind with extensibility and customization in mind.
10 lines (9 loc) • 431 B
JavaScript
import { isLiteralObject } from '@layerstack/utils/object';
export function asIconData(v) {
return isIconComponentProps(v) ? v.data : v;
}
function isIconComponentProps(v) {
// `iconName` is a required property of `IconDefinition`, the only other object that `IconInput` supports.
// If it is undefined, then only ComponentProps<Icon> is viable.
return isLiteralObject(v) && typeof v['iconName'] === 'undefined';
}