@vanilla-extract/recipes
Advanced tools
Comparing version 0.0.0-inline-prototype-202342012537 to 0.0.0-namespace-theme-tokens-20240321223951
import { ComplexStyleRule } from '@vanilla-extract/css'; | ||
type Resolve<T> = { | ||
[Key in keyof T]: T[Key]; | ||
} & {}; | ||
type RecipeStyleRule = ComplexStyleRule | string; | ||
@@ -10,14 +13,20 @@ type VariantDefinitions = Record<string, RecipeStyleRule>; | ||
}; | ||
type VariantsClassNames<Variants extends VariantGroups> = { | ||
[P in keyof Variants]: { | ||
[PP in keyof Variants[P]]: string; | ||
}; | ||
}; | ||
type PatternResult<Variants extends VariantGroups> = { | ||
defaultClassName: string; | ||
variantClassNames: { | ||
[P in keyof Variants]: { | ||
[P in keyof Variants[keyof Variants]]: string; | ||
}; | ||
}; | ||
variantClassNames: VariantsClassNames<Variants>; | ||
defaultVariants: VariantSelection<Variants>; | ||
compoundVariants: Array<[VariantSelection<Variants>, string]>; | ||
}; | ||
type RuntimeFn<Variants extends VariantGroups> = ((options?: VariantSelection<Variants>) => string) & { | ||
type RecipeClassNames<Variants extends VariantGroups> = { | ||
base: string; | ||
variants: VariantsClassNames<Variants>; | ||
}; | ||
type RuntimeFn<Variants extends VariantGroups> = ((options?: Resolve<VariantSelection<Variants>>) => string) & { | ||
variants: () => (keyof Variants)[]; | ||
classNames: RecipeClassNames<Variants>; | ||
}; | ||
@@ -24,0 +33,0 @@ |
@@ -5,96 +5,6 @@ 'use strict'; | ||
function _toPrimitive(input, hint) { | ||
if (typeof input !== "object" || input === null) return input; | ||
var prim = input[Symbol.toPrimitive]; | ||
if (prim !== undefined) { | ||
var res = prim.call(input, hint || "default"); | ||
if (typeof res !== "object") return res; | ||
throw new TypeError("@@toPrimitive must return a primitive value."); | ||
} | ||
return (hint === "string" ? String : Number)(input); | ||
} | ||
var createRuntimeFn_dist_vanillaExtractRecipesCreateRuntimeFn = require('../../dist/createRuntimeFn-2f250aaf.cjs.dev.js'); | ||
function _toPropertyKey(arg) { | ||
var key = _toPrimitive(arg, "string"); | ||
return typeof key === "symbol" ? key : String(key); | ||
} | ||
function _defineProperty(obj, key, value) { | ||
key = _toPropertyKey(key); | ||
if (key in obj) { | ||
Object.defineProperty(obj, key, { | ||
value: value, | ||
enumerable: true, | ||
configurable: true, | ||
writable: true | ||
}); | ||
} else { | ||
obj[key] = value; | ||
} | ||
return obj; | ||
} | ||
function ownKeys(object, enumerableOnly) { | ||
var keys = Object.keys(object); | ||
if (Object.getOwnPropertySymbols) { | ||
var symbols = Object.getOwnPropertySymbols(object); | ||
enumerableOnly && (symbols = symbols.filter(function (sym) { | ||
return Object.getOwnPropertyDescriptor(object, sym).enumerable; | ||
})), keys.push.apply(keys, symbols); | ||
} | ||
return keys; | ||
} | ||
function _objectSpread2(target) { | ||
for (var i = 1; i < arguments.length; i++) { | ||
var source = null != arguments[i] ? arguments[i] : {}; | ||
i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { | ||
_defineProperty(target, key, source[key]); | ||
}) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { | ||
Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); | ||
}); | ||
} | ||
return target; | ||
} | ||
var shouldApplyCompound = (compoundCheck, selections, defaultVariants) => { | ||
for (var key of Object.keys(compoundCheck)) { | ||
var _selections$key; | ||
if (compoundCheck[key] !== ((_selections$key = selections[key]) !== null && _selections$key !== void 0 ? _selections$key : defaultVariants[key])) { | ||
return false; | ||
} | ||
} | ||
return true; | ||
}; | ||
var createRuntimeFn = config => { | ||
var runtimeFn = options => { | ||
var className = config.defaultClassName; | ||
var selections = _objectSpread2(_objectSpread2({}, config.defaultVariants), options); | ||
for (var variantName in selections) { | ||
var _selections$variantNa; | ||
var variantSelection = (_selections$variantNa = selections[variantName]) !== null && _selections$variantNa !== void 0 ? _selections$variantNa : config.defaultVariants[variantName]; | ||
if (variantSelection != null) { | ||
var selection = variantSelection; | ||
if (typeof selection === 'boolean') { | ||
// @ts-expect-error | ||
selection = selection === true ? 'true' : 'false'; | ||
} | ||
var selectionClassName = | ||
// @ts-expect-error | ||
config.variantClassNames[variantName][selection]; | ||
if (selectionClassName) { | ||
className += ' ' + selectionClassName; | ||
} | ||
} | ||
} | ||
for (var [compoundCheck, compoundClassName] of config.compoundVariants) { | ||
if (shouldApplyCompound(compoundCheck, selections, config.defaultVariants)) { | ||
className += ' ' + compoundClassName; | ||
} | ||
} | ||
return className; | ||
}; | ||
runtimeFn.variants = () => Object.keys(config.variantClassNames); | ||
return runtimeFn; | ||
}; | ||
exports.createRuntimeFn = createRuntimeFn; | ||
exports.createRuntimeFn = createRuntimeFn_dist_vanillaExtractRecipesCreateRuntimeFn.createRuntimeFn; |
@@ -5,96 +5,6 @@ 'use strict'; | ||
function _toPrimitive(input, hint) { | ||
if (typeof input !== "object" || input === null) return input; | ||
var prim = input[Symbol.toPrimitive]; | ||
if (prim !== undefined) { | ||
var res = prim.call(input, hint || "default"); | ||
if (typeof res !== "object") return res; | ||
throw new TypeError("@@toPrimitive must return a primitive value."); | ||
} | ||
return (hint === "string" ? String : Number)(input); | ||
} | ||
var createRuntimeFn_dist_vanillaExtractRecipesCreateRuntimeFn = require('../../dist/createRuntimeFn-166334d7.cjs.prod.js'); | ||
function _toPropertyKey(arg) { | ||
var key = _toPrimitive(arg, "string"); | ||
return typeof key === "symbol" ? key : String(key); | ||
} | ||
function _defineProperty(obj, key, value) { | ||
key = _toPropertyKey(key); | ||
if (key in obj) { | ||
Object.defineProperty(obj, key, { | ||
value: value, | ||
enumerable: true, | ||
configurable: true, | ||
writable: true | ||
}); | ||
} else { | ||
obj[key] = value; | ||
} | ||
return obj; | ||
} | ||
function ownKeys(object, enumerableOnly) { | ||
var keys = Object.keys(object); | ||
if (Object.getOwnPropertySymbols) { | ||
var symbols = Object.getOwnPropertySymbols(object); | ||
enumerableOnly && (symbols = symbols.filter(function (sym) { | ||
return Object.getOwnPropertyDescriptor(object, sym).enumerable; | ||
})), keys.push.apply(keys, symbols); | ||
} | ||
return keys; | ||
} | ||
function _objectSpread2(target) { | ||
for (var i = 1; i < arguments.length; i++) { | ||
var source = null != arguments[i] ? arguments[i] : {}; | ||
i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { | ||
_defineProperty(target, key, source[key]); | ||
}) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { | ||
Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); | ||
}); | ||
} | ||
return target; | ||
} | ||
var shouldApplyCompound = (compoundCheck, selections, defaultVariants) => { | ||
for (var key of Object.keys(compoundCheck)) { | ||
var _selections$key; | ||
if (compoundCheck[key] !== ((_selections$key = selections[key]) !== null && _selections$key !== void 0 ? _selections$key : defaultVariants[key])) { | ||
return false; | ||
} | ||
} | ||
return true; | ||
}; | ||
var createRuntimeFn = config => { | ||
var runtimeFn = options => { | ||
var className = config.defaultClassName; | ||
var selections = _objectSpread2(_objectSpread2({}, config.defaultVariants), options); | ||
for (var variantName in selections) { | ||
var _selections$variantNa; | ||
var variantSelection = (_selections$variantNa = selections[variantName]) !== null && _selections$variantNa !== void 0 ? _selections$variantNa : config.defaultVariants[variantName]; | ||
if (variantSelection != null) { | ||
var selection = variantSelection; | ||
if (typeof selection === 'boolean') { | ||
// @ts-expect-error | ||
selection = selection === true ? 'true' : 'false'; | ||
} | ||
var selectionClassName = | ||
// @ts-expect-error | ||
config.variantClassNames[variantName][selection]; | ||
if (selectionClassName) { | ||
className += ' ' + selectionClassName; | ||
} | ||
} | ||
} | ||
for (var [compoundCheck, compoundClassName] of config.compoundVariants) { | ||
if (shouldApplyCompound(compoundCheck, selections, config.defaultVariants)) { | ||
className += ' ' + compoundClassName; | ||
} | ||
} | ||
return className; | ||
}; | ||
runtimeFn.variants = () => Object.keys(config.variantClassNames); | ||
return runtimeFn; | ||
}; | ||
exports.createRuntimeFn = createRuntimeFn; | ||
exports.createRuntimeFn = createRuntimeFn_dist_vanillaExtractRecipesCreateRuntimeFn.createRuntimeFn; |
@@ -1,95 +0,1 @@ | ||
function _toPrimitive(input, hint) { | ||
if (typeof input !== "object" || input === null) return input; | ||
var prim = input[Symbol.toPrimitive]; | ||
if (prim !== undefined) { | ||
var res = prim.call(input, hint || "default"); | ||
if (typeof res !== "object") return res; | ||
throw new TypeError("@@toPrimitive must return a primitive value."); | ||
} | ||
return (hint === "string" ? String : Number)(input); | ||
} | ||
function _toPropertyKey(arg) { | ||
var key = _toPrimitive(arg, "string"); | ||
return typeof key === "symbol" ? key : String(key); | ||
} | ||
function _defineProperty(obj, key, value) { | ||
key = _toPropertyKey(key); | ||
if (key in obj) { | ||
Object.defineProperty(obj, key, { | ||
value: value, | ||
enumerable: true, | ||
configurable: true, | ||
writable: true | ||
}); | ||
} else { | ||
obj[key] = value; | ||
} | ||
return obj; | ||
} | ||
function ownKeys(object, enumerableOnly) { | ||
var keys = Object.keys(object); | ||
if (Object.getOwnPropertySymbols) { | ||
var symbols = Object.getOwnPropertySymbols(object); | ||
enumerableOnly && (symbols = symbols.filter(function (sym) { | ||
return Object.getOwnPropertyDescriptor(object, sym).enumerable; | ||
})), keys.push.apply(keys, symbols); | ||
} | ||
return keys; | ||
} | ||
function _objectSpread2(target) { | ||
for (var i = 1; i < arguments.length; i++) { | ||
var source = null != arguments[i] ? arguments[i] : {}; | ||
i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { | ||
_defineProperty(target, key, source[key]); | ||
}) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { | ||
Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); | ||
}); | ||
} | ||
return target; | ||
} | ||
var shouldApplyCompound = (compoundCheck, selections, defaultVariants) => { | ||
for (var key of Object.keys(compoundCheck)) { | ||
var _selections$key; | ||
if (compoundCheck[key] !== ((_selections$key = selections[key]) !== null && _selections$key !== void 0 ? _selections$key : defaultVariants[key])) { | ||
return false; | ||
} | ||
} | ||
return true; | ||
}; | ||
var createRuntimeFn = config => { | ||
var runtimeFn = options => { | ||
var className = config.defaultClassName; | ||
var selections = _objectSpread2(_objectSpread2({}, config.defaultVariants), options); | ||
for (var variantName in selections) { | ||
var _selections$variantNa; | ||
var variantSelection = (_selections$variantNa = selections[variantName]) !== null && _selections$variantNa !== void 0 ? _selections$variantNa : config.defaultVariants[variantName]; | ||
if (variantSelection != null) { | ||
var selection = variantSelection; | ||
if (typeof selection === 'boolean') { | ||
// @ts-expect-error | ||
selection = selection === true ? 'true' : 'false'; | ||
} | ||
var selectionClassName = | ||
// @ts-expect-error | ||
config.variantClassNames[variantName][selection]; | ||
if (selectionClassName) { | ||
className += ' ' + selectionClassName; | ||
} | ||
} | ||
} | ||
for (var [compoundCheck, compoundClassName] of config.compoundVariants) { | ||
if (shouldApplyCompound(compoundCheck, selections, config.defaultVariants)) { | ||
className += ' ' + compoundClassName; | ||
} | ||
} | ||
return className; | ||
}; | ||
runtimeFn.variants = () => Object.keys(config.variantClassNames); | ||
return runtimeFn; | ||
}; | ||
export { createRuntimeFn }; | ||
export { c as createRuntimeFn } from '../../dist/createRuntimeFn-62c9670f.esm.js'; |
import { ComplexStyleRule } from '@vanilla-extract/css'; | ||
type Resolve<T> = { | ||
[Key in keyof T]: T[Key]; | ||
} & {}; | ||
type RecipeStyleRule = ComplexStyleRule | string; | ||
@@ -10,2 +13,7 @@ type VariantDefinitions = Record<string, RecipeStyleRule>; | ||
}; | ||
type VariantsClassNames<Variants extends VariantGroups> = { | ||
[P in keyof Variants]: { | ||
[PP in keyof Variants[P]]: string; | ||
}; | ||
}; | ||
interface CompoundVariant<Variants extends VariantGroups> { | ||
@@ -21,10 +29,14 @@ variants: VariantSelection<Variants>; | ||
}; | ||
type RuntimeFn<Variants extends VariantGroups> = ((options?: VariantSelection<Variants>) => string) & { | ||
type RecipeClassNames<Variants extends VariantGroups> = { | ||
base: string; | ||
variants: VariantsClassNames<Variants>; | ||
}; | ||
type RuntimeFn<Variants extends VariantGroups> = ((options?: Resolve<VariantSelection<Variants>>) => string) & { | ||
variants: () => (keyof Variants)[]; | ||
classNames: RecipeClassNames<Variants>; | ||
}; | ||
type RecipeVariants<RecipeFn extends RuntimeFn<VariantGroups>> = Parameters<RecipeFn>[0]; | ||
type RecipeVariants<RecipeFn extends RuntimeFn<VariantGroups>> = Resolve<Parameters<RecipeFn>[0]>; | ||
declare function recipe<Variants extends VariantGroups>(options: PatternOptions<Variants>, debugId?: string): RuntimeFn<Variants>; | ||
declare const recipe$: typeof recipe; | ||
export { RecipeVariants, RuntimeFn, recipe, recipe$ }; | ||
export { RecipeVariants, RuntimeFn, recipe }; |
@@ -7,11 +7,4 @@ 'use strict'; | ||
var css = require('@vanilla-extract/css'); | ||
var createRuntimeFn_dist_vanillaExtractRecipesCreateRuntimeFn = require('../createRuntimeFn/dist/vanilla-extract-recipes-createRuntimeFn.cjs.dev.js'); | ||
var createRuntimeFn_dist_vanillaExtractRecipesCreateRuntimeFn = require('./createRuntimeFn-2f250aaf.cjs.dev.js'); | ||
function mapValues(input, fn) { | ||
var result = {}; | ||
for (var _key in input) { | ||
result[_key] = fn(input[_key], _key); | ||
} | ||
return result; | ||
} | ||
function recipe(options, debugId) { | ||
@@ -22,8 +15,14 @@ var { | ||
compoundVariants = [], | ||
base = '' | ||
base | ||
} = options; | ||
var defaultClassName = typeof base === 'string' ? base : css.style(base, debugId); | ||
var defaultClassName; | ||
if (!base || typeof base === 'string') { | ||
var baseClassName = css.style({}); | ||
defaultClassName = base ? "".concat(baseClassName, " ").concat(base) : baseClassName; | ||
} else { | ||
defaultClassName = css.style(base, debugId); | ||
} | ||
// @ts-expect-error | ||
var variantClassNames = mapValues(variants, (variantGroup, variantGroupName) => css.styleVariants(variantGroup, styleRule => typeof styleRule === 'string' ? [styleRule] : styleRule, debugId ? "".concat(debugId, "_").concat(variantGroupName) : variantGroupName)); | ||
var variantClassNames = createRuntimeFn_dist_vanillaExtractRecipesCreateRuntimeFn.mapValues(variants, (variantGroup, variantGroupName) => css.styleVariants(variantGroup, styleRule => typeof styleRule === 'string' ? [styleRule] : styleRule, debugId ? "".concat(debugId, "_").concat(variantGroupName) : variantGroupName)); | ||
var compounds = []; | ||
@@ -49,5 +48,3 @@ for (var { | ||
} | ||
var recipe$ = recipe; | ||
exports.recipe = recipe; | ||
exports.recipe$ = recipe$; |
@@ -7,11 +7,4 @@ 'use strict'; | ||
var css = require('@vanilla-extract/css'); | ||
var createRuntimeFn_dist_vanillaExtractRecipesCreateRuntimeFn = require('../createRuntimeFn/dist/vanilla-extract-recipes-createRuntimeFn.cjs.prod.js'); | ||
var createRuntimeFn_dist_vanillaExtractRecipesCreateRuntimeFn = require('./createRuntimeFn-166334d7.cjs.prod.js'); | ||
function mapValues(input, fn) { | ||
var result = {}; | ||
for (var _key in input) { | ||
result[_key] = fn(input[_key], _key); | ||
} | ||
return result; | ||
} | ||
function recipe(options, debugId) { | ||
@@ -22,8 +15,14 @@ var { | ||
compoundVariants = [], | ||
base = '' | ||
base | ||
} = options; | ||
var defaultClassName = typeof base === 'string' ? base : css.style(base, debugId); | ||
var defaultClassName; | ||
if (!base || typeof base === 'string') { | ||
var baseClassName = css.style({}); | ||
defaultClassName = base ? "".concat(baseClassName, " ").concat(base) : baseClassName; | ||
} else { | ||
defaultClassName = css.style(base, debugId); | ||
} | ||
// @ts-expect-error | ||
var variantClassNames = mapValues(variants, (variantGroup, variantGroupName) => css.styleVariants(variantGroup, styleRule => typeof styleRule === 'string' ? [styleRule] : styleRule, debugId ? "".concat(debugId, "_").concat(variantGroupName) : variantGroupName)); | ||
var variantClassNames = createRuntimeFn_dist_vanillaExtractRecipesCreateRuntimeFn.mapValues(variants, (variantGroup, variantGroupName) => css.styleVariants(variantGroup, styleRule => typeof styleRule === 'string' ? [styleRule] : styleRule, debugId ? "".concat(debugId, "_").concat(variantGroupName) : variantGroupName)); | ||
var compounds = []; | ||
@@ -49,5 +48,3 @@ for (var { | ||
} | ||
var recipe$ = recipe; | ||
exports.recipe = recipe; | ||
exports.recipe$ = recipe$; |
import { addRecipe } from '@vanilla-extract/css/recipe'; | ||
import { style, styleVariants } from '@vanilla-extract/css'; | ||
import { createRuntimeFn } from '../createRuntimeFn/dist/vanilla-extract-recipes-createRuntimeFn.esm.js'; | ||
import { m as mapValues, c as createRuntimeFn } from './createRuntimeFn-62c9670f.esm.js'; | ||
function mapValues(input, fn) { | ||
var result = {}; | ||
for (var _key in input) { | ||
result[_key] = fn(input[_key], _key); | ||
} | ||
return result; | ||
} | ||
function recipe(options, debugId) { | ||
@@ -17,5 +10,11 @@ var { | ||
compoundVariants = [], | ||
base = '' | ||
base | ||
} = options; | ||
var defaultClassName = typeof base === 'string' ? base : style(base, debugId); | ||
var defaultClassName; | ||
if (!base || typeof base === 'string') { | ||
var baseClassName = style({}); | ||
defaultClassName = base ? "".concat(baseClassName, " ").concat(base) : baseClassName; | ||
} else { | ||
defaultClassName = style(base, debugId); | ||
} | ||
@@ -44,4 +43,3 @@ // @ts-expect-error | ||
} | ||
var recipe$ = recipe; | ||
export { recipe, recipe$ }; | ||
export { recipe }; |
{ | ||
"name": "@vanilla-extract/recipes", | ||
"version": "0.0.0-inline-prototype-202342012537", | ||
"version": "0.0.0-namespace-theme-tokens-20240321223951", | ||
"description": "Create multi-variant styles with a type-safe runtime API, heavily inspired by https://stitches.dev", | ||
@@ -37,7 +37,7 @@ "sideEffects": false, | ||
"peerDependencies": { | ||
"@vanilla-extract/css": "^0.0.0-inline-prototype-202342012537" | ||
"@vanilla-extract/css": "0.0.0-namespace-theme-tokens-20240321223951" | ||
}, | ||
"devDependencies": { | ||
"@vanilla-extract/css": "^0.0.0-inline-prototype-202342012537" | ||
"@vanilla-extract/css": "0.0.0-namespace-theme-tokens-20240321223951" | ||
} | ||
} |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
25725
19
535
1