UNPKG

@nex-ui/system

Version:

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

31 lines (27 loc) 1.1 kB
'use strict'; var utils = require('@nex-ui/utils'); var createRuntimeFn = require('./createRuntimeFn.cjs'); var utils$1 = require('../utils.cjs'); function defineSlotRecipe(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.__slotRecipe === true && extend.__config) { other = utils$1.mergeRecipeConfigs(extend.__config, other); } const { slots, ...o } = other; const runtimeFn = createRuntimeFn.createRuntimeFn({ mainStyles: slots, ...o }); runtimeFn.__slotRecipe = true; runtimeFn.__config = other; runtimeFn.variants = other.variants ? Object.keys(other.variants) : []; runtimeFn.slots = other.slots ? Object.keys(other.slots) : []; return runtimeFn; } exports.defineSlotRecipe = defineSlotRecipe;