UNPKG

@nex-ui/system

Version:

A lightweight and performant styling library based on Emotion, focusing on component architecture and developer experience.

28 lines (25 loc) 972 B
import { __DEV__, isArray } from '@nex-ui/utils'; import { createRuntimeFn } from './createRuntimeFn.mjs'; import { mergeRecipeConfigs } from '../utils.mjs'; function defineRecipe(config) { if (__DEV__) { if (config.compoundVariants && !isArray(config.compoundVariants)) { throw new TypeError(`[Nex UI] system: The "compoundVariants" prop must be an array. Received: ${typeof config.compoundVariants}`); } } // eslint-disable-next-line prefer-const let { extend, ...other } = config; if (extend && extend?.__recipe === true && extend?.__config) { other = mergeRecipeConfigs(extend.__config, other); } const { base, ...o } = other; const runtimeFn = createRuntimeFn({ mainStyles: base, ...o }); runtimeFn.__recipe = true; runtimeFn.__config = other; runtimeFn.variants = other.variants ? Object.keys(other.variants) : []; return runtimeFn; } export { defineRecipe };