clava 0.1.19 → 0.2.1

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,44 @@
1
1
  # clava
2
2
 
3
+ ## 0.2.1
4
+
5
+ ### Improved runtime performance of `cv` and `splitProps`
6
+
7
+ Variant tables, disabled-variant sets, and extended-component metadata are now pre-built once when [`cv`](https://clava.style/docs/reference/cv) is called, so prop resolution no longer walks `Object.entries` and variant-related styles are pre-normalized at creation time instead of on each render. [`splitProps`](https://clava.style/docs/reference/split-props) reuses component key arrays directly instead of copying them per call.
8
+
9
+ Per-render benchmarks improve roughly 2× to 7×, with no public API or behavior changes; component-creation cost is unchanged.
10
+
11
+ ## 0.2.0
12
+
13
+ ### Minor Changes
14
+
15
+ - 2d99317: Removed the `defaultMode` option from `create()` and changed the default callable Clava component result to return normalized `{ class, style }` props.
16
+
17
+ Calling a component directly now always returns Clava's definition-compatible shape, with camelCase style keys. Use `.jsx`, `.html`, or `.htmlObj` when a framework- or renderer-specific prop shape is needed.
18
+
19
+ Before:
20
+
21
+ ```ts
22
+ const { cv } = create({ defaultMode: "htmlObj" });
23
+ const button = cv({ style: { fontSize: "16px" } });
24
+
25
+ button();
26
+ // { class: "", style: { "font-size": "16px" } }
27
+ ```
28
+
29
+ After:
30
+
31
+ ```ts
32
+ const { cv } = create();
33
+ const button = cv({ style: { fontSize: "16px" } });
34
+
35
+ button();
36
+ // { class: "", style: { fontSize: "16px" } }
37
+
38
+ button.htmlObj();
39
+ // { class: "", style: { "font-size": "16px" } }
40
+ ```
41
+
3
42
  ## 0.1.19
4
43
 
5
44
  ### Patch Changes
package/dist/index.d.ts CHANGED
@@ -18,12 +18,11 @@ interface HTMLObjProps {
18
18
  class: string;
19
19
  style: HTMLCSSProperties;
20
20
  }
21
- interface StyleProps {
22
- jsx: JSXProps;
23
- html: HTMLProps;
24
- htmlObj: HTMLObjProps;
21
+ interface StyleClassProps {
22
+ class: string;
23
+ style: StyleValue;
25
24
  }
26
- type ComponentResult = JSXProps | HTMLProps | HTMLObjProps;
25
+ type ComponentResult = JSXProps | HTMLProps | HTMLObjProps | StyleClassProps;
27
26
  type AllComponentResultKeys = keyof JSXProps | keyof HTMLProps | keyof HTMLObjProps;
28
27
  type ComponentResultValue<K extends AllComponentResultKeys> = K extends "style" ? StyleProperty : K extends "className" ? string : K extends "class" ? string : never;
29
28
  type NullableComponentResult = { [K in AllComponentResultKeys]?: ComponentResultValue<K> | null };
@@ -58,11 +57,11 @@ interface ModalComponent<V, R extends ComponentResult> {
58
57
  class: (props?: ComponentProps<V>) => string;
59
58
  style: (props?: ComponentProps<V>) => R["style"];
60
59
  getVariants: GetVariants<V>;
61
- keys: (keyof V | keyof R)[];
60
+ keys: (keyof V | keyof NullableComponentResult)[];
62
61
  variantKeys: (keyof V)[];
63
- propKeys: (keyof V | keyof R)[];
62
+ propKeys: (keyof V | keyof NullableComponentResult)[];
64
63
  }
65
- interface CVComponent<V extends Variants = {}, CV extends ComputedVariants = {}, E extends AnyComponent[] = [], R extends ComponentResult = ComponentResult> extends ModalComponent<MergeVariants<V, CV, E>, R> {
64
+ interface CVComponent<V extends Variants = {}, CV extends ComputedVariants = {}, E extends AnyComponent[] = [], R extends ComponentResult = StyleClassProps> extends ModalComponent<MergeVariants<V, CV, E>, R> {
66
65
  jsx: ModalComponent<MergeVariants<V, CV, E>, JSXProps>;
67
66
  html: ModalComponent<MergeVariants<V, CV, E>, HTMLProps>;
68
67
  htmlObj: ModalComponent<MergeVariants<V, CV, E>, HTMLObjProps>;
@@ -105,10 +104,6 @@ type ExtendedVariants<E extends AnyComponent[]> = MergeExtendedVariants<E> & Mer
105
104
  type NullablePartial<T> = T extends Record<string, any> ? { [K in keyof T]?: T[K] | null } : T | null;
106
105
  type ExtendableVariants<V extends Variants, E extends AnyComponent[]> = V & { [K in keyof ExtendedVariants<E>]?: NullablePartial<ExtendedVariants<E>[K]> | Variant$1 };
107
106
  //#endregion
108
- //#region src/utils.d.ts
109
- declare const MODES: readonly ["jsx", "html", "htmlObj"];
110
- type Mode = (typeof MODES)[number];
111
- //#endregion
112
107
  //#region src/index.d.ts
113
108
  type VariantProps<T extends Pick<AnyComponent, "getVariants">> = ReturnType<T["getVariants"]>;
114
109
  type VariantKey<T> = T extends boolean ? "true" | "false" : Extract<T, string>;
@@ -122,8 +117,7 @@ interface CVConfig<V extends Variants = {}, CV extends ComputedVariants = {}, E
122
117
  defaultVariants?: VariantValues<MergeVariants<V, CV, E>>;
123
118
  computed?: Computed<MergeVariants<V, CV, E>>;
124
119
  }
125
- interface CreateParams<M extends Mode> {
126
- defaultMode?: M;
120
+ interface CreateParams {
127
121
  transformClass?: (className: string) => string;
128
122
  }
129
123
  /**
@@ -133,29 +127,18 @@ interface CreateParams<M extends Mode> {
133
127
  * only receive variant props. Arrays receive their listed keys but don't claim
134
128
  * styling props. The last element is always the "rest" containing keys not
135
129
  * claimed by any source.
136
- * @example
137
- * ```ts
138
- * const [buttonProps, inputProps, rest] = splitProps(
139
- * props,
140
- * buttonComponent,
141
- * inputComponent,
142
- * );
143
- * // buttonProps has class/style + button variants
144
- * // inputProps has only input variants (no class/style)
145
- * ```
146
130
  */
147
131
  declare const splitProps: SplitPropsFunction;
148
132
  /**
149
133
  * Creates the cv and cx functions.
150
134
  */
151
- declare function create<M extends Mode = "jsx">({
152
- defaultMode,
135
+ declare function create({
153
136
  transformClass
154
- }?: CreateParams<M>): {
155
- cv: <V extends Variants = {}, CV extends ComputedVariants = {}, const E extends AnyComponent[] = []>(config?: CVConfig<V, CV, E>) => CVComponent<V, CV, E, StyleProps[M]>;
137
+ }?: CreateParams): {
138
+ cv: <V extends Variants = {}, CV extends ComputedVariants = {}, const E extends AnyComponent[] = []>(config?: CVConfig<V, CV, E>) => CVComponent<V, CV, E>;
156
139
  cx: (...classes: ClassValue$1[]) => string;
157
140
  };
158
- declare const cv: <V extends Variants = {}, CV extends ComputedVariants = {}, const E extends AnyComponent[] = []>(config?: CVConfig<V, CV, E>) => CVComponent<V, CV, E, JSXProps>, cx: (...classes: ClassValue$1[]) => string;
141
+ declare const cv: <V extends Variants = {}, CV extends ComputedVariants = {}, const E extends AnyComponent[] = []>(config?: CVConfig<V, CV, E>) => CVComponent<V, CV, E>, cx: (...classes: ClassValue$1[]) => string;
159
142
  //#endregion
160
- export { type CVComponent, CVConfig, type ClassValue, type HTMLObjProps, type HTMLProps, type JSXProps, type StyleClassValue, type StyleValue, Variant, VariantProps, create, cv, cx, splitProps };
143
+ export { type CVComponent, CVConfig, type ClassValue, type HTMLObjProps, type HTMLProps, type JSXProps, type StyleClassProps, type StyleClassValue, type StyleValue, Variant, VariantProps, create, cv, cx, splitProps };
161
144
  //# sourceMappingURL=index.d.ts.map