tailwindcss-react-aria-components
Advanced tools
Comparing version
{ | ||
"name": "tailwindcss-react-aria-components", | ||
"version": "3.0.0-nightly-3e1c5183f-250124", | ||
"version": "3.0.0-nightly-3ebf5610a-250604", | ||
"description": "A Tailwind plugin that adds variants for data attributes in React Aria Components", | ||
@@ -19,7 +19,8 @@ "license": "Apache-2.0", | ||
"peerDependencies": { | ||
"tailwindcss": "*" | ||
"tailwindcss": "^4.0.0" | ||
}, | ||
"devDependencies": { | ||
"postcss": "^7.0.0", | ||
"tailwindcss": "^3.2.2" | ||
"@tailwindcss/postcss": "^4.0.0", | ||
"postcss": "^8.0.0", | ||
"tailwindcss": "^4.0.0" | ||
}, | ||
@@ -26,0 +27,0 @@ "publishConfig": { |
@@ -13,2 +13,3 @@ const plugin = require('tailwindcss/plugin'); | ||
'has-submenu', | ||
'has-child-items', | ||
@@ -83,3 +84,3 @@ // States | ||
// If no prefix is specified, we want to avoid overriding native variants on non-RAC components, so we only target elements with the data-rac attribute for those variants. | ||
let getSelector = (prefix, attributeName, attributeValue, hoverOnlyWhenSupported) => { | ||
let getSelector = (prefix, attributeName, attributeValue) => { | ||
let baseSelector = attributeValue ? `[data-${attributeName}="${attributeValue}"]` : `[data-${attributeName}]`; | ||
@@ -90,4 +91,4 @@ let nativeSelector = nativeVariantSelectors.get(attributeName); | ||
let nativeSelectorGenerator = wrappedNativeSelector; | ||
if (nativeSelector === ':hover' && hoverOnlyWhenSupported) { | ||
nativeSelectorGenerator = wrap => `@media (hover: hover) and (pointer: fine) { ${wrap(wrappedNativeSelector)} }`; | ||
if (nativeSelector === ':hover') { | ||
nativeSelectorGenerator = wrap => `@media (hover: hover) { ${wrap(wrappedNativeSelector)} }`; | ||
} | ||
@@ -118,26 +119,8 @@ return [`&:where([data-rac])${baseSelector}`, nativeSelectorGenerator]; | ||
let addVariants = (variantName, selectors, addVariant, matchVariant) => { | ||
let addVariants = (variantName, selectors, addVariant) => { | ||
addVariant(variantName, mapSelector(selectors, selector => wrapSelector(selector, s => s))); | ||
matchVariant( | ||
'group', | ||
(_, {modifier}) => | ||
modifier | ||
? mapSelector(selectors, selector => wrapSelector(selector, s => `:merge(.group\\/${modifier})${s.slice(1)} &`)) | ||
: mapSelector(selectors, selector => wrapSelector(selector, s => `:merge(.group)${s.slice(1)} &`)), | ||
{values: {[variantName]: variantName}} | ||
); | ||
matchVariant( | ||
'peer', | ||
(_, {modifier}) => | ||
modifier | ||
? mapSelector(selectors, selector => wrapSelector(selector, s => `:merge(.peer\\/${modifier})${s.slice(1)} ~ &`)) | ||
: mapSelector(selectors, selector => wrapSelector(selector, s => `:merge(.peer)${s.slice(1)} ~ &`)), | ||
{values: {[variantName]: variantName}} | ||
); | ||
}; | ||
module.exports = plugin.withOptions((options) => (({addVariant, matchVariant, config}) => { | ||
module.exports = plugin.withOptions((options) => (({addVariant}) => { | ||
let prefix = options?.prefix ? `${options.prefix}-` : ''; | ||
let future = config().future; | ||
let hoverOnlyWhenSupported = future === 'all' || future?.hoverOnlyWhenSupported; | ||
@@ -147,7 +130,7 @@ // Enum attributes go first because currently they are all non-interactive states. | ||
attributes.enum[attributeName].forEach( | ||
(attributeValue) => { | ||
(attributeValue, i) => { | ||
let name = shortNames[attributeName] || attributeName; | ||
let variantName = `${prefix}${name}-${attributeValue}`; | ||
let selectors = getSelector(prefix, attributeName, attributeValue, hoverOnlyWhenSupported); | ||
addVariants(variantName, selectors, addVariant, matchVariant); | ||
let selectors = getSelector(prefix, attributeName, attributeValue); | ||
addVariants(variantName, selectors, addVariant, i); | ||
} | ||
@@ -157,9 +140,9 @@ ); | ||
attributes.boolean.forEach((attribute) => { | ||
attributes.boolean.forEach((attribute, i) => { | ||
let variantName = Array.isArray(attribute) ? attribute[0] : attribute; | ||
variantName = `${prefix}${variantName}`; | ||
let attributeName = Array.isArray(attribute) ? attribute[1] : attribute; | ||
let selectors = getSelector(prefix, attributeName, null, hoverOnlyWhenSupported); | ||
addVariants(variantName, selectors, addVariant, matchVariant); | ||
let selectors = getSelector(prefix, attributeName, null); | ||
addVariants(variantName, selectors, addVariant, i); | ||
}); | ||
})); |
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
5875
-78.65%3
50%4
-20%135
-80.93%1
Infinity%