UNPKG

@studiocms/ui

Version:

The UI library for StudioCMS. Includes the layouts & components we use to build StudioCMS.

135 lines (134 loc) 4.94 kB
import type { ExtendedIconifyIcon, IconifyDimenisons, IconifyIcon, IconifyJSON, IconifyOptional, IconifyTransformations } from '@iconify/types'; export type FullIconifyIcon = Required<IconifyIcon>; /** * SVG viewBox: x, y, width, height */ export type SVGViewBox = [x: number, y: number, width: number, height: number]; /** * Get viewBox from string */ export declare function getSVGViewBox(value: string): SVGViewBox | undefined; /** * Extract definitions from SVG * * Can be used with other tags, but name kept for backwards compatibility. * Should be used only with tags that cannot be nested, such as masks, clip paths, etc. */ interface SplitSVGDefsResult { defs: string; content: string; } export declare function splitSVGDefs(content: string, tag?: string): SplitSVGDefsResult; /** * Merge defs and content */ export declare function mergeDefsAndContent(defs: string, content: string): string; /** * Wrap SVG content, without wrapping definitions */ export declare function wrapSVGContent(body: string, start: string, end: string): string; export type PartialExtendedIconifyIcon = Partial<ExtendedIconifyIcon>; type IconifyIconExtraProps = Omit<ExtendedIconifyIcon, keyof IconifyIcon>; export type FullExtendedIconifyIcon = FullIconifyIcon & IconifyIconExtraProps; /** * Calculate second dimension when only 1 dimension is set */ export declare function calculateSize(size: string, ratio: number, precision?: number): string; export declare function calculateSize(size: number, ratio: number, precision?: number): number; export declare function calculateSize(size: string | number, ratio: number, precision?: number): string | number; /** * Default values for dimensions */ export declare const defaultIconDimensions: Required<IconifyDimenisons>; /** * Default values for transformations */ export declare const defaultIconTransformations: Required<IconifyTransformations>; /** * Default values for all optional IconifyIcon properties */ export declare const defaultIconProps: Required<IconifyOptional>; /** * Default values for all properties used in ExtendedIconifyIcon */ export declare const defaultExtendedIconProps: Required<FullExtendedIconifyIcon>; /** * Merge transformations */ export declare function mergeIconTransformations<T extends IconifyTransformations>(obj1: T, obj2: IconifyTransformations): T; /** * Icon size */ export type IconifyIconSize = null | string | number; /** * Dimensions */ export interface IconifyIconSizeCustomisations { width?: IconifyIconSize; height?: IconifyIconSize; } /** * Icon customisations */ export interface IconifyIconCustomisations extends IconifyTransformations, IconifyIconSizeCustomisations { } export type FullIconCustomisations = Required<IconifyIconCustomisations>; /** * Default icon customisations values */ export declare const defaultIconSizeCustomisations: Required<IconifyIconSizeCustomisations>; export declare const defaultIconCustomisations: FullIconCustomisations; /** * Merge icon and alias * * Can also be used to merge default values and icon */ export declare function mergeIconData<T extends PartialExtendedIconifyIcon>(parent: T, child: PartialExtendedIconifyIcon): T; export type ParentIconsList = string[]; export type ParentIconsTree = Record<string, ParentIconsList | null>; /** * Resolve icon set icons * * Returns parent icon for each icon */ export declare function getIconsTree(data: IconifyJSON, names?: string[]): ParentIconsTree; /** * Get icon data, using prepared aliases tree */ export declare function internalGetIconData(data: IconifyJSON, name: string, tree: string[]): ExtendedIconifyIcon; /** * Get data for icon */ export declare function getIconData(data: IconifyJSON, name: string): ExtendedIconifyIcon | null; /** * Interface for getSVGData() result */ export interface IconifyIconBuildResult { attributes: { width?: string; height?: string; viewBox: string; }; viewBox: SVGViewBox; body: string; } /** * Check if value should be unset. Allows multiple keywords */ export declare const isUnsetKeyword: (value: unknown) => value is "undefined" | "none" | "unset"; /** * Replace IDs in SVG output with unique IDs */ export declare function replaceIDs(body: string, prefix?: string | ((id: string) => string)): string; /** * Get SVG attributes and content from icon + customisations * * Does not generate style to make it compatible with frameworks that use objects for style, such as React. * Instead, it generates 'inline' value. If true, rendering engine should add verticalAlign: -0.125em to icon. * * Customisations should be normalised by platform specific parser. * Result should be converted to <svg> by platform specific parser. * Use replaceIDs to generate unique IDs for body. */ export declare function iconToSVG(icon: IconifyIcon, customisations?: IconifyIconCustomisations): IconifyIconBuildResult; export {};