import React from 'react'; import { ComponentStyles } from '../themes'; import { MaybeThunk, Thunk } from '../utils'; import { BlueBaseModuleRegistry, BlueBaseModuleRegistryInputItem, BlueBaseModuleRegistryItem } from './BlueBaseModuleRegistry'; import { ItemCollection } from './Registry'; /** * Definition of the HOC */ export type ComponentRegistryHocItem = (...args: any[]) => React.ComponentType; export type ComponentRegistryHocItemWithArgs = [Thunk, T]; interface ComponentRegistryItemExtras { /** Higher Order Components. BlueBase will wrap the component during resolution */ hocs: Array; /** Style rules for this component. May also be a thunk. */ styles: MaybeThunk; /** Is this component's code split? Mean's it's bundle will have to be split. */ isAsync: boolean; /** Should apply styles and theming to this component? true by default */ applyStyles: boolean; CachedComponent: React.ComponentType; } export type ComponentRegistryItem = BlueBaseModuleRegistryItem> & ComponentRegistryItemExtras; export type ComponentRegistryInputItem = BlueBaseModuleRegistryInputItem> & Partial; export type ComponentCollection = ItemCollection; /** * 🎁 ComponentRegistry */ export declare class ComponentRegistry extends BlueBaseModuleRegistry { /** * Resolves a Component. Wraps it in `hocs` and `styles`. Takes care of loading and error * states if required. * @param keys */ resolve(...keys: Array>): React.ComponentType; resolveFromCache(...keys: Array>): React.ComponentType; /** * Adds higher order component to the registered component * @param {string} key The name of the registered component to whom hocs are to added * @param {Array} hocs The HOCs to compose with the raw component. */ addHocs(key: string, ...hocs: Array): void; /** * Set styles of a component. * @param key * @param styles */ setStyles(key: string, styles: MaybeThunk): void; /** * Get styles of a component * @param key */ getStyles(key: string): MaybeThunk | undefined; /** * Find one item in a given sequence. Returns the first item found. * @param keys */ protected findOne(...keys: Array>): ComponentRegistryItem | undefined; /** * Convert any input value to an item. This is where you transform inputs and add defualts * @param key * @param partial */ protected createItem(key: string, partial: any): ComponentRegistryItem; /** * Typeguard to check a given object is an input value * @param value */ protected isInputValue(value: any): value is ComponentRegistryInputItem['value']; } export {};