@@ -8,6 +8,7 @@ import type { ParsedModifier, StateModifierType } from "../../../parser/index.js
88import {
99 expandSchemeModifier ,
1010 isColorSchemeModifier ,
11+ isDirectionalModifier ,
1112 isPlatformModifier ,
1213 isSchemeModifier ,
1314 isStateModifier ,
@@ -19,6 +20,7 @@ import { generateStyleKey } from "../../../utils/styleKey.js";
1920import { getTargetStyleProp , isAttributeSupported } from "../../utils/attributeMatchers.js" ;
2021import { processColorSchemeModifiers } from "../../utils/colorSchemeModifierProcessing.js" ;
2122import { getComponentModifierSupport , getStatePropertyForModifier } from "../../utils/componentSupport.js" ;
23+ import { processDirectionalModifiers } from "../../utils/directionalModifierProcessing.js" ;
2224import { processDynamicExpression } from "../../utils/dynamicProcessing.js" ;
2325import { createStyleFunction , processStaticClassNameWithModifiers } from "../../utils/modifierProcessing.js" ;
2426import { processPlatformModifiers } from "../../utils/platformModifierProcessing.js" ;
@@ -107,6 +109,7 @@ export function jsxAttributeVisitor(
107109 const placeholderModifiers = modifierClasses . filter ( ( m ) => m . modifier === "placeholder" ) ;
108110 const platformModifiers = modifierClasses . filter ( ( m ) => isPlatformModifier ( m . modifier ) ) ;
109111 const colorSchemeModifiers = modifierClasses . filter ( ( m ) => isColorSchemeModifier ( m . modifier ) ) ;
112+ const directionalModifiers = modifierClasses . filter ( ( m ) => isDirectionalModifier ( m . modifier ) ) ;
110113 const stateModifiers = modifierClasses . filter (
111114 ( m ) => isStateModifier ( m . modifier ) && m . modifier !== "placeholder" ,
112115 ) ;
@@ -138,6 +141,7 @@ export function jsxAttributeVisitor(
138141 // Handle combination of modifiers
139142 const hasPlatformModifiers = platformModifiers . length > 0 ;
140143 const hasColorSchemeModifiers = colorSchemeModifiers . length > 0 ;
144+ const hasDirectionalModifiers = directionalModifiers . length > 0 ;
141145 const hasStateModifiers = stateModifiers . length > 0 ;
142146 const hasBaseClasses = baseClasses . length > 0 ;
143147
@@ -160,14 +164,14 @@ export function jsxAttributeVisitor(
160164 }
161165
162166 // If we have multiple modifier types, combine them in an array expression
163- // For state modifiers, wrap in arrow function; for color scheme, they're just conditionals
164- if ( hasStateModifiers && ( hasPlatformModifiers || hasColorSchemeModifiers ) ) {
167+ // For state modifiers, wrap in arrow function; for color scheme and directional , they're just conditionals
168+ if ( hasStateModifiers && ( hasPlatformModifiers || hasColorSchemeModifiers || hasDirectionalModifiers ) ) {
165169 // Get the JSX opening element for component support checking
166170 const jsxOpeningElement = path . parent ;
167171 const componentSupport = getComponentModifierSupport ( jsxOpeningElement , t ) ;
168172
169173 if ( componentSupport ) {
170- // Build style array: [baseStyle, Platform.select(...), colorSchemeConditionals, stateConditionals]
174+ // Build style array: [baseStyle, Platform.select(...), colorSchemeConditionals, directionalConditionals, stateConditionals]
171175 const styleArrayElements : BabelTypes . Expression [ ] = [ ] ;
172176
173177 // Add base classes
@@ -179,7 +183,7 @@ export function jsxAttributeVisitor(
179183 if ( hasRuntimeDimensions ( baseStyleObject ) ) {
180184 throw path . buildCodeFrameError (
181185 `w-screen and h-screen cannot be combined with modifiers. ` +
182- `Found: "${ baseClassName } " with state, platform, or color scheme modifiers. ` +
186+ `Found: "${ baseClassName } " with state, platform, color scheme, or directional modifiers. ` +
183187 `Use w-screen/h-screen without modifiers instead.` ,
184188 ) ;
185189 }
@@ -215,6 +219,18 @@ export function jsxAttributeVisitor(
215219 styleArrayElements . push ( ...colorSchemeConditionals ) ;
216220 }
217221
222+ // Add directional modifiers as conditionals
223+ if ( hasDirectionalModifiers ) {
224+ const directionalConditionals = processDirectionalModifiers (
225+ directionalModifiers ,
226+ state ,
227+ parseClassName ,
228+ generateStyleKey ,
229+ t ,
230+ ) ;
231+ styleArrayElements . push ( ...directionalConditionals ) ;
232+ }
233+
218234 // Add state modifiers as conditionals
219235 // Group by modifier type
220236 const modifiersByType = new Map < StateModifierType , ParsedModifier [ ] > ( ) ;
@@ -267,9 +283,9 @@ export function jsxAttributeVisitor(
267283 }
268284 }
269285
270- // Handle platform and/or color scheme modifiers (no state modifiers)
271- if ( ( hasPlatformModifiers || hasColorSchemeModifiers ) && ! hasStateModifiers ) {
272- // Build style array/expression: [baseStyle, Platform.select(...), colorSchemeConditionals]
286+ // Handle platform, color scheme, and/or directional modifiers (no state modifiers)
287+ if ( ( hasPlatformModifiers || hasColorSchemeModifiers || hasDirectionalModifiers ) && ! hasStateModifiers ) {
288+ // Build style array/expression: [baseStyle, Platform.select(...), colorSchemeConditionals, directionalConditionals ]
273289 const styleExpressions : BabelTypes . Expression [ ] = [ ] ;
274290
275291 // Add base classes
@@ -281,7 +297,7 @@ export function jsxAttributeVisitor(
281297 if ( hasRuntimeDimensions ( baseStyleObject ) ) {
282298 throw path . buildCodeFrameError (
283299 `w-screen and h-screen cannot be combined with modifiers. ` +
284- `Found: "${ baseClassName } " with platform or color scheme modifiers. ` +
300+ `Found: "${ baseClassName } " with platform, color scheme, or directional modifiers. ` +
285301 `Use w-screen/h-screen without modifiers instead.` ,
286302 ) ;
287303 }
@@ -317,6 +333,18 @@ export function jsxAttributeVisitor(
317333 styleExpressions . push ( ...colorSchemeConditionals ) ;
318334 }
319335
336+ // Add directional modifiers as conditionals
337+ if ( hasDirectionalModifiers ) {
338+ const directionalConditionals = processDirectionalModifiers (
339+ directionalModifiers ,
340+ state ,
341+ parseClassName ,
342+ generateStyleKey ,
343+ t ,
344+ ) ;
345+ styleExpressions . push ( ...directionalConditionals ) ;
346+ }
347+
320348 // Generate style attribute
321349 const styleExpression =
322350 styleExpressions . length === 1 ? styleExpressions [ 0 ] : t . arrayExpression ( styleExpressions ) ;
0 commit comments