clava 0.6.2 → 0.6.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,31 @@
1
1
  # clava
2
2
 
3
+ ## 0.6.4
4
+
5
+ - Fixed shared components in [`cv`](https://clava.style/docs/reference/cv) extension chains to apply only at their first occurrence, preventing repeated base classes and variant output when several components extend the same base.
6
+
7
+ ## 0.6.3
8
+
9
+ ### Improved runtime performance of the `refine` chain
10
+
11
+ Per-render benchmarks improve roughly 15% to 20% for a component that extends nothing and whose [`refine`](https://clava.style/docs/reference/refine) callback does not change variants. A component that does more work per render gains a smaller share of that improvement. The minified bundle is 2.2% smaller. There are no public API or behavior changes.
12
+
13
+ Resolving a component whose chain contains [`refine`](https://clava.style/docs/reference/refine) or a computed `defaultVariants` entry allocated the bookkeeping for a variant change on every call, even when no callback changed one. Each piece of that bookkeeping is now created only when something reads it: the record of assigned variants when a callback assigns one, and the copy of your props when a computed default reads them.
14
+
15
+ ### Improved runtime performance of re-running the `refine` chain
16
+
17
+ Per-render benchmarks improve roughly 15% to 20% for a component whose [`refine`](https://clava.style/docs/reference/refine) callback or computed `defaultVariants` entry changes a variant, and the [`getVariants()`](https://clava.style/docs/reference/getVariants) benchmark for such a component is roughly twice as fast, measured on the unbundled `dist` under Node. The minified bundle is 0.3% smaller. There are no public API changes and no change to supported behavior.
18
+
19
+ When a callback changes a variant, Clava re-runs the chain until the variants stop changing, and each extra pass cost far more than the work it repeated. Two things caused that. A development-only check read `process.env.NODE_ENV` on every pass that changed a variant, which in Node is an environment lookup rather than a property load. Separately, the record tracking a callback's assignments was seeded with a full copy of the resolved variants. The check now runs only as a chain approaches its iteration limit, and the record holds only the keys that changed.
20
+
21
+ A bundler that replaces `process.env.NODE_ENV` already removes that check from both versions, so a bundled application gains only from the record change, which applies where a [`refine`](https://clava.style/docs/reference/refine) callback calls `setVariants`.
22
+
23
+ ### Ignored inherited property values in variants, props, and configuration
24
+
25
+ [`cv`](https://clava.style/docs/reference/cv) and [`create`](https://clava.style/docs/reference/create) no longer take a class, a style, a variant value, or a configuration setting from a key inherited from `Object.prototype`.
26
+
27
+ A variant named after an `Object.prototype` member, such as `constructor` or `toString`, now resolves like any other variant.
28
+
3
29
  ## 0.6.2
4
30
 
5
31
  - Fixed `TS2590` and `TS2345` type errors when a framework style value, such as React's `CSSProperties` or Solid's `JSX.CSSProperties`, is passed to a [`cv`](https://clava.style/docs/reference/cv) component.
package/README.md CHANGED
@@ -269,6 +269,10 @@ Function variants can return any class value, `{ class, style }`, a default Clav
269
269
 
270
270
  Use `extend` to compose existing Clava components. Extended base classes are ordered before the child class, and extended variant output is applied before child variant output.
271
271
 
272
+ If a component appears through several `extend` paths, Clava applies it only at its first occurrence. Its classes, styles, defaults, and refinement participate through that path. For example, if `left` and `right` both extend `base`, `cv({ extend: [left, right] })` applies `base`, then `left`, then `right`. The component's JSX and HTML helpers share the same identity. Separate components can still emit identical classes.
273
+
274
+ Components created by older Clava versions retain their existing internal extension behavior. Shared ancestors inside those components can still repeat.
275
+
272
276
  ```ts
273
277
  const baseButton = cv({
274
278
  class: "button",
@@ -549,7 +553,7 @@ The package also exports `ClassValue`, `StyleValue`, `StyleClassProps`, `StyleCl
549
553
 
550
554
  ## Comparison
551
555
 
552
- This table compares Clava with the packages used by the repository's alternative benchmark: `class-variance-authority@0.7.1`, `cva@1.0.0-beta.6`, `tailwind-variants/lite@3.2.2`, `tailwind-variants@3.2.2`, and `tailwind-merge@3.6.0` through Clava's `transformClass`.
556
+ This table compares Clava with the packages used by the repository's alternative benchmark: `class-variance-authority@0.7.1`, `cva@1.0.0-beta.8`, `tailwind-variants/lite@3.3.1`, and `tailwind-variants@3.3.1`.
553
557
 
554
558
  | Feature | Clava | CVA v0 | CVA v1 beta | TV Lite | TV |
555
559
  | ---------------------------------------------------- | -------------- | ------------------ | ------------------ | ------------------ | ------------------ |
@@ -565,18 +569,35 @@ This table compares Clava with the packages used by the repository's alternative
565
569
  | Dedicated slots API | No | No | No | Yes | Yes |
566
570
  | Built-in Tailwind conflict merging | No | No | No | No | Yes |
567
571
 
568
- The `pnpm perf-alternatives` benchmark resolves a composed Tailwind-style button with inherited variants, defaults, and cross-variant conditions. On Node v24.18.0, Vitest reported these results, where higher ops/sec is better:
572
+ Clava has no built-in Tailwind conflict merging. [`create({ transformClass })`](#create-and-cx) routes every generated class string through a merger such as `tailwind-merge` when you need one.
573
+
574
+ The `pnpm perf-alternatives` benchmark resolves a composed Tailwind-style button with inherited variants and defaults. It runs in two groups so each group compares equivalent work, since cross-variant conditions cost every library something different. On Node v24.18.0, Vitest reported these results, where higher ops/sec is better.
575
+
576
+ The first group composes three layers with no cross-variant conditions. `class-variance-authority` has no compose helper, so its build merges the three layers into a single config.
577
+
578
+ | Package | Ops/sec | Relative to Clava |
579
+ | -------------------------------- | --------: | ----------------: |
580
+ | `clava@0.6.2` | 2,384,411 | 1.00x |
581
+ | `class-variance-authority@0.7.1` | 1,872,892 | 1.27x slower |
582
+ | `tailwind-variants@3.3.1` | 1,312,965 | 1.82x slower |
583
+ | `tailwind-variants/lite@3.3.1` | 1,308,798 | 1.82x slower |
584
+ | `cva@1.0.0-beta.8` | 408,730 | 5.83x slower |
585
+
586
+ The second group adds the same cross-variant conditions at the interaction and product layers. Clava expresses them with `refine`, and every other library with `compoundVariants`.
587
+
588
+ | Package | Ops/sec | Relative to Clava |
589
+ | -------------------------------- | --------: | ----------------: |
590
+ | `clava@0.6.2` | 1,335,204 | 1.00x |
591
+ | `tailwind-variants/lite@3.3.1` | 568,960 | 2.35x slower |
592
+ | `tailwind-variants@3.3.1` | 563,659 | 2.37x slower |
593
+ | `class-variance-authority@0.7.1` | 500,557 | 2.67x slower |
594
+ | `cva@1.0.0-beta.8` | 313,641 | 4.26x slower |
595
+
596
+ Dividing one table by the other shows what each library charges for cross-variant conditions. `cva` charges the least at 1.30x, Clava sits at 1.79x, both `tailwind-variants` entry points are near 2.31x, and `class-variance-authority` charges the most at 3.74x. The exact ratios move by several percent between runs, so read the ordering rather than the digits, and reach for the group that matches your components rather than reading either table as the whole picture.
569
597
 
570
- | Package | Ops/sec | Relative to Clava |
571
- | ------------------------------------ | --------: | ----------------: |
572
- | `clava@0.6.1` | 1,064,359 | 1.00x |
573
- | `clava@0.6.1 + tailwind-merge@3.6.0` | 505,454 | 2.11x slower |
574
- | `class-variance-authority@0.7.1` | 435,382 | 2.44x slower |
575
- | `tailwind-variants/lite@3.2.2` | 371,763 | 2.86x slower |
576
- | `cva@1.0.0-beta.6` | 328,566 | 3.24x slower |
577
- | `tailwind-variants@3.2.2` | 274,351 | 3.88x slower |
598
+ Benchmark results vary by runtime and hardware, so treat them as a reproducible snapshot of this repository's composed-variant case rather than a universal ranking. Rows within a few percent of each other sit inside run-to-run noise, so their relative order is not meaningful. That covers the two `tailwind-variants` entry points, which land within a few percent in both groups and swap order between runs.
578
599
 
579
- Benchmark results vary by runtime and hardware, so treat them as a reproducible snapshot of this repository's composed-variant case rather than a universal ranking.
600
+ Both groups resolve one fixed prop set on every iteration, so every package with an internal cache serves repeated calls from cache after warmup. Both `tailwind-variants` entry points cache the resolved result by variant props. Clava, `cva`, and `class-variance-authority` have no such cache, so those rows recompute on every iteration.
580
601
 
581
602
  ## API Summary
582
603
 
package/dist/index.d.ts CHANGED
@@ -316,7 +316,7 @@ export declare const splitProps: SplitPropsFunction;
316
316
  /**
317
317
  * Creates the cv and cx functions.
318
318
  */
319
- export declare function create({ transformClass }?: CreateParams): {
319
+ export declare function create(params?: CreateParams): {
320
320
  cv: <V extends Variants = {}, const E extends AnyComponent[] = []>(config?: CVConfig<V, E>) => CVComponent<V, E>;
321
321
  cx: (...classes: ClassValue$1[]) => string;
322
322
  };