tailwind-to-style 1.1.1 → 1.1.3
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/index.js +23 -8
- package/package.json +1 -1
package/index.js
CHANGED
|
@@ -5711,25 +5711,40 @@ const breakpoints = {
|
|
|
5711
5711
|
};
|
|
5712
5712
|
|
|
5713
5713
|
function tws(classNames, convertToJson) {
|
|
5714
|
+
if (
|
|
5715
|
+
[
|
|
5716
|
+
!classNames,
|
|
5717
|
+
typeof classNames !== "string",
|
|
5718
|
+
classNames.trim() === "",
|
|
5719
|
+
].includes(true)
|
|
5720
|
+
) {
|
|
5721
|
+
return convertToJson ? {} : "";
|
|
5722
|
+
}
|
|
5723
|
+
|
|
5714
5724
|
const cssString = generateTailwindCssString().replace(/\s\s+/g, " ");
|
|
5715
5725
|
const cssObject = convertCssToObject(cssString);
|
|
5716
5726
|
|
|
5717
|
-
const classes = classNames.
|
|
5727
|
+
const classes = classNames.match(/[\w-]+(?:\[[^\]]+\])?|\w+/g);
|
|
5728
|
+
|
|
5718
5729
|
let cssResult = classes.map((className) => {
|
|
5719
5730
|
if (cssObject[className]) {
|
|
5720
5731
|
return cssObject[className];
|
|
5721
5732
|
} else if (className.includes("[")) {
|
|
5722
|
-
const
|
|
5723
|
-
|
|
5724
|
-
|
|
5725
|
-
|
|
5726
|
-
|
|
5727
|
-
|
|
5728
|
-
|
|
5733
|
+
const match = className.match(/\[([^\]]+)\]/);
|
|
5734
|
+
if (match) {
|
|
5735
|
+
const customValue = match[1];
|
|
5736
|
+
const baseKey = className.split("[")[0];
|
|
5737
|
+
if (cssObject[`${baseKey}custom`]) {
|
|
5738
|
+
return cssObject[`${baseKey}custom`].replace(
|
|
5739
|
+
/custom_value/g,
|
|
5740
|
+
customValue
|
|
5741
|
+
);
|
|
5742
|
+
}
|
|
5729
5743
|
}
|
|
5730
5744
|
}
|
|
5731
5745
|
return "";
|
|
5732
5746
|
});
|
|
5747
|
+
|
|
5733
5748
|
cssResult = replaceAndRemoveCSSVariables(cssResult.join(""));
|
|
5734
5749
|
cssResult = inlineStyleToJson(cssResult);
|
|
5735
5750
|
|