stillwind 0.12.0 → 0.13.0

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.
Files changed (88) hide show
  1. package/CHANGELOG.md +55 -0
  2. package/README.md +1 -1
  3. package/css/builtin-utilities/tw-borders.css +59 -59
  4. package/css/builtin-utilities/tw-effects.css +53 -53
  5. package/css/builtin-utilities/tw-typography.css +13 -13
  6. package/dist/class-object-C87DR3v2.js +6 -0
  7. package/dist/class-object-C87DR3v2.js.map +1 -0
  8. package/dist/class-object-CR0QHoF9.d.ts +10 -0
  9. package/dist/{class-string-DQmH4PZX.d.ts → class-string-BlClX8JK.d.ts} +2 -2
  10. package/dist/class-string-CiNTVHYm.js +6 -0
  11. package/dist/{class-string-CrQnTRvI.js.map → class-string-CiNTVHYm.js.map} +1 -1
  12. package/dist/{formats-Ctf2WFc-.js → formats-DP9B9SG6.js} +228 -113
  13. package/dist/formats-DP9B9SG6.js.map +1 -0
  14. package/dist/{formats-aeLCNAXl.d.ts → formats-NBNjMP5R.d.ts} +34 -12
  15. package/dist/frameworks/alpine.d.ts +5 -3
  16. package/dist/frameworks/alpine.js +3 -1
  17. package/dist/frameworks/alpine.js.map +1 -1
  18. package/dist/frameworks/astro.d.ts +3 -3
  19. package/dist/frameworks/astro.js +1 -1
  20. package/dist/frameworks/lit.d.ts +5 -3
  21. package/dist/frameworks/lit.js +3 -1
  22. package/dist/frameworks/lit.js.map +1 -1
  23. package/dist/frameworks/preact.d.ts +3 -3
  24. package/dist/frameworks/preact.js +1 -1
  25. package/dist/frameworks/qwik.d.ts +3 -3
  26. package/dist/frameworks/qwik.js +1 -1
  27. package/dist/frameworks/react.d.ts +2 -2
  28. package/dist/frameworks/react.js +1 -1
  29. package/dist/frameworks/solid.d.ts +3 -3
  30. package/dist/frameworks/solid.js +1 -1
  31. package/dist/frameworks/svelte.d.ts +3 -3
  32. package/dist/frameworks/svelte.js +1 -1
  33. package/dist/frameworks/vanilla.d.ts +5 -3
  34. package/dist/frameworks/vanilla.js +6 -1
  35. package/dist/frameworks/vanilla.js.map +1 -0
  36. package/dist/frameworks/vue.d.ts +3 -3
  37. package/dist/frameworks/vue.js +1 -1
  38. package/dist/{index-uw1R9t_P.d.ts → index-DpaDcczW.d.ts} +150 -50
  39. package/dist/macro/index.d.ts +2 -2
  40. package/dist/macro/index.js +1 -1
  41. package/dist/runtime/development.d.ts +16 -8
  42. package/dist/runtime/development.js +57 -21
  43. package/dist/runtime/development.js.map +1 -1
  44. package/dist/runtime/index.d.ts +2 -2
  45. package/dist/runtime/index.js +1 -1
  46. package/dist/{style-Bzuux32Y.js → style-dMBm8aX_.js} +6 -3
  47. package/dist/style-dMBm8aX_.js.map +1 -0
  48. package/docs/at-rules/apply.md +1 -1
  49. package/docs/at-rules/custom-variant.md +1 -1
  50. package/docs/at-rules/slot.md +1 -1
  51. package/docs/at-rules/stillwind-property.md +1 -1
  52. package/docs/at-rules/stillwind-registry.md +7 -7
  53. package/docs/at-rules/stillwind-require-properties.md +1 -1
  54. package/docs/at-rules/stillwind-undef-arbitrary-property.md +1 -1
  55. package/docs/at-rules/stillwind-undef-utility.md +1 -1
  56. package/docs/at-rules/stillwind-undef-variant.md +1 -1
  57. package/docs/at-rules/theme.md +5 -5
  58. package/docs/at-rules/utility.md +43 -4
  59. package/docs/at-rules/variant.md +1 -1
  60. package/docs/concepts/css-ordering.md +46 -7
  61. package/docs/concepts/how-styles-compile.md +8 -8
  62. package/docs/errors/SW10006.md +34 -0
  63. package/docs/errors/index.md +1 -0
  64. package/docs/guides/migrating-from-tailwind.md +52 -9
  65. package/docs/guides/reusable-styles.md +2 -2
  66. package/docs/integrations.md +20 -1
  67. package/docs/lints/conflicting-utilities.md +9 -0
  68. package/docs/lints/cyclic-style-order.md +61 -0
  69. package/docs/lints/index.md +14 -10
  70. package/docs/lints/{invalid-cva-config.md → invalid-recipe-config.md} +8 -8
  71. package/docs/lints/{invalid-cva-input.md → invalid-recipe-input.md} +9 -9
  72. package/docs/lints/multiple-style-forwards.md +59 -0
  73. package/docs/lints/partial-utility-override.md +77 -0
  74. package/docs/lints/utility-class-selector.md +72 -0
  75. package/docs/llms.txt +8 -3
  76. package/docs/macros/index.md +1 -1
  77. package/docs/macros/recipe.md +246 -0
  78. package/docs/macros/style.md +62 -0
  79. package/docs/macros/when.md +1 -1
  80. package/package.json +6 -6
  81. package/skills/stillwind/SKILL.md +1 -1
  82. package/dist/class-object-CXvJOi2z.d.ts +0 -9
  83. package/dist/class-object-CzD1oMD_.js +0 -6
  84. package/dist/class-object-CzD1oMD_.js.map +0 -1
  85. package/dist/class-string-CrQnTRvI.js +0 -6
  86. package/dist/formats-Ctf2WFc-.js.map +0 -1
  87. package/dist/style-Bzuux32Y.js.map +0 -1
  88. package/docs/macros/cva.md +0 -155
@@ -1 +0,0 @@
1
- {"version":3,"file":"formats-Ctf2WFc-.js","names":[],"sources":["../src/runtime/fragment.ts","../src/runtime/shared.ts","../src/runtime/cva.ts","../src/runtime/formats.ts"],"sourcesContent":["/**\n * Framework conventions and private channels used to materialize fragments.\n * The three keys must be distinct and belong to the runtime that created the fragments.\n */\nexport type FragmentRuntimeOptions = readonly [\n /** Element prop that receives the combined class text. */\n classProperty: \"class\" | \"className\",\n /** Whether style records become objects or semicolon-separated declaration text. */\n styleFormat: \"object\" | \"string\",\n /** Own fragment property containing class text. */\n stillwindClassKey: symbol,\n /** Own fragment property containing the last authored style payload. */\n stillwindStyleKey: symbol,\n /** Own fragment property containing generated custom properties applied last. */\n stillwindCustomPropertiesKey: symbol,\n];\n\nexport function isObject(value: unknown): value is Record<PropertyKey, unknown> {\n return typeof value === \"object\" && value !== null;\n}\n\n/**\n * Converts a style payload using the framework's style convention.\n *\n * @param payload - Arbitrary payload. String mode accepts text and objects whose entries become declarations.\n * @param styleFormat - Object mode returns the payload unchanged; string mode serializes object entries in order.\n * @returns The payload, declaration text, or undefined for an unsupported string-mode payload.\n */\nexport function serializeStyle(payload: unknown, styleFormat: \"object\" | \"string\"): unknown {\n if (styleFormat === \"string\") {\n if (typeof payload === \"string\") {\n return payload;\n }\n if (isObject(payload)) {\n return Object.entries(payload)\n .map(([name, value]) => `${name}:${String(value)}`)\n .join(\";\");\n }\n return undefined;\n }\n return payload;\n}\n\n/**\n * Materializes class and style fragments without mutating the inputs.\n *\n * @param options - Framework conventions and the keys of the runtime that created the fragments.\n * @param values - Fragments or nested arrays.\n * Nonobjects are ignored. Materialized bases must first be converted with `toFragment`.\n * @returns Props with classes joined in traversal order. The last non-null fragment\n * style supplies inline style, and generated custom properties are combined and applied\n * last. Fragment symbol channels do not appear in the result.\n */\nexport function mergeFragments(\n options: FragmentRuntimeOptions,\n values: readonly unknown[],\n): Record<string, unknown> {\n const [\n classProperty,\n styleFormat,\n stillwindClassKey,\n stillwindStyleKey,\n stillwindCustomPropertiesKey,\n ] = options;\n const classes: string[] = [];\n const customProperties: Record<string, string> = {};\n let style: unknown;\n let hasStyle = false;\n\n const collect = (value: unknown): void => {\n if (!value) {\n return;\n }\n if (Array.isArray(value)) {\n for (const element of value) {\n collect(element);\n }\n return;\n }\n if (!isObject(value)) {\n return;\n }\n const fragment =\n Object.hasOwn(value, stillwindClassKey) ||\n Object.hasOwn(value, stillwindStyleKey) ||\n Object.hasOwn(value, stillwindCustomPropertiesKey);\n if (fragment) {\n const custom = value[stillwindCustomPropertiesKey];\n if (isObject(custom)) {\n Object.assign(customProperties, custom);\n }\n const contribution = value[stillwindClassKey];\n if (typeof contribution === \"string\" && contribution.length > 0) {\n classes.push(contribution);\n }\n if (Object.hasOwn(value, stillwindStyleKey)) {\n const payload = value[stillwindStyleKey];\n if (payload !== undefined && payload !== null) {\n style = payload;\n hasStyle = true;\n }\n }\n }\n };\n\n for (const value of values) {\n collect(value);\n }\n\n const result: Record<string, unknown> = {};\n if (classes.length > 0) {\n result[classProperty] = classes.join(\" \");\n }\n if (hasStyle) {\n const materialized = serializeStyle(style, styleFormat);\n if (materialized !== undefined) {\n result.style = materialized;\n }\n }\n if (Object.keys(customProperties).length > 0) {\n result.style =\n styleFormat === \"string\"\n ? [serializeStyle(result.style, styleFormat), serializeStyle(customProperties, styleFormat)]\n .filter(Boolean)\n .join(\";\")\n : { ...(isObject(result.style) ? result.style : {}), ...customProperties };\n }\n return result;\n}\n\n/**\n * Converts a composition base to a fragment that contributes only its class.\n *\n * A base contributes either `class` or `className`, or the class channel of a fragment\n * from this runtime. The receiving output's prop takes precedence unless it is null or\n * undefined. Style payloads and custom properties are ignored.\n *\n * @param options - The receiving framework's prop conventions and fragment keys.\n * @param value - A non-null object containing materialized props or this runtime's\n * fragment channels.\n * @returns A new fragment whose class channel holds the base's class value.\n */\nexport function toFragment(\n options: FragmentRuntimeOptions,\n value: Record<PropertyKey, unknown>,\n): Record<PropertyKey, unknown> {\n const [classProperty, , stillwindClassKey] = options;\n return {\n [stillwindClassKey]: Object.hasOwn(value, stillwindClassKey)\n ? value[stillwindClassKey]\n : (value[classProperty] ?? value[classProperty === \"class\" ? \"className\" : \"class\"]),\n };\n}\n","/**\n * Converts a dynamic value into text for a generated CSS declaration.\n *\n * @param value - CSS text, a number, a URL, or a boolean. URLs are quoted and CSS-escaped. True\n * becomes a space and false becomes `initial`.\n * @returns CSS value text. Strings and numbers are converted with `String`.\n */\nexport function stillwindCssValue(value: URL | string | number | boolean): string {\n if (typeof value === \"boolean\") {\n return value ? \" \" : \"initial\";\n }\n if (value instanceof URL) {\n const escaped = value.href.replace(\n /[\"\\\\\\n\\r\\f]/g,\n (character) => `\\\\${character.codePointAt(0)!.toString(16)} `,\n );\n return `url(\"${escaped}\")`;\n }\n return String(value);\n}\n\n/**\n * Flattens class contributions and joins nonempty values with spaces.\n *\n * @param values - Strings, numbers, bigints, nested arrays, or objects whose truthy values enable\n * their keys. Other values are ignored.\n * @returns Class text in contribution order, without deduplication.\n */\nexport function stillwindClsx(...values: readonly unknown[]): string {\n return values.flatMap(flatten).filter(Boolean).join(\" \");\n}\n\n/**\n * Escapes text for use as one CSS identifier.\n *\n * @param value - Unescaped identifier text.\n * @returns `CSS.escape` output when available, otherwise escaped text with NUL replaced by U+FFFD.\n */\nexport function stillwindEscapedIdentifier(value: string): string {\n if (typeof CSS !== \"undefined\" && typeof CSS.escape === \"function\") {\n return CSS.escape(value);\n }\n const characters = Array.from(value);\n let escaped = \"\";\n for (const [index, character] of characters.entries()) {\n const code = character.codePointAt(0)!;\n const isDigit = code >= 48 && code <= 57;\n const isControl = (code >= 1 && code <= 31) || code === 127;\n if (code === 0) {\n escaped += \"\\uFFFD\";\n } else if (isControl) {\n escaped += `\\\\${code.toString(16)} `;\n } else if (index === 0 && isDigit) {\n escaped += `\\\\${code.toString(16)} `;\n } else if (index === 0 && character === \"-\" && characters.length === 1) {\n escaped += \"\\\\-\";\n } else if (index === 1 && isDigit && characters[0] === \"-\") {\n escaped += `\\\\${code.toString(16)} `;\n } else if (\n isDigit ||\n (code >= 65 && code <= 90) ||\n (code >= 97 && code <= 122) ||\n code === 45 ||\n code === 95 ||\n code >= 128\n ) {\n escaped += character;\n } else {\n escaped += `\\\\${character}`;\n }\n }\n return escaped;\n}\n\n/**\n * Builds a CSS identifier for one keyed view transition.\n *\n * @param value - Nonempty class token or an object whose `v` property contains that token.\n * @param key - Key appended to the token after a hyphen using `String`.\n * @returns The combined token and key escaped as a CSS identifier.\n */\nexport function stillwindViewTransitionName(value: unknown, key: string | number): string {\n const token = typeof value === \"string\" ? value : (value as { v: string }).v;\n return stillwindEscapedIdentifier(`${token}-${String(key)}`);\n}\n\n/**\n * Expands one class contribution into strings without splitting class text.\n *\n * @param value - Class text, a number, a bigint, a nested array, or an object with enabled class\n * keys.\n * @returns Strings in traversal or object-entry order. Unsupported values produce an empty list.\n */\nfunction flatten(value: unknown): string[] {\n if (typeof value === \"string\" || typeof value === \"number\" || typeof value === \"bigint\") {\n return [String(value)];\n }\n if (Array.isArray(value)) {\n return value.flatMap(flatten);\n }\n if (value && typeof value === \"object\") {\n return Object.entries(value as Record<string, unknown>)\n .filter(([, enabled]) => Boolean(enabled))\n .map(([name]) => name);\n }\n return [];\n}\n","import { mergeFragments, type FragmentRuntimeOptions } from \"./fragment.ts\";\nimport { stillwindClsx } from \"./shared.ts\";\n\n/** Compiler-produced class text, fragment channels, or nested fragment arrays. */\nexport type CvaValue = string | boolean | null | undefined | object;\n\n/** Compiled configuration whose structure is immutable after factory creation. */\nexport interface CompiledCvaConfig {\n readonly variants?: Readonly<Record<string, Readonly<Record<string, CvaValue>>>>;\n readonly defaultVariants?: Readonly<Record<string, string | number | boolean | null | undefined>>;\n readonly compoundVariants?: readonly Readonly<Record<string, unknown>>[];\n}\n\nfunction optionKey(value: unknown): unknown {\n return typeof value === \"boolean\" ? String(value) : value === 0 ? \"0\" : value;\n}\n\n/**\n * Creates a selector over compiler-produced values using the supplied framework channels.\n * Values are captured at creation. Each call returns fresh props without mutating inputs.\n * Undefined selections keep defaults; null suppresses an option. Matching compounds\n * contribute in array order, followed by external class and className inputs.\n *\n * @param options - Framework conventions and the keys used by compiled fragments.\n * @param base - Compiled styles included in every selection.\n * @param config - Immutable compiled option maps, defaults, and compound conditions.\n * @param classes - Concatenates external class inputs. Development calls supply validation.\n * @param merge - Materializes selected fragments. Development calls supply validation.\n * @returns A selector that materializes class and optional style props without private symbols.\n */\nexport function createCva(\n options: FragmentRuntimeOptions,\n base: CvaValue,\n config: CompiledCvaConfig = {},\n classes: typeof stillwindClsx = stillwindClsx,\n merge: typeof mergeFragments = mergeFragments,\n): (props?: Readonly<Record<string, unknown>>) => Record<string, unknown> {\n const axes = Object.keys(config.variants ?? {});\n const compounds = (config.compoundVariants ?? []).map((compound) => ({\n conditions: Object.entries(compound).filter(([key]) => key !== \"class\" && key !== \"className\"),\n class: compound.class as CvaValue,\n className: compound.className as CvaValue,\n }));\n const fragment = (value: CvaValue): unknown =>\n typeof value === \"string\" ? { [options[2]]: value } : value;\n\n return (props = {}) => {\n const values: unknown[] = [fragment(base)];\n const variants = config.variants;\n if (variants) {\n for (const axis of axes) {\n const supplied = props[axis];\n if (supplied === null) {\n continue;\n }\n const key = optionKey(supplied) || optionKey(config.defaultVariants?.[axis]);\n const choices = variants[axis]!;\n if ((typeof key === \"string\" || typeof key === \"number\") && Object.hasOwn(choices, key)) {\n values.push(fragment(choices[key]));\n }\n }\n const resolved = {\n ...config.defaultVariants,\n ...Object.fromEntries(Object.entries(props).filter(([, value]) => value !== undefined)),\n };\n for (const compound of compounds) {\n if (\n compound.conditions.every(([key, expected]) =>\n Array.isArray(expected) ? expected.includes(resolved[key]) : expected === resolved[key],\n )\n ) {\n values.push(fragment(compound.class), fragment(compound.className));\n }\n }\n }\n values.push({ [options[2]]: classes(props.class, props.className) });\n return merge(options, values);\n };\n}\n","/**\n * Fragment keys and production operations for each output format.\n *\n * Each format owns distinct symbol keys, so a fragment must be materialized by the format that\n * created it. Export names start with the format name because all formats share one entrypoint.\n */\n\nimport { createCva, type CompiledCvaConfig, type CvaValue } from \"./cva.ts\";\nimport {\n mergeFragments,\n serializeStyle,\n toFragment,\n type FragmentRuntimeOptions,\n} from \"./fragment.ts\";\n\nexport const stillwindClassObjectClassKey = /* @__PURE__ */ Symbol(\"stillwind.class-object.class\");\n\nexport const stillwindClassObjectStyleKey = /* @__PURE__ */ Symbol(\"stillwind.class-object.style\");\n\nexport const stillwindClassObjectCustomPropertiesKey = /* @__PURE__ */ Symbol(\n \"stillwind.class-object.custom-properties\",\n);\n\nexport const classObjectOptions: FragmentRuntimeOptions = [\n \"class\",\n \"object\",\n stillwindClassObjectClassKey,\n stillwindClassObjectStyleKey,\n stillwindClassObjectCustomPropertiesKey,\n];\n\n/** Materializes ordered fragments with `class` and object styles. */\nexport function stillwindClassObjectMerge(...values: readonly unknown[]): Record<string, unknown> {\n return mergeFragments(classObjectOptions, values);\n}\n\n/** Converts either class prop of a composition base to a class-only fragment. */\nexport function stillwindClassObjectToFragment(\n value: Record<PropertyKey, unknown>,\n): Record<PropertyKey, unknown> {\n return toFragment(classObjectOptions, value);\n}\n\n/** Returns the supplied style payload, or undefined for null or undefined. */\nexport function stillwindClassObjectStyleValue(value: unknown): unknown {\n return value == null ? undefined : serializeStyle(value, \"object\");\n}\n\n/** Selects compiled CVA values and returns fresh props with `class` and object styles. */\nexport function stillwindClassObjectCva(base?: CvaValue, config?: CompiledCvaConfig) {\n return createCva(classObjectOptions, base, config);\n}\n\nexport const stillwindClassStringClassKey = /* @__PURE__ */ Symbol(\"stillwind.class-string.class\");\n\nexport const stillwindClassStringStyleKey = /* @__PURE__ */ Symbol(\"stillwind.class-string.style\");\n\nexport const stillwindClassStringCustomPropertiesKey = /* @__PURE__ */ Symbol(\n \"stillwind.class-string.custom-properties\",\n);\n\nexport const classStringOptions: FragmentRuntimeOptions = [\n \"class\",\n \"string\",\n stillwindClassStringClassKey,\n stillwindClassStringStyleKey,\n stillwindClassStringCustomPropertiesKey,\n];\n\n/** Materializes ordered fragments with `class` and string styles. */\nexport function stillwindClassStringMerge(...values: readonly unknown[]): Record<string, unknown> {\n return mergeFragments(classStringOptions, values);\n}\n\n/** Converts either class prop of a composition base to a class-only fragment. */\nexport function stillwindClassStringToFragment(\n value: Record<PropertyKey, unknown>,\n): Record<PropertyKey, unknown> {\n return toFragment(classStringOptions, value);\n}\n\n/** Serializes object style declarations or preserves a string. Other inputs omit style. */\nexport function stillwindClassStringStyleValue(value: unknown): unknown {\n return value == null ? undefined : serializeStyle(value, \"string\");\n}\n\n/** Selects compiled CVA values and returns fresh props with `class` and string styles. */\nexport function stillwindClassStringCva(base?: CvaValue, config?: CompiledCvaConfig) {\n return createCva(classStringOptions, base, config);\n}\n\nexport const stillwindClassNameObjectClassKey = /* @__PURE__ */ Symbol(\n \"stillwind.class-name-object.class\",\n);\n\nexport const stillwindClassNameObjectStyleKey = /* @__PURE__ */ Symbol(\n \"stillwind.class-name-object.style\",\n);\n\nexport const stillwindClassNameObjectCustomPropertiesKey = /* @__PURE__ */ Symbol(\n \"stillwind.class-name-object.custom-properties\",\n);\n\nexport const classNameObjectOptions: FragmentRuntimeOptions = [\n \"className\",\n \"object\",\n stillwindClassNameObjectClassKey,\n stillwindClassNameObjectStyleKey,\n stillwindClassNameObjectCustomPropertiesKey,\n];\n\n/** Materializes ordered fragments with `className` and object styles. */\nexport function stillwindClassNameObjectMerge(\n ...values: readonly unknown[]\n): Record<string, unknown> {\n return mergeFragments(classNameObjectOptions, values);\n}\n\n/** Converts either class prop of a composition base to a class-only fragment. */\nexport function stillwindClassNameObjectToFragment(\n value: Record<PropertyKey, unknown>,\n): Record<PropertyKey, unknown> {\n return toFragment(classNameObjectOptions, value);\n}\n\n/** Returns the supplied style payload, or undefined for null or undefined. */\nexport function stillwindClassNameObjectStyleValue(value: unknown): unknown {\n return value == null ? undefined : serializeStyle(value, \"object\");\n}\n\n/** Selects compiled CVA values and returns fresh props with `className` and object styles. */\nexport function stillwindClassNameObjectCva(base?: CvaValue, config?: CompiledCvaConfig) {\n return createCva(classNameObjectOptions, base, config);\n}\n"],"mappings":";AAiBA,SAAgB,SAAS,OAAuD;CAC9E,OAAO,OAAO,UAAU,YAAY,UAAU;AAChD;;;;;;;;AASA,SAAgB,eAAe,SAAkB,aAA2C;CAC1F,IAAI,gBAAgB,UAAU;EAC5B,IAAI,OAAO,YAAY,UACrB,OAAO;EAET,IAAI,SAAS,OAAO,GAClB,OAAO,OAAO,QAAQ,OAAO,CAAC,CAC3B,KAAK,CAAC,MAAM,WAAW,GAAG,KAAK,GAAG,OAAO,KAAK,GAAG,CAAC,CAClD,KAAK,GAAG;EAEb;CACF;CACA,OAAO;AACT;;;;;;;;;;;AAYA,SAAgB,eACd,SACA,QACyB;CACzB,MAAM,CACJ,eACA,aACA,mBACA,mBACA,gCACE;CACJ,MAAM,UAAoB,CAAC;CAC3B,MAAM,mBAA2C,CAAC;CAClD,IAAI;CACJ,IAAI,WAAW;CAEf,MAAM,WAAW,UAAyB;EACxC,IAAI,CAAC,OACH;EAEF,IAAI,MAAM,QAAQ,KAAK,GAAG;GACxB,KAAK,MAAM,WAAW,OACpB,QA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EA,MAAa,qBAA6C;CACxD;CACA;CACA;CACA;CACA;AACF;;AAGA,SAAgB,0BAA0B,GAAG,QAAqD;CAChG,OAAO,eAAe,oBAAoB,MAAM;AAClD;;AAGA,SAAgB,+BACd,OAC8B;CAC9B,OAAO,WAAW,oBAAoB,KAAK;AAC7C;;AAGA,SAAgB,+BAA+B,OAAyB;CACtE,OAAO,SAAS,OAAO,KAAA,IAAY,eAAe,OAAO,QAAQ;AACnE;;AAGA,SAAgB,wBAAwB,MAAiB,QAA4B;CACnF,OAAO,UAAU,oBAAoB,MAAM,MAAM;AACnD;AAEA,MAAa,mCAAmD,uBAC9D,mCACF;AAEA,MAAa,mCAAmD,uBAC9D,mCACF;AAEA,MAAa,8CAA8D,uBACzE,+CACF;AAEA,MAAa,yBAAiD;CAC5D;CACA;CACA;CACA;CACA;AACF;;AAGA,SAAgB,8BACd,GAAG,QACsB;CACzB,OAAO,eAAe,wBAAwB,MAAM;AACtD;;AAGA,SAAgB,mCACd,OAC8B;CAC9B,OAAO,WAAW,wBAAwB,KAAK;AACjD;;AAGA,SAAgB,mCAAmC,OAAyB;CAC1E,OAAO,SAAS,OAAO,KAAA,IAAY,eAAe,OAAO,QAAQ;AACnE;;AAGA,SAAgB,4BAA4B,MAAiB,QAA4B;CACvF,OAAO,UAAU,wBAAwB,MAAM,MAAM;AACvD"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"style-Bzuux32Y.js","names":[],"sources":["../src/macro/style.ts"],"sourcesContent":["/** Framework macros and the placeholders that the compiler replaces. */\n\nimport type { StyleCssInput, StyleCssOptions } from \"./css.ts\";\nimport type {\n CvaClassProps,\n CvaConfig,\n CvaInput,\n CvaResult,\n CvaSelection,\n CvaVariants,\n} from \"./cva.ts\";\nimport type { CheckedStyleInputs, StyleArgument } from \"./input.ts\";\nimport type { StyleKeyframes, StyleKeyframesDefinition } from \"./keyframes.ts\";\nimport type { StyleOutput, StyleResult } from \"./output.ts\";\nimport type { StyleRefProjection } from \"./projection.ts\";\nimport type { AnchorScope, StyleRef, StyleVariantKey } from \"./refs.ts\";\nimport type { StyleViewTransition, StyleViewTransitionDefinition } from \"./view-transition.ts\";\nimport type { StyleStoredVariant } from \"./when.ts\";\n\n/**\n * Internal use only. The compiler inserts this identity argument in source used by the\n * TypeScript checker. Application code must not construct or pass it.\n *\n * @internal\n */\nexport type StillwindDeclarationIdentity<Id extends string> = {\n readonly __stillwindDeclarationIdentity: Id;\n};\n\n/**\n * Compile-time UI declarations with pure value expressions.\n *\n * Only completed style calls and declaration macros produce reusable values.\n * Projections require their supported style input positions. Ref variants require\n * computed variant keys or utility template substitutions.\n *\n * Each argument expression must return an equivalent value for the same inputs and must\n * not mutate shared data or perform observable effects, including through callees,\n * getters, or value conversion. Calls need no PURE annotation. Functions may mutate\n * fresh local data used only to compute their result.\n *\n * Evaluation order and count are not API guarantees: unused expressions may be omitted\n * and class/value conversions may be combined. Do not rely on exceptions from unused\n * expressions. Read time/randomness and perform I/O, state updates, Hooks, await/yield,\n * imports, JSX, and class initialization outside the macro. Pass their resulting\n * values. Reactive reads stay in the current computation scope and must not be used\n * only to establish a subscription.\n *\n * Names, utility definitions, animation options, and selector/query arguments are\n * static declarations. Dynamic identity selectors and view-transition keys obey the\n * same value-expression contract. Declaration-identity overloads are internal checker\n * metadata.\n */\nexport type StyleMacro<Props = object> = {\n /**\n * Compiles static utility branches and combines them with inline custom\n * properties, external classes, and completed style props.\n *\n * Value expressions must obey the purity contract of {@link StyleMacro}. Projection\n * and animation-use calls must appear directly at supported input positions. Ref\n * variants require computed keys or utility template substitutions.\n *\n * @param inputs - Rule and class inputs in composition order. Custom properties\n * replace earlier values, and classes are concatenated. Utility construction must be\n * static, and invalid utilities or unsupported syntax cause compilation errors.\n * @returns Framework props that may be stored, exported, passed, returned, or spread\n * onto an element. Store this result before passing it to another `style()` call.\n * Direct nested calls are rejected. The class prop is optional. The optional style\n * prop is present in the type when inputs include custom properties, participant\n * naming, or composed props that may contain inline style. CSS is emitted at build\n * time.\n */\n <Inputs extends readonly StyleArgument[]>(\n ...inputs: Inputs & CheckedStyleInputs<Inputs>\n ): StyleResult<string, StyleOutput<Props, Inputs>>;\n\n /**\n * Internal use only. The checker supplies the final identity argument to track the\n * completed props value. Application code must use the overload without it.\n *\n * @param inputs - Style inputs followed by the declaration identity inserted by the compiler.\n * The public overload validates authored inputs. This overload adds identity tracking for the checker.\n * @returns The composed style props with the supplied declaration identity.\n * @internal\n */\n <Inputs extends readonly StyleArgument[], Id extends string>(\n ...inputs: [...Inputs, StillwindDeclarationIdentity<Id>]\n ): StyleResult<Id, StyleOutput<Props, Inputs>>;\n\n /**\n * Declares an unlabeled DOM identity in a binding initializer.\n * Passing the declaration to `style()` attaches its marker to that element.\n *\n * @returns A reusable ref declaration that may be stored, exported, passed, returned,\n * or conditionally selected. Its identity belongs to the declaration site. Repeated\n * evaluation does not allocate new CSS identities.\n */\n ref(): StyleRef;\n\n /**\n * Declares a labeled DOM identity in a binding initializer.\n * Passing the declaration to `style()` attaches its marker to that element.\n *\n * @param label - A string literal used in generated names. Empty text omits the\n * label. Labels do not determine declaration identity.\n * @returns A reusable ref declaration that may be stored, exported, passed, returned,\n * or conditionally selected. Repeated evaluation keeps its identity.\n */\n ref(label: string): StyleRef;\n\n /**\n * Internal use only. The checker supplies identity for an unlabeled ref declaration.\n * Application code must use `ref()` without this argument.\n *\n * @internal\n */\n ref<const Id extends string>(identity: StillwindDeclarationIdentity<Id>): StyleRef<Id>;\n\n /**\n * Internal use only. The checker supplies identity for a labeled ref declaration.\n * Application code must use `ref(label)` without the identity argument.\n *\n * @internal\n */\n ref<const Id extends string>(\n label: string,\n identity: StillwindDeclarationIdentity<Id>,\n ): StyleRef<Id>;\n\n /**\n * Declares a local animation in a binding initializer and assigns its CSS name.\n *\n * Apply it by calling the returned declaration with literal options directly inside\n * `style()`. The animation use cannot be stored for later consumption.\n *\n * @param definition - A direct static object with frame utility strings, optional\n * media/supports replacement bodies, and an optional literal label. Invalid frame\n * syntax or utilities cause compilation errors.\n * @returns A reusable keyframes declaration that may be stored, exported, passed,\n * returned, or conditionally selected. Its identity belongs to the declaration site.\n */\n keyframes(definition: StyleKeyframesDefinition): StyleKeyframes;\n\n /**\n * Internal use only. The checker supplies identity for a keyframes declaration.\n * Application code must use `keyframes(definition)` without the identity argument.\n *\n * @internal\n */\n keyframes<const Id extends string>(\n definition: StyleKeyframesDefinition,\n identity: StillwindDeclarationIdentity<Id>,\n ): StyleKeyframes<Id>;\n\n /**\n * Declares view transition phases in a binding initializer and assigns their class.\n *\n * Pass the declaration to `style()` to mark participants, or call `.for(key)`\n * directly inside `style()` to also name them. The naming use cannot be stored.\n *\n * @param definition - A direct static object with at least one literal phase\n * string and an optional literal label. Invalid phases, utilities, or condition\n * variants cause compilation errors.\n * @returns A reusable transition declaration that may be stored, exported, passed,\n * returned, or conditionally selected. Its identity belongs to the declaration site.\n */\n viewTransition(definition: StyleViewTransitionDefinition): StyleViewTransition;\n\n /**\n * Internal use only. The checker supplies identity for a view transition declaration.\n * Application code must use `viewTransition(definition)` without the identity argument.\n *\n * @internal\n */\n viewTransition<const Id extends string>(\n definition: StyleViewTransitionDefinition,\n identity: StillwindDeclarationIdentity<Id>,\n ): StyleViewTransition<Id>;\n\n /**\n * Stores variant sequences in a binding initializer for later use in `style()`.\n *\n * Use the result as a computed variant key, as a variant segment followed by `:` in\n * a utility template, or in the argument of another `style.when()`. Each use means\n * the same as writing the sequence directly at that position, so the sequence obeys\n * the same rules as a variant key written in `style()`. A use must resolve to one\n * declaration. The compiler replaces the call with `undefined`.\n *\n * With several arguments, the stored variant matches when any argument matches. A\n * use means the same as writing the use once for each argument, in argument order.\n *\n * @param variants - Static variant sequences. Each one is a string literal such as\n * `\"hover:md\"`, a ref variant call or tag with optional `.in()` calls, a container\n * variant, another stored variant, or a template literal whose substitutions are\n * complete variant segments. The final `:` is optional. Invalid sequences produce\n * lint findings.\n * @returns A stored variant that may be stored, exported, imported, and passed.\n */\n when(\n ...variants: [string | StyleVariantKey, ...(string | StyleVariantKey)[]]\n ): StyleStoredVariant;\n\n /**\n * Internal use only. The checker supplies identity for a stored variant declaration.\n * Application code must use `when(...variants)` without the identity argument.\n *\n * @internal\n */\n when<const Id extends string>(\n ...variants: [\n string | StyleVariantKey,\n ...(string | StyleVariantKey)[],\n StillwindDeclarationIdentity<Id>,\n ]\n ): StyleStoredVariant<Id>;\n\n /**\n * Adds anchor-scope without requiring a ref marker on the element.\n *\n * Use this call directly in a style input. The argument follows the same literal\n * keyword or array rules as `ref.asAnchor`. An empty array emits no declaration.\n * The returned projection cannot be stored, exported, passed, or returned for later\n * consumption.\n *\n * @param scope - A literal `\"all\"`, `\"none\"`, or array of refs. All possible\n * identities of each entry are included. Empty arrays and duplicate identities\n * produce lint findings.\n * @returns Rule input that supplies anchor-scope when consumed by `style()`.\n */\n anchorScope(scope: AnchorScope): StyleRefProjection;\n\n /**\n * Returns the media query list of variants, such as for `window.matchMedia()`.\n *\n * The compiler replaces the call with a string, so the result can be stored, exported,\n * and passed. The string has no `@media` or braces. Write the call outside other macro\n * calls.\n *\n * @param variants - String literals of variants whose definitions contain only media\n * conditions, with an optional final `:`. The variants of one argument must all hold,\n * and the arguments are alternatives: `media(\"sm:motion-reduce\", \"print\")` matches a\n * wide screen with reduced motion, or print. An argument that does not resolve or that\n * contains another kind of condition, such as `hover`, matches nothing and produces a\n * lint finding.\n * @returns A media query list. It is `\"not all\"` when no argument can match.\n */\n media(...variants: [string, ...string[]]): string;\n\n /**\n * Returns a stylesheet built from utilities, such as for a shadow root.\n *\n * The compiler replaces the call with a string, so the result can be stored,\n * exported, and passed, for example to `CSSStyleSheet.replaceSync()`. The call adds\n * nothing to the document stylesheet. The string contains the rules and the theme\n * values, keyframes, and custom-property support that they need, placed by the\n * selected `@stillwind-css-template`. It never contains preflight.\n *\n * A selector-replacing variant, such as `host:`, `[:host]:`, or `[button]:`, selects\n * the element that a utility styles. Utilities without one need the `selector`\n * option, or are omitted with a lint finding. Write the call outside other macro\n * calls.\n *\n * @param inputs - Static utility strings, arrays, and variant groups. A final\n * object whose keys are only `template` and `selector` is the options.\n * @returns Stylesheet text.\n */\n css(...inputs: StyleCssInput[]): string;\n\n /**\n * Returns a stylesheet built from utilities, with the options in the last argument.\n *\n * @param inputs - Static utility inputs followed by the options object.\n * @returns Stylesheet text.\n */\n css(...inputs: [...StyleCssInput[], StyleCssOptions]): string;\n\n /**\n * Compiles a CVA definition and returns a function that selects element props.\n * Write the configuration and utility inputs directly in the call. Utility inputs\n * cannot contain `&&` or ternary expressions. Pass runtime conditions as variant\n * selections. Custom properties remain inline and value expressions obey this\n * macro's purity contract.\n *\n * @param base - Optional styles included in every selection.\n * @param config - Static variants, defaults, and compound conditions.\n * @returns A reusable factory returning fresh framework class and style props.\n * Its results cannot be passed to style() for composition.\n */\n cva<Variants extends CvaVariants = Record<never, never>>(\n base?: CvaInput,\n config?: CvaConfig<Variants>,\n ): (props?: CvaSelection<Variants> & CvaClassProps) => CvaResult<Props>;\n};\n\nfunction uncompiledMacroError(name: string): Error {\n return new Error(\n `Stillwind ${name}() is a compile-time macro and cannot run uncompiled. ` +\n \"Configure the Stillwind build integration (placed before JSX transforms) or test runner plugin. \" +\n \"See node_modules/stillwind/docs/integrations.md.\",\n );\n}\n\n/**\n * Internal use only. Builds the placeholder exported by each framework entrypoint.\n * The compiler replaces supported macro calls before the application runs.\n *\n * @returns A fresh callable object with declaration and scope methods. Calling the\n * object or any of these methods throws an Error about missing integration. Creating\n * the placeholder itself does not execute any macro or generate CSS.\n *\n * @internal\n */\nexport function createStyleMacro<Props>(): StyleMacro<Props> {\n return Object.assign(\n (): never => {\n throw uncompiledMacroError(\"style\");\n },\n {\n anchorScope(): never {\n throw uncompiledMacroError(\"style.anchorScope\");\n },\n ref(): never {\n throw uncompiledMacroError(\"style.ref\");\n },\n keyframes(): never {\n throw uncompiledMacroError(\"style.keyframes\");\n },\n viewTransition(): never {\n throw uncompiledMacroError(\"style.viewTransition\");\n },\n when(): never {\n throw uncompiledMacroError(\"style.when\");\n },\n cva(): never {\n throw uncompiledMacroError(\"style.cva\");\n },\n media(): never {\n throw uncompiledMacroError(\"style.media\");\n },\n css(): never {\n throw uncompiledMacroError(\"style.css\");\n },\n },\n );\n}\n"],"mappings":";AAsSA,SAAS,qBAAqB,MAAqB;CACjD,uBAAO,IAAI,MACT,aAAa,KAAK,uMAGpB;AACF;;;;;;;;;;;AAYA,SAAgB,mBAA6C;CAC3D,OAAO,OAAO,aACC;EACX,MAAM,qBAAqB,OAAO;CACpC,GACA;EACE,cAAqB;GACnB,MAAM,qBAAqB,mBAAmB;EAChD;EACA,MAAa;GACX,MAAM,qBAAqB,WAAW;EACxC;EACA,YAAmB;GACjB,MAAM,qBAAqB,iBAAiB;EAC9C;EACA,iBAAwB;GACtB,MAAM,qBAAqB,sBAAsB;EACnD;EACA,OAAc;GACZ,MAAM,qBAAqB,YAAY;EACzC;EACA,MAAa;GACX,MAAM,qBAAqB,WAAW;EACxC;EACA,QAAe;GACb,MAAM,qBAAqB,aAAa;EAC1C;EACA,MAAa;GACX,MAAM,qBAAqB,WAAW;EACxC;CACF,CACF;AACF"}
@@ -1,155 +0,0 @@
1
- ---
2
- title: "style.cva()"
3
- description: "Create a factory that selects compiled styles by option, with the configuration of class-variance-authority."
4
- ---
5
-
6
- # style.cva()
7
-
8
- `style.cva(base?, config?)` creates a factory with the configuration format of
9
- `cva` from [Class Variance Authority](https://cva.style/). The compiler
10
- generates the CSS for every option at build time. Calling the factory selects
11
- the compiled classes for the chosen options and returns props for an element.
12
-
13
- `style.cva()` exists mainly to migrate existing CVA components. For new
14
- components, see [Reusable styles](https://stillwind.dev/docs/guides/reusable-styles).
15
-
16
- ## Example
17
-
18
- ### Source
19
-
20
- ```tsx
21
- import { style } from "stillwind/react";
22
-
23
- export const button = style.cva("inline-flex rounded-md", {
24
- variants: {
25
- size: {
26
- small: "px-2 py-1",
27
- large: "px-4 py-2",
28
- },
29
- },
30
- defaultVariants: {
31
- size: "small",
32
- },
33
- compoundVariants: [
34
- {
35
- size: "large",
36
- class: "font-medium",
37
- },
38
- ],
39
- });
40
-
41
- export const props = button({ size: "large" });
42
- ```
43
-
44
- ### Compiled code
45
-
46
- ```ts
47
- import { stillwindClassNameObjectCva } from "stillwind/runtime";
48
-
49
- export const button = stillwindClassNameObjectCva("sw_6tzpq", {
50
- variants: {
51
- size: {
52
- small: "sw_gzwci",
53
- large: "sw_w6696",
54
- },
55
- },
56
- defaultVariants: {
57
- size: "small",
58
- },
59
- compoundVariants: [
60
- {
61
- size: "large",
62
- class: "sw_v1iw3",
63
- },
64
- ],
65
- });
66
-
67
- export const props = button({ size: "large" });
68
- ```
69
-
70
- ### Generated CSS
71
-
72
-
73
- ```css
74
- .sw_6tzpq {
75
- display: inline-flex;
76
- border-radius: var(--radius-md);
77
- }
78
-
79
- .sw_gzwci {
80
- padding-inline: calc(var(--spacing) * 2);
81
- padding-block: calc(var(--spacing) * 1);
82
- }
83
-
84
- .sw_w6696 {
85
- padding-inline: calc(var(--spacing) * 4);
86
- padding-block: calc(var(--spacing) * 2);
87
- }
88
-
89
- .sw_v1iw3 {
90
- --tw-font-weight: var(--font-weight-medium);
91
- font-weight: var(--font-weight-medium);
92
- }
93
- ```
94
-
95
- ## Configuration
96
-
97
- Write the configuration as an object literal in the call:
98
-
99
- | Field | Value |
100
- | ------------------ | ---------------------------------------------------------------- |
101
- | `variants` | Each option name maps each value to a style |
102
- | `defaultVariants` | The value that each option uses when the call passes `undefined` |
103
- | `compoundVariants` | Entries that add `class` when every listed option matches |
104
-
105
- `class` and `className` cannot be option names, because the factory uses them
106
- for classes from other stylesheets. An option with the values `true` and
107
- `false` accepts booleans.
108
-
109
- Use `VariantProps<typeof button>` from your framework's entrypoint to type the
110
- options.
111
-
112
- ## Style values
113
-
114
- The base and each option value accept utility strings, arrays, objects with
115
- variant keys, `true`, `false`, `null`, `undefined`, and custom properties.
116
-
117
- They do not accept `&&`, ternaries, stored [`style()`](https://stillwind.dev/docs/macros/style)
118
- results, refs, animations, or `class` fields. To choose a style at runtime,
119
- pass a different option to the factory.
120
- [invalid-cva-input](https://stillwind.dev/docs/lints/invalid-cva-input) reports these values, and
121
- [invalid-cva-config](https://stillwind.dev/docs/lints/invalid-cva-config) reports a malformed
122
- configuration.
123
-
124
- A custom property value can be an expression. The factory evaluates it once,
125
- when the factory is created. Custom properties stay in the inline style, so a
126
- later option can replace them.
127
-
128
- ## Calling the factory
129
-
130
- | Option value | Result |
131
- | ------------ | ------------------------------------- |
132
- | `undefined` | Uses the value from `defaultVariants` |
133
- | `null` | Adds nothing for that option |
134
- | A value | Adds the style of that value |
135
-
136
- The result combines, in order: the base, the selected values in the order of
137
- the keys of `variants`, every matching compound variant in array order, and the
138
- `class` or `className` from the call. The option values are not passed to the
139
- element. Each call returns a new props object.
140
-
141
- The factory does not merge utilities at runtime. When two selected styles set
142
- the same property, the compiler's CSS order decides which one wins.
143
-
144
- The props that the factory returns cannot be passed to `style()` as a base.
145
-
146
- ## Generated code
147
-
148
- The compiler creates the factory with a helper from `stillwind/runtime`, such as
149
- `stillwindClassNameObjectCva` for React, together with the compiled class names.
150
- Factory calls stay ordinary JavaScript.
151
- The development build checks the selected values and the classes from other
152
- stylesheets.
153
-
154
- See [Migrating from Tailwind CSS](https://stillwind.dev/docs/guides/migrating-from-tailwind#cva) to
155
- convert existing `cva` calls.