tailwind-to-style 1.1.1 → 1.1.2

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 (2) hide show
  1. package/index.js +13 -8
  2. package/package.json +1 -1
package/index.js CHANGED
@@ -5714,22 +5714,27 @@ function tws(classNames, convertToJson) {
5714
5714
  const cssString = generateTailwindCssString().replace(/\s\s+/g, " ");
5715
5715
  const cssObject = convertCssToObject(cssString);
5716
5716
 
5717
- const classes = classNames.split(" ");
5717
+ const classes = classNames.match(/[\w-]+(?:\[[^\]]+\])?|\w+/g);
5718
+
5718
5719
  let cssResult = classes.map((className) => {
5719
5720
  if (cssObject[className]) {
5720
5721
  return cssObject[className];
5721
5722
  } else if (className.includes("[")) {
5722
- const customValue = className.match(/\[([^\]]+)\]/)[1];
5723
- const baseKey = className.split("[")[0];
5724
- if (cssObject[`${baseKey}custom`]) {
5725
- return cssObject[`${baseKey}custom`].replace(
5726
- /custom_value/g,
5727
- customValue
5728
- );
5723
+ const match = className.match(/\[([^\]]+)\]/);
5724
+ if (match) {
5725
+ const customValue = match[1];
5726
+ const baseKey = className.split("[")[0];
5727
+ if (cssObject[`${baseKey}custom`]) {
5728
+ return cssObject[`${baseKey}custom`].replace(
5729
+ /custom_value/g,
5730
+ customValue
5731
+ );
5732
+ }
5729
5733
  }
5730
5734
  }
5731
5735
  return "";
5732
5736
  });
5737
+
5733
5738
  cssResult = replaceAndRemoveCSSVariables(cssResult.join(""));
5734
5739
  cssResult = inlineStyleToJson(cssResult);
5735
5740
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "tailwind-to-style",
3
- "version": "1.1.1",
3
+ "version": "1.1.2",
4
4
  "description": "Convert tailwind classes to inline style",
5
5
  "main": "index.js",
6
6
  "scripts": {