UNPKG

@nex-ui/system

Version:

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

30 lines (26 loc) 1.01 kB
'use strict'; var utils = require('@nex-ui/utils'); var createRuntimeFn = require('./createRuntimeFn.cjs'); var utils$1 = require('../utils.cjs'); function defineRecipe(config) { if (utils.__DEV__) { if (config.compoundVariants && !Array.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 = utils$1.mergeRecipeConfigs(extend.__config, other); } const { base, ...o } = other; const runtimeFn = createRuntimeFn.createRuntimeFn({ mainStyles: base, ...o }); runtimeFn.__recipe = true; runtimeFn.__config = other; runtimeFn.variants = other.variants ? Object.keys(other.variants) : []; return runtimeFn; } exports.defineRecipe = defineRecipe;