@dndbuilder.com/react
Version:
Drag and drop builder for React
100 lines (99 loc) • 3.53 kB
TypeScript
import { BreakpointConfig, BuilderConfig } from './types';
import { BlockConfig } from './types/block';
/**
* BuilderRegistry class for managing block configurations
* Implemented as a singleton
*/
export declare class BuilderRegistry {
private static instance;
private constructor();
static getInstance(): BuilderRegistry;
private registeredBlocks;
private breakpoints;
private groupOrder;
/**
* Register multiple blocks at once
* @param blocks - Array of block configurations to register
*/
registerBlocks(blocks: BlockConfig[]): this;
/**
* Register a single block configuration
* @param block - Block configuration to register
* @throws Error if the block type is already registered
*/
registerBlock(block: BlockConfig): this;
getRegisteredBlocks(): Record<string, BlockConfig>;
/**
* Get all registered blocks
* @returns Object containing all registered blocks
*/
getBlocks(): BlockConfig[];
/**
* Get a block by its type
* @param type - The type of the block to retrieve
* @returns The block configuration if found, otherwise undefined
*/
getBlock(type: string): BlockConfig | undefined;
/**
* Get blocks by their group
* @param group - The group to filter blocks by
* @returns Array of blocks that belong to the specified group
*/
getBlocksByGroup(group: string): BlockConfig[];
/**
* Get all registered block types
* @returns Array of block type strings
*/
getBlockTypes(): string[];
/**
* Get all registered groups
* @returns Array of group configurations
*/
setGroupsOrder(groups: string[]): this;
/**
* Get the order of registered groups
* @returns Array of block groups in the order they were registered
*/
getGroupsOrder(): string[];
/**
* Get the order index of a specific group
* @param group - The group to find the order index for
* @returns The index of the group in the registered order, or -1 if not found
*/
getGroupOrder(group: string): number;
/**
* Get all registered breakpoints
* @returns Object containing all registered breakpoints
*/
registerBreakpoints(breakpoints: BreakpointConfig[]): this;
/**
* Register a single breakpoint configuration
* @param breakpoint - The breakpoint configuration to register
* @throws Error if the breakpoint key is already registered
*/
registerBreakpoint(breakpoint: BreakpointConfig): this;
/**
* Get a specific breakpoint by its key
* @param key - The key of the breakpoint to retrieve
* @returns The breakpoint configuration if found, otherwise undefined
*/
getBreakpoint(key: string): BreakpointConfig;
/**
* Get all registered breakpoints
* @returns Array of all registered breakpoint configurations
*/
getBreakpoints(): BreakpointConfig[];
/**
* Get a media query string for a specific breakpoint
* @param key - The key of the breakpoint to generate the media query for
* @returns Media query string for the specified breakpoint
*/
getMediaQuery(key: string): string;
/**
* Merge custom configuration with existing configuration
* @param config - Custom builder configuration to merge
* @returns The BuilderRegistry instance for method chaining
*/
mergeConfig(config: BuilderConfig): BuilderRegistry;
}
//# sourceMappingURL=registry.d.ts.map