Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

cvax

Package Overview
Dependencies
Maintainers
1
Versions
40
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

cvax - npm Package Compare versions

Comparing version 0.1.8 to 0.2.0

dist/merge.d.ts

39

dist/index.cjs.js

@@ -12,2 +12,3 @@ "use strict";

= _interopRequireDefault(require("lodash.isequal"));
var _merge = require("./merge");
function _interopRequireDefault(obj) {

@@ -70,3 +71,2 @@ return obj && obj.__esModule ? obj : {

}, []);
// return cx(config?.base, getVariantClassNames, getCompoundVariantClassNames, props?.className)
return cn(config === null || config === void 0 ? void 0 : config.base, getVariantClassNames, getCompoundVariantClassNames, props === null || props === void 0 ? void 0 : props.className);

@@ -102,28 +102,25 @@ };

function getVariants(baseVariants, newVariants) {
const obj = Object.assign({}, baseVariants);
Object.entries(newVariants).map((param)=>{
let [variant, value] = param;
return Object.keys(value).map((key)=>{
var ref;
if (!(typeof obj !== "object")) throw new Error("obj ".concat(obj, " is not an Object"));
if (!(variant in obj)) Object.assign(obj, {
[variant]: newVariants[variant]
const variants = {
...baseVariants
};
Object.entries(newVariants).map((param2)=>{
let [variant, value] = param2;
return Object.entries(value).map((param)=>{
let [key, classes] = param;
var ref, ref1;
if (!(variant in variants)) Object.assign(variants, {
[variant]: {}
});
Object.assign(obj[variant], {
[key]: cn(obj === null || obj === void 0 ? void 0 : (ref = obj[variant]) === null || ref === void 0 ? void 0 : ref[key], value[key])
Object.assign(variants[variant], {
[key]: cn((ref = variants) === null || ref === void 0 ? void 0 : (ref1 = ref[variant]) === null || ref1 === void 0 ? void 0 : ref1[key], classes)
});
});
});
return obj;
return variants;
}
function getDefaultVariants(baseVariants, newVariants) {
const obj = Object.assign({}, baseVariants);
Object.keys(newVariants).map((variant)=>{
Object.assign(obj, {
[variant]: newVariants[variant]
});
});
return obj;
return (0, _merge).merge(baseVariants, newVariants);
}
// FIXME: make newVariants as first priopity
// TODO: optimize algorithm
function getCompoundVariants(baseVariants, newVariants) {

@@ -137,4 +134,4 @@ const arr = [

for(let i = key + 1; i < arr.length; i++){
const { className , ...ArrRest } = arr[i];
if ((0, _lodashIsequal).default(rest, ArrRest)) markArr[i] = null;
const { className , ...arrRest } = arr[i];
if ((0, _lodashIsequal).default(rest, arrRest)) markArr[i] = null;
}

@@ -141,0 +138,0 @@ }

@@ -27,5 +27,5 @@ import type { ClassProp, ClassValue, CxOptions, CxReturn, OmitUndefined, StringToBoolean } from "./types";

}> : never : never : never : T_1 extends import("type-fest/source/internal").UnknownArrayOrTuple ? import("type-fest/source/conditional-simplify").ConditionalSimplifyDeep<U, Function | Iterable<unknown>, object> extends infer T_3 ? T_3 extends import("type-fest/source/conditional-simplify").ConditionalSimplifyDeep<U, Function | Iterable<unknown>, object> ? T_3 extends import("type-fest/source/internal").UnknownArrayOrTuple ? (Exclude<T_1, undefined>[number] | Exclude<T_3, undefined>[number])[] : never : never : never : never : never : never, Function | Iterable<unknown>, object>;
defaultVariants: T & U;
defaultVariants: Pick<ConfigVariants<T>, Exclude<keyof T, keyof (Pick<ConfigVariants<U>, Exclude<keyof U, never>> & Pick<unknown, never> & {} extends infer T_4 ? T_4 extends Pick<ConfigVariants<U>, Exclude<keyof U, never>> & Pick<unknown, never> & {} ? T_4 extends unknown ? {} : never : never : never)>> & Pick<Pick<ConfigVariants<U>, Exclude<keyof U, never>> & Pick<unknown, never> & {} extends infer T_4 ? T_4 extends Pick<ConfigVariants<U>, Exclude<keyof U, never>> & Pick<unknown, never> & {} ? T_4 extends unknown ? {} : never : never : never, Exclude<keyof (Pick<ConfigVariants<U>, Exclude<keyof U, never>> & Pick<unknown, never> & {} extends infer T_4 ? T_4 extends Pick<ConfigVariants<U>, Exclude<keyof U, never>> & Pick<unknown, never> & {} ? T_4 extends unknown ? {} : never : never : never), ((Pick<ConfigVariants<U>, Exclude<keyof U, never>> & Pick<unknown, never> & {} extends infer T_4 ? T_4 extends Pick<ConfigVariants<U>, Exclude<keyof U, never>> & Pick<unknown, never> & {} ? T_4 extends unknown ? {} : never : never : never) extends infer T_5 ? { [Key in keyof T_5]-?: {} extends { [P in Key]: (Pick<ConfigVariants<U>, Exclude<keyof U, never>> & Pick<unknown, never> & {} extends infer T_4 ? T_4 extends Pick<ConfigVariants<U>, Exclude<keyof U, never>> & Pick<unknown, never> & {} ? T_4 extends unknown ? {} : never : never : never)[Key]; } ? Key : never; } : never)[keyof (Pick<ConfigVariants<U>, Exclude<keyof U, never>> & Pick<unknown, never> & {} extends infer T_4 ? T_4 extends Pick<ConfigVariants<U>, Exclude<keyof U, never>> & Pick<unknown, never> & {} ? T_4 extends unknown ? {} : never : never : never)]>> & Pick<Pick<ConfigVariants<U>, Exclude<keyof U, never>> & Pick<unknown, never> & {} extends infer T_4 ? T_4 extends Pick<ConfigVariants<U>, Exclude<keyof U, never>> & Pick<unknown, never> & {} ? T_4 extends unknown ? {} : never : never : never, Exclude<((Pick<ConfigVariants<U>, Exclude<keyof U, never>> & Pick<unknown, never> & {} extends infer T_4 ? T_4 extends Pick<ConfigVariants<U>, Exclude<keyof U, never>> & Pick<unknown, never> & {} ? T_4 extends unknown ? {} : never : never : never) extends infer T_5 ? { [Key in keyof T_5]-?: {} extends { [P in Key]: (Pick<ConfigVariants<U>, Exclude<keyof U, never>> & Pick<unknown, never> & {} extends infer T_4 ? T_4 extends Pick<ConfigVariants<U>, Exclude<keyof U, never>> & Pick<unknown, never> & {} ? T_4 extends unknown ? {} : never : never : never)[Key]; } ? Key : never; } : never)[keyof (Pick<ConfigVariants<U>, Exclude<keyof U, never>> & Pick<unknown, never> & {} extends infer T_4 ? T_4 extends Pick<ConfigVariants<U>, Exclude<keyof U, never>> & Pick<unknown, never> & {} ? T_4 extends unknown ? {} : never : never : never)], keyof T>> & { [P_1 in ((Pick<ConfigVariants<U>, Exclude<keyof U, never>> & Pick<unknown, never> & {} extends infer T_4 ? T_4 extends Pick<ConfigVariants<U>, Exclude<keyof U, never>> & Pick<unknown, never> & {} ? T_4 extends unknown ? {} : never : never : never) extends infer T_5 ? { [Key in keyof T_5]-?: {} extends { [P in Key]: (Pick<ConfigVariants<U>, Exclude<keyof U, never>> & Pick<unknown, never> & {} extends infer T_4 ? T_4 extends Pick<ConfigVariants<U>, Exclude<keyof U, never>> & Pick<unknown, never> & {} ? T_4 extends unknown ? {} : never : never : never)[Key]; } ? Key : never; } : never)[keyof (Pick<ConfigVariants<U>, Exclude<keyof U, never>> & Pick<unknown, never> & {} extends infer T_4 ? T_4 extends Pick<ConfigVariants<U>, Exclude<keyof U, never>> & Pick<unknown, never> & {} ? T_4 extends unknown ? {} : never : never : never)] & keyof T]: ConfigVariants<T>[P_1] | Exclude<(Pick<ConfigVariants<U>, Exclude<keyof U, never>> & Pick<unknown, never> & {} extends infer T_4 ? T_4 extends Pick<ConfigVariants<U>, Exclude<keyof U, never>> & Pick<unknown, never> & {} ? T_4 extends unknown ? {} : never : never : never)[P_1], undefined>; } extends infer T_6 ? T_6 extends Pick<ConfigVariants<T>, Exclude<keyof T, keyof (Pick<ConfigVariants<U>, Exclude<keyof U, never>> & Pick<unknown, never> & {} extends infer T_4 ? T_4 extends Pick<ConfigVariants<U>, Exclude<keyof U, never>> & Pick<unknown, never> & {} ? T_4 extends unknown ? {} : never : never : never)>> & Pick<Pick<ConfigVariants<U>, Exclude<keyof U, never>> & Pick<unknown, never> & {} extends infer T_4 ? T_4 extends Pick<ConfigVariants<U>, Exclude<keyof U, never>> & Pick<unknown, never> & {} ? T_4 extends unknown ? {} : never : never : never, Exclude<keyof (Pick<ConfigVariants<U>, Exclude<keyof U, never>> & Pick<unknown, never> & {} extends infer T_4 ? T_4 extends Pick<ConfigVariants<U>, Exclude<keyof U, never>> & Pick<unknown, never> & {} ? T_4 extends unknown ? {} : never : never : never), ((Pick<ConfigVariants<U>, Exclude<keyof U, never>> & Pick<unknown, never> & {} extends infer T_4 ? T_4 extends Pick<ConfigVariants<U>, Exclude<keyof U, never>> & Pick<unknown, never> & {} ? T_4 extends unknown ? {} : never : never : never) extends infer T_5 ? { [Key in keyof T_5]-?: {} extends { [P in Key]: (Pick<ConfigVariants<U>, Exclude<keyof U, never>> & Pick<unknown, never> & {} extends infer T_4 ? T_4 extends Pick<ConfigVariants<U>, Exclude<keyof U, never>> & Pick<unknown, never> & {} ? T_4 extends unknown ? {} : never : never : never)[Key]; } ? Key : never; } : never)[keyof (Pick<ConfigVariants<U>, Exclude<keyof U, never>> & Pick<unknown, never> & {} extends infer T_4 ? T_4 extends Pick<ConfigVariants<U>, Exclude<keyof U, never>> & Pick<unknown, never> & {} ? T_4 extends unknown ? {} : never : never : never)]>> & Pick<Pick<ConfigVariants<U>, Exclude<keyof U, never>> & Pick<unknown, never> & {} extends infer T_4 ? T_4 extends Pick<ConfigVariants<U>, Exclude<keyof U, never>> & Pick<unknown, never> & {} ? T_4 extends unknown ? {} : never : never : never, Exclude<((Pick<ConfigVariants<U>, Exclude<keyof U, never>> & Pick<unknown, never> & {} extends infer T_4 ? T_4 extends Pick<ConfigVariants<U>, Exclude<keyof U, never>> & Pick<unknown, never> & {} ? T_4 extends unknown ? {} : never : never : never) extends infer T_5 ? { [Key in keyof T_5]-?: {} extends { [P in Key]: (Pick<ConfigVariants<U>, Exclude<keyof U, never>> & Pick<unknown, never> & {} extends infer T_4 ? T_4 extends Pick<ConfigVariants<U>, Exclude<keyof U, never>> & Pick<unknown, never> & {} ? T_4 extends unknown ? {} : never : never : never)[Key]; } ? Key : never; } : never)[keyof (Pick<ConfigVariants<U>, Exclude<keyof U, never>> & Pick<unknown, never> & {} extends infer T_4 ? T_4 extends Pick<ConfigVariants<U>, Exclude<keyof U, never>> & Pick<unknown, never> & {} ? T_4 extends unknown ? {} : never : never : never)], keyof T>> & { [P_1 in ((Pick<ConfigVariants<U>, Exclude<keyof U, never>> & Pick<unknown, never> & {} extends infer T_4 ? T_4 extends Pick<ConfigVariants<U>, Exclude<keyof U, never>> & Pick<unknown, never> & {} ? T_4 extends unknown ? {} : never : never : never) extends infer T_5 ? { [Key in keyof T_5]-?: {} extends { [P in Key]: (Pick<ConfigVariants<U>, Exclude<keyof U, never>> & Pick<unknown, never> & {} extends infer T_4 ? T_4 extends Pick<ConfigVariants<U>, Exclude<keyof U, never>> & Pick<unknown, never> & {} ? T_4 extends unknown ? {} : never : never : never)[Key]; } ? Key : never; } : never)[keyof (Pick<ConfigVariants<U>, Exclude<keyof U, never>> & Pick<unknown, never> & {} extends infer T_4 ? T_4 extends Pick<ConfigVariants<U>, Exclude<keyof U, never>> & Pick<unknown, never> & {} ? T_4 extends unknown ? {} : never : never : never)] & keyof T]: ConfigVariants<T>[P_1] | Exclude<(Pick<ConfigVariants<U>, Exclude<keyof U, never>> & Pick<unknown, never> & {} extends infer T_4 ? T_4 extends Pick<ConfigVariants<U>, Exclude<keyof U, never>> & Pick<unknown, never> & {} ? T_4 extends unknown ? {} : never : never : never)[P_1], undefined>; } ? T_6 extends unknown ? {} : never : never : never;
compoundVariants: ((T extends ConfigSchema ? (ConfigVariants<T> | ConfigVariantsMulti<T>) & ClassProp : ClassProp) | (U extends ConfigSchema ? (ConfigVariants<U> | ConfigVariantsMulti<U>) & ClassProp : ClassProp))[];
};
export {};
import { twMerge } from "tailwind-merge";
import isEqual from "lodash.isequal"; // FIXME: find the way to not to use lodash
import { merge } from "./merge";
function falsyToString(value) {

@@ -57,3 +58,2 @@ return typeof value === "boolean" ? "".concat(value) : value === 0 ? "0" : value;

}, []);
// return cx(config?.base, getVariantClassNames, getCompoundVariantClassNames, props?.className)
return cn(config === null || config === void 0 ? void 0 : config.base, getVariantClassNames, getCompoundVariantClassNames, props === null || props === void 0 ? void 0 : props.className);

@@ -90,28 +90,25 @@ };

function getVariants(baseVariants, newVariants) {
const obj = Object.assign({}, baseVariants);
Object.entries(newVariants).map((param)=>{
let [variant, value] = param;
return Object.keys(value).map((key)=>{
var ref;
if (!(typeof obj !== "object")) throw new Error("obj ".concat(obj, " is not an Object"));
if (!(variant in obj)) Object.assign(obj, {
[variant]: newVariants[variant]
const variants = {
...baseVariants
};
Object.entries(newVariants).map((param2)=>{
let [variant, value] = param2;
return Object.entries(value).map((param)=>{
let [key, classes] = param;
var ref, ref1;
if (!(variant in variants)) Object.assign(variants, {
[variant]: {}
});
Object.assign(obj[variant], {
[key]: cn(obj === null || obj === void 0 ? void 0 : (ref = obj[variant]) === null || ref === void 0 ? void 0 : ref[key], value[key])
Object.assign(variants[variant], {
[key]: cn((ref = variants) === null || ref === void 0 ? void 0 : (ref1 = ref[variant]) === null || ref1 === void 0 ? void 0 : ref1[key], classes)
});
});
});
return obj;
return variants;
}
function getDefaultVariants(baseVariants, newVariants) {
const obj = Object.assign({}, baseVariants);
Object.keys(newVariants).map((variant)=>{
Object.assign(obj, {
[variant]: newVariants[variant]
});
});
return obj;
return merge(baseVariants, newVariants);
}
// FIXME: make newVariants as first priopity
// TODO: optimize algorithm
function getCompoundVariants(baseVariants, newVariants) {

@@ -125,4 +122,4 @@ const arr = [

for(let i = key + 1; i < arr.length; i++){
const { className , ...ArrRest } = arr[i];
if (isEqual(rest, ArrRest)) markArr[i] = null;
const { className , ...arrRest } = arr[i];
if (isEqual(rest, arrRest)) markArr[i] = null;
}

@@ -129,0 +126,0 @@ }

{
"name": "cvax",
"version": "0.1.8",
"version": "0.2.0",
"description": "Customized CVA. fork 'class-variance-authority'",

@@ -5,0 +5,0 @@ "repository": "https://github.com/alexvyber/cvax.git",

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc