clava 0.6.1 → 0.6.3

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.
@@ -1,4 +1,4 @@
1
- import { hasOwn } from "./utils.ts";
1
+ import { getOwn, hasOwn } from "./utils.ts";
2
2
 
3
3
  export interface CreationFrame {
4
4
  stack?: string;
@@ -105,8 +105,9 @@ export function accumulateUnstableVariantChanges(
105
105
  ): void {
106
106
  for (const key in next) {
107
107
  if (!hasOwn(next, key)) continue;
108
- if (!Object.is(prev[key], next[key])) {
109
- setVariantChange(into, key, prev[key], next[key]);
108
+ const from = getOwn(prev, key);
109
+ if (!Object.is(from, next[key])) {
110
+ setVariantChange(into, key, from, next[key]);
110
111
  }
111
112
  }
112
113
  for (const key in prev) {
package/src/types.ts CHANGED
@@ -24,19 +24,28 @@ export type ClassValue =
24
24
  | void
25
25
  | ClassValue[];
26
26
 
27
- export interface JSXCSSProperties extends CSS.Properties<string | number> {
27
+ interface CustomProperties {
28
28
  [key: `--${string}`]: string | number;
29
29
  }
30
30
 
31
- export interface HTMLCSSProperties extends CSS.PropertiesHyphen<
32
- string | number
33
- > {
34
- [key: `--${string}`]: string | number;
35
- }
31
+ export interface JSXCSSProperties
32
+ extends CSS.Properties<string | number>, CustomProperties {}
33
+
34
+ export interface HTMLCSSProperties
35
+ extends CSS.PropertiesHyphen<string | number>, CustomProperties {}
36
36
 
37
37
  export type CSSProperties = CSS.Properties;
38
38
 
39
- export type StyleProperty = JSXCSSProperties | HTMLCSSProperties | string;
39
+ // Indexed members keep custom properties known to fresh style literals, one
40
+ // per input mode. Index-free members keep framework style types assignable:
41
+ // an all-indexed union rejects React's `CSSProperties`, surfacing as TS2590.
42
+ // https://github.com/ariakit/clava/issues/483#issuecomment-5447514407
43
+ export type StyleProperty =
44
+ | JSXCSSProperties
45
+ | HTMLCSSProperties
46
+ | CSS.Properties<string | number>
47
+ | CSS.PropertiesHyphen<string | number>
48
+ | string;
40
49
 
41
50
  /**
42
51
  * The prop object returned by a component's `.jsx()` mode.
@@ -375,9 +384,7 @@ export type DefaultVariants<V> = {
375
384
  * };
376
385
  * ```
377
386
  */
378
- export interface StyleValue extends CSS.Properties {
379
- [key: `--${string}`]: string | number;
380
- }
387
+ export interface StyleValue extends CSS.Properties, CustomProperties {}
381
388
 
382
389
  /**
383
390
  * A value that contributes both class and style output from a base config,
package/src/utils.ts CHANGED
@@ -2,6 +2,20 @@ import type { HTMLCSSProperties, StyleValue } from "./types.ts";
2
2
 
3
3
  export const hasOwn = Object.hasOwn;
4
4
 
5
+ /**
6
+ * Reads a key that may be absent from a plain record. Variant, prop, and config
7
+ * records are plain objects, so a key inherited from a polluted
8
+ * `Object.prototype` would otherwise read back like a value the caller passed
9
+ * or Clava itself resolved.
10
+ */
11
+ export function getOwn<T extends object, K extends keyof T & string>(
12
+ record: T,
13
+ key: K,
14
+ ): T[K] | undefined {
15
+ if (!hasOwn(record, key)) return undefined;
16
+ return record[key];
17
+ }
18
+
5
19
  // Keep this explicit so normalization does not depend on browser globals.
6
20
  // Vendor-prefixed variants are derived below instead of duplicating the list.
7
21
  const unitlessNumberProperties = new Set([