tailwind-styled-v4 5.1.25 → 5.1.27

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/dist/index.d.mts CHANGED
@@ -32,7 +32,7 @@ type VariantLiterals = string | number | boolean;
32
32
  /** Sizes sugar syntax — shorthand untuk variants.size */
33
33
  type SizesConfig = Record<string, string>;
34
34
  type InferVariantProps<T extends ComponentConfig> = {
35
- [K in keyof T["variants"]]?: keyof T["variants"][K];
35
+ [K in keyof T["variants"]]?: T["variants"][K] extends Record<infer Key, any> ? Key extends "true" | "false" ? boolean : Key : never;
36
36
  };
37
37
  type InferSizeProps<T extends ComponentConfig> = T["sizes"] extends Record<string, string> ? {
38
38
  size?: keyof T["sizes"];
@@ -66,7 +66,7 @@ type InferStatesProps<T extends ComponentConfig> = {
66
66
  interface SubComponentConfig {
67
67
  base?: string;
68
68
  variants?: Record<string, Record<string, string>>;
69
- defaultVariants?: Record<string, string>;
69
+ defaultVariants?: Record<string, string | number | boolean>;
70
70
  compoundVariants?: Array<{
71
71
  class: string;
72
72
  [key: string]: string;
@@ -90,8 +90,10 @@ type SubValue = string | Record<string, string | SubComponentConfig>;
90
90
  type StatesConfig = Record<string, string>;
91
91
  interface ComponentConfig {
92
92
  base?: string;
93
- /** Variants — nested: { intent: { primary: "..." }, size: { sm: "..." } } */
94
- variants?: Record<string, Record<string, string>>;
93
+ /** Variants — nested: { intent: { primary: "..." }, size: { sm: "..." } }
94
+ * Supports string and boolean keys: { disabled: { true: "...", false: "..." } }
95
+ */
96
+ variants?: Record<string, Record<string | "true" | "false", string>>;
95
97
  defaultVariants?: Record<string, string>;
96
98
  compoundVariants?: Array<{
97
99
  class: string;
package/dist/index.d.ts CHANGED
@@ -32,7 +32,7 @@ type VariantLiterals = string | number | boolean;
32
32
  /** Sizes sugar syntax — shorthand untuk variants.size */
33
33
  type SizesConfig = Record<string, string>;
34
34
  type InferVariantProps<T extends ComponentConfig> = {
35
- [K in keyof T["variants"]]?: keyof T["variants"][K];
35
+ [K in keyof T["variants"]]?: T["variants"][K] extends Record<infer Key, any> ? Key extends "true" | "false" ? boolean : Key : never;
36
36
  };
37
37
  type InferSizeProps<T extends ComponentConfig> = T["sizes"] extends Record<string, string> ? {
38
38
  size?: keyof T["sizes"];
@@ -66,7 +66,7 @@ type InferStatesProps<T extends ComponentConfig> = {
66
66
  interface SubComponentConfig {
67
67
  base?: string;
68
68
  variants?: Record<string, Record<string, string>>;
69
- defaultVariants?: Record<string, string>;
69
+ defaultVariants?: Record<string, string | number | boolean>;
70
70
  compoundVariants?: Array<{
71
71
  class: string;
72
72
  [key: string]: string;
@@ -90,8 +90,10 @@ type SubValue = string | Record<string, string | SubComponentConfig>;
90
90
  type StatesConfig = Record<string, string>;
91
91
  interface ComponentConfig {
92
92
  base?: string;
93
- /** Variants — nested: { intent: { primary: "..." }, size: { sm: "..." } } */
94
- variants?: Record<string, Record<string, string>>;
93
+ /** Variants — nested: { intent: { primary: "..." }, size: { sm: "..." } }
94
+ * Supports string and boolean keys: { disabled: { true: "...", false: "..." } }
95
+ */
96
+ variants?: Record<string, Record<string | "true" | "false", string>>;
95
97
  defaultVariants?: Record<string, string>;
96
98
  compoundVariants?: Array<{
97
99
  class: string;
package/dist/index.js CHANGED
@@ -965,7 +965,7 @@ function resolveVariants(variants, props, defaults) {
965
965
  if (!binding?.resolveSimpleVariants) {
966
966
  const classes = [];
967
967
  for (const key of Object.keys(variants)) {
968
- const propValue = cleanProps[key] ?? defaults[key];
968
+ const propValue = cleanProps[key] ?? String(defaults[key]);
969
969
  if (propValue !== void 0 && variants[key]?.[propValue]) {
970
970
  classes.push(variants[key][propValue]);
971
971
  }
@@ -1491,14 +1491,20 @@ function cv(config, componentId) {
1491
1491
  }
1492
1492
  }
1493
1493
  }
1494
- return (props = {}) => {
1494
+ const stringifiedDefaults = {};
1495
+ if (config.defaultVariants) {
1496
+ for (const [k, v] of Object.entries(config.defaultVariants)) {
1497
+ stringifiedDefaults[k] = String(v);
1498
+ }
1499
+ }
1500
+ return ((props = {}) => {
1495
1501
  let result;
1496
1502
  const variantKeys = Object.keys(config.variants ?? {});
1497
1503
  if (componentId) {
1498
1504
  const generated = lookupGenerated(
1499
1505
  componentId,
1500
1506
  props,
1501
- config.defaultVariants,
1507
+ stringifiedDefaults,
1502
1508
  variantKeys
1503
1509
  );
1504
1510
  result = generated ?? resolveVariantsNative(config, props);
@@ -1506,7 +1512,7 @@ function cv(config, componentId) {
1506
1512
  result = resolveVariantsNative(config, props);
1507
1513
  }
1508
1514
  return props.className ? twMerge(result, props.className) : result;
1509
- };
1515
+ });
1510
1516
  }
1511
1517
 
1512
1518
  // packages/domain/core/src/cx.ts