UNPKG

tw-merge

Version:

Merge CSS utility classes without style conflicts - small and zero config

40 lines (39 loc) 2 kB
export type Handler<T = any> = (memory: T, matches: NonNullable<RegExpMatchArray["groups"]>) => boolean | "c"; export type Rule = [string, Handler]; export type RuleSet = Rule[]; export declare const TRAILING_SLASH_REGEXP = "(\\/\\d+)?"; export declare const VALUE_REGEXP: string; export type SimpleHandlerOptions = { byType?: boolean; }; export declare function createSimpleHandler({ byType }?: SimpleHandlerOptions): Handler<Record<string, Partial<Record<"number" | "other", boolean>>>>; export type SimpleRuleOptions = SimpleHandlerOptions; export declare function simpleRule(target: string, { byType }?: SimpleRuleOptions): Rule; export type CardinalHandlerOptions = { byType?: boolean; }; export declare function createCardinalHandler({ byType }?: CardinalHandlerOptions): Handler<Partial<Record<string, Partial<Record<"number" | "other", boolean>>>> & { _?: Partial<Record<"number" | "other", Set<string>>> | undefined; }>; export type CardinalRuleOptions = { /** * Whether the direction is dash-separated (e.g. `border-t-2`) * @default true */ dash?: boolean; } & CardinalHandlerOptions; export declare function cardinalRule(target: string, { dash, byType }?: CardinalRuleOptions): Rule; export declare function cardinalRules(targets: string, options?: CardinalRuleOptions): Rule[]; export declare function createUniqueHandler(): Handler<Record<string, boolean>>; export type UniqueRuleOptions = { prefix?: string; def?: boolean; }; export declare function uniqueRule(targets: (string | string[])[]): Rule; export declare function createArbitraryHandler(): Handler<Record<string, { done?: boolean | undefined; }>>; export declare function arbitraryRule(): Rule; export type ConflictRuleTargets = Record<string, string>; export declare function createConflictHandler(targets: ConflictRuleTargets): Handler<Record<string, boolean>>; export declare function conflictRule(targets: ConflictRuleTargets): Rule;