UNPKG

@helpwave/hightide

Version:

helpwave's component and theming library

1 lines 820 B
{"version":3,"sources":["../../src/util/PropsWithFunctionChildren.ts"],"sourcesContent":["import type { ReactNode } from 'react'\n\nexport type BagFunction<T> = (bag: T) => ReactNode\n\nexport type PropsWithBagFunction<T, P = unknown> = P & { children?: BagFunction<T> }\n\nexport type PropsWithBagFunctionOrChildren<T, P = unknown> = P & { children?: BagFunction<T> | ReactNode }\n\nconst resolve = <T>(children: BagFunction<T> | ReactNode, bag: T): ReactNode => {\n if (typeof children === 'function') {\n return (children as BagFunction<T>)(bag)\n }\n\n return children ?? undefined\n}\n\nexport const BagFunctionUtil = {\n resolve\n}"],"mappings":";AAQA,IAAM,UAAU,CAAI,UAAsC,QAAsB;AAC9E,MAAI,OAAO,aAAa,YAAY;AAClC,WAAQ,SAA4B,GAAG;AAAA,EACzC;AAEA,SAAO,YAAY;AACrB;AAEO,IAAM,kBAAkB;AAAA,EAC7B;AACF;","names":[]}