Socket
Socket
Sign inDemoInstall

@uxf/core

Package Overview
Dependencies
3
Maintainers
1
Versions
84
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 11.11.3 to 11.18.0

utils/cx.test.d.ts

2

package.json
{
"name": "@uxf/core",
"version": "11.11.3",
"version": "11.18.0",
"description": "UXF Core",

@@ -5,0 +5,0 @@ "author": "Petr Vejvoda <vejvoda@uxf.cz>",

@@ -331,2 +331,54 @@ # UXF Core

## Utils
### cx, cxa
It is our fork of `clsx` library https://github.com/lukeed/clsx
We will mainly use `cx`, which is fork of `clsx/lite` – it accepts **ONLY** string values! Any non-string arguments are ignored!
```tsx
import { cx } from "@uxf/core/utils/cx";
// string
cx("hello", true && "foo", false && "bar");
// => "hello foo"
// NOTE: Any non-string input(s) ignored
cx({ foo: true });
//=> ""
```
The `cxa` function is full fork of `clsx` and can take *any* number of arguments, each of which can be an Object, Array, Boolean, or String.
**Important**: Any falsy values are discarded! Standalone Boolean values are discarded as well.
```tsx
import { cxa } from "@uxf/core/utils/cxa";
cxa(true, false, "", null, undefined, 0, NaN);
//=> ""
// Strings (variadic)
cxa("foo", true && "bar", "baz");
//=> "foo bar baz"
// Objects
cxa({ foo:true, bar:false, baz:isTrue() });
//=> "foo baz"
// Objects (variadic)
cxa({ foo:true }, { bar:false }, null, { "--foobar":"hello" });
//=> "foo --foobar"
// Arrays
cxa(["foo", 0, false, "bar"]);
//=> "foo bar"
// Arrays (variadic)
cxa(["foo"], ["", 0, false, "bar"], [["baz", [["hello"], "there"]]]);
//=> "foo bar baz hello there"
// Kitchen sink (with nesting)
cxa("foo", [1 && "bar", { baz:false, bat:null }, ["hello", ["world"]]], "cya");
//=> "foo bar hello world cya"
```
## Validators

@@ -333,0 +385,0 @@ ```tsx

@@ -1,3 +0,2 @@

export type ClassArray = ClassValue[];
export type ClassValue = ClassArray | Record<string, any> | string | number | null | boolean | undefined;
export declare function cx(...classes: ClassValue[]): string;
export type CxClassValue = string | null | boolean | undefined;
export declare function cx(...classes: CxClassValue[]): string;
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.cx = void 0;
function toVal(mix) {
let k;
let y;
let str = "";
if (typeof mix === "string" || typeof mix === "number") {
str += mix;
}
else if (typeof mix === "object") {
if (Array.isArray(mix)) {
for (k = 0; k < mix.length; k++) {
if (mix[k]) {
if ((y = toVal(mix[k]))) {
if (str) {
str += " ";
}
str += y;
}
}
}
}
else {
for (k in mix) {
if (mix === null || mix === void 0 ? void 0 : mix[k]) {
if (str) {
str += " ";
}
str += k;
}
}
}
}
return str;
}
function cx(...classes) {
let i = 0;
let tmp;
let x;
let str = "";
while (i < classes.length) {
if ((tmp = classes[i++])) {
if ((x = toVal(tmp))) {
if (str) {
str += " ";
}
str += x;
let i = 0, tmp, str = "";
for (; i < classes.length; i++) {
if ((tmp = classes[i])) {
if (typeof tmp === "string") {
str += (str && " ") + tmp;
}

@@ -50,0 +11,0 @@ }

SocketSocket SOC 2 Logo

Product

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc