tailwind-styled-v4 5.1.24 → 5.1.26

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
@@ -19,7 +19,6 @@ interface AnimateOptions {
19
19
  name?: string;
20
20
  }
21
21
 
22
- type TokenMap = Record<string, string>;
23
22
  type HtmlTagName = keyof HTMLElementTagNameMap;
24
23
 
25
24
  /**
@@ -33,7 +32,7 @@ type VariantLiterals = string | number | boolean;
33
32
  /** Sizes sugar syntax — shorthand untuk variants.size */
34
33
  type SizesConfig = Record<string, string>;
35
34
  type InferVariantProps<T extends ComponentConfig> = {
36
- [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;
37
36
  };
38
37
  type InferSizeProps<T extends ComponentConfig> = T["sizes"] extends Record<string, string> ? {
39
38
  size?: keyof T["sizes"];
@@ -67,7 +66,7 @@ type InferStatesProps<T extends ComponentConfig> = {
67
66
  interface SubComponentConfig {
68
67
  base?: string;
69
68
  variants?: Record<string, Record<string, string>>;
70
- defaultVariants?: Record<string, string>;
69
+ defaultVariants?: Record<string, string | number | boolean>;
71
70
  compoundVariants?: Array<{
72
71
  class: string;
73
72
  [key: string]: string;
@@ -91,8 +90,10 @@ type SubValue = string | Record<string, string | SubComponentConfig>;
91
90
  type StatesConfig = Record<string, string>;
92
91
  interface ComponentConfig {
93
92
  base?: string;
94
- /** Variants — nested: { intent: { primary: "..." }, size: { sm: "..." } } */
95
- 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>>;
96
97
  defaultVariants?: Record<string, string>;
97
98
  compoundVariants?: Array<{
98
99
  class: string;
@@ -813,27 +814,4 @@ interface ThemeConfig {
813
814
  raw: Record<string, string>;
814
815
  }
815
816
 
816
- type TokenSubscriber = (tokens: TokenMap) => void;
817
- interface LiveTokenSet {
818
- vars: Record<string, string>;
819
- get(name: string): string | undefined;
820
- set(name: string, value: string): void;
821
- setAll(tokens: TokenMap): void;
822
- snapshot(): TokenMap;
823
- }
824
- interface LiveTokenEngineBridge {
825
- getToken(name: string): string | undefined;
826
- getTokens(): TokenMap;
827
- setToken(name: string, value: string): void;
828
- setTokens(tokens: TokenMap): void;
829
- applyTokenSet(tokens: TokenMap): void;
830
- subscribeTokens(fn: TokenSubscriber): () => void;
831
- subscribe?(fn: TokenSubscriber): () => void;
832
- }
833
- declare global {
834
- interface Window {
835
- __TW_TOKEN_ENGINE__?: LiveTokenEngineBridge;
836
- }
837
- }
838
-
839
- export { type ComponentConfig, type ContainerConfig, type ContainerEntry, type CvFn, type HtmlTagName, type InferVariantProps, type LiveTokenSet, type MergeOptions, type ParsedClass, type ParsedClassModifier, type ResolvedThemeTokens, type StateComponentEntry, type StateConfig, type StyledComponentProps, type StyledOptions, type StyledProps, type StyledSystemConfig, type StyledSystemInstance, type SubComponentEntry, type SubComponentMap, type SubComponentProps, type SystemComponentConfig, type SystemComponentFactory, type SystemTokenMap, type ThemeConfig, type ThemeTokenMap, type TokenMap, type TokenSubscriber, type TwComponentFactory, type TwObject, type TwStyledComponent, type TwSubComponent, type TwTagFactory, type TwTagFactoryAny, type VariantLiterals, cn, createComponent, createStyledSystem, createTheme, createTwMerge, cssVar, cv, cx, cxm, generateContainerCss, generateStateCss, getAllSubComponents, getContainerRegistry, getStateRegistry, getSubComponent, mergeWithRules, processContainer, processState, registerSubComponent, registerVariantTable, resolveStyledClassName, server, styled, t, tw, twMerge, twVar, v4Tokens, withSubComponents };
817
+ export { type ComponentConfig, type ContainerConfig, type ContainerEntry, type CvFn, type HtmlTagName, type InferVariantProps, type MergeOptions, type ParsedClass, type ParsedClassModifier, type ResolvedThemeTokens, type StateComponentEntry, type StateConfig, type StyledComponentProps, type StyledOptions, type StyledProps, type StyledSystemConfig, type StyledSystemInstance, type SubComponentEntry, type SubComponentMap, type SubComponentProps, type SystemComponentConfig, type SystemComponentFactory, type SystemTokenMap, type ThemeConfig, type ThemeTokenMap, type TwComponentFactory, type TwObject, type TwStyledComponent, type TwSubComponent, type TwTagFactory, type TwTagFactoryAny, type VariantLiterals, cn, createComponent, createStyledSystem, createTheme, createTwMerge, cssVar, cv, cx, cxm, generateContainerCss, generateStateCss, getAllSubComponents, getContainerRegistry, getStateRegistry, getSubComponent, mergeWithRules, processContainer, processState, registerSubComponent, registerVariantTable, resolveStyledClassName, server, styled, t, tw, twMerge, twVar, v4Tokens, withSubComponents };
package/dist/index.d.ts CHANGED
@@ -19,7 +19,6 @@ interface AnimateOptions {
19
19
  name?: string;
20
20
  }
21
21
 
22
- type TokenMap = Record<string, string>;
23
22
  type HtmlTagName = keyof HTMLElementTagNameMap;
24
23
 
25
24
  /**
@@ -33,7 +32,7 @@ type VariantLiterals = string | number | boolean;
33
32
  /** Sizes sugar syntax — shorthand untuk variants.size */
34
33
  type SizesConfig = Record<string, string>;
35
34
  type InferVariantProps<T extends ComponentConfig> = {
36
- [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;
37
36
  };
38
37
  type InferSizeProps<T extends ComponentConfig> = T["sizes"] extends Record<string, string> ? {
39
38
  size?: keyof T["sizes"];
@@ -67,7 +66,7 @@ type InferStatesProps<T extends ComponentConfig> = {
67
66
  interface SubComponentConfig {
68
67
  base?: string;
69
68
  variants?: Record<string, Record<string, string>>;
70
- defaultVariants?: Record<string, string>;
69
+ defaultVariants?: Record<string, string | number | boolean>;
71
70
  compoundVariants?: Array<{
72
71
  class: string;
73
72
  [key: string]: string;
@@ -91,8 +90,10 @@ type SubValue = string | Record<string, string | SubComponentConfig>;
91
90
  type StatesConfig = Record<string, string>;
92
91
  interface ComponentConfig {
93
92
  base?: string;
94
- /** Variants — nested: { intent: { primary: "..." }, size: { sm: "..." } } */
95
- 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>>;
96
97
  defaultVariants?: Record<string, string>;
97
98
  compoundVariants?: Array<{
98
99
  class: string;
@@ -813,27 +814,4 @@ interface ThemeConfig {
813
814
  raw: Record<string, string>;
814
815
  }
815
816
 
816
- type TokenSubscriber = (tokens: TokenMap) => void;
817
- interface LiveTokenSet {
818
- vars: Record<string, string>;
819
- get(name: string): string | undefined;
820
- set(name: string, value: string): void;
821
- setAll(tokens: TokenMap): void;
822
- snapshot(): TokenMap;
823
- }
824
- interface LiveTokenEngineBridge {
825
- getToken(name: string): string | undefined;
826
- getTokens(): TokenMap;
827
- setToken(name: string, value: string): void;
828
- setTokens(tokens: TokenMap): void;
829
- applyTokenSet(tokens: TokenMap): void;
830
- subscribeTokens(fn: TokenSubscriber): () => void;
831
- subscribe?(fn: TokenSubscriber): () => void;
832
- }
833
- declare global {
834
- interface Window {
835
- __TW_TOKEN_ENGINE__?: LiveTokenEngineBridge;
836
- }
837
- }
838
-
839
- export { type ComponentConfig, type ContainerConfig, type ContainerEntry, type CvFn, type HtmlTagName, type InferVariantProps, type LiveTokenSet, type MergeOptions, type ParsedClass, type ParsedClassModifier, type ResolvedThemeTokens, type StateComponentEntry, type StateConfig, type StyledComponentProps, type StyledOptions, type StyledProps, type StyledSystemConfig, type StyledSystemInstance, type SubComponentEntry, type SubComponentMap, type SubComponentProps, type SystemComponentConfig, type SystemComponentFactory, type SystemTokenMap, type ThemeConfig, type ThemeTokenMap, type TokenMap, type TokenSubscriber, type TwComponentFactory, type TwObject, type TwStyledComponent, type TwSubComponent, type TwTagFactory, type TwTagFactoryAny, type VariantLiterals, cn, createComponent, createStyledSystem, createTheme, createTwMerge, cssVar, cv, cx, cxm, generateContainerCss, generateStateCss, getAllSubComponents, getContainerRegistry, getStateRegistry, getSubComponent, mergeWithRules, processContainer, processState, registerSubComponent, registerVariantTable, resolveStyledClassName, server, styled, t, tw, twMerge, twVar, v4Tokens, withSubComponents };
817
+ export { type ComponentConfig, type ContainerConfig, type ContainerEntry, type CvFn, type HtmlTagName, type InferVariantProps, type MergeOptions, type ParsedClass, type ParsedClassModifier, type ResolvedThemeTokens, type StateComponentEntry, type StateConfig, type StyledComponentProps, type StyledOptions, type StyledProps, type StyledSystemConfig, type StyledSystemInstance, type SubComponentEntry, type SubComponentMap, type SubComponentProps, type SystemComponentConfig, type SystemComponentFactory, type SystemTokenMap, type ThemeConfig, type ThemeTokenMap, type TwComponentFactory, type TwObject, type TwStyledComponent, type TwSubComponent, type TwTagFactory, type TwTagFactoryAny, type VariantLiterals, cn, createComponent, createStyledSystem, createTheme, createTwMerge, cssVar, cv, cx, cxm, generateContainerCss, generateStateCss, getAllSubComponents, getContainerRegistry, getStateRegistry, getSubComponent, mergeWithRules, processContainer, processState, registerSubComponent, registerVariantTable, resolveStyledClassName, server, styled, t, tw, twMerge, twVar, v4Tokens, withSubComponents };
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
  }
@@ -1236,6 +1236,9 @@ function makeTag(tag) {
1236
1236
  });
1237
1237
  }
1238
1238
  var HTML_TAGS = [
1239
+ "html",
1240
+ "head",
1241
+ "body",
1239
1242
  "div",
1240
1243
  "section",
1241
1244
  "article",
@@ -1488,14 +1491,20 @@ function cv(config, componentId) {
1488
1491
  }
1489
1492
  }
1490
1493
  }
1491
- 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 = {}) => {
1492
1501
  let result;
1493
1502
  const variantKeys = Object.keys(config.variants ?? {});
1494
1503
  if (componentId) {
1495
1504
  const generated = lookupGenerated(
1496
1505
  componentId,
1497
1506
  props,
1498
- config.defaultVariants,
1507
+ stringifiedDefaults,
1499
1508
  variantKeys
1500
1509
  );
1501
1510
  result = generated ?? resolveVariantsNative(config, props);
@@ -1503,7 +1512,7 @@ function cv(config, componentId) {
1503
1512
  result = resolveVariantsNative(config, props);
1504
1513
  }
1505
1514
  return props.className ? twMerge(result, props.className) : result;
1506
- };
1515
+ });
1507
1516
  }
1508
1517
 
1509
1518
  // packages/domain/core/src/cx.ts