tailwind-to-style 1.1.6 → 1.1.8

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 +57 -19
  2. package/package.json +1 -1
package/index.js CHANGED
@@ -4255,6 +4255,10 @@ function generator$I(configOptions = {}) {
4255
4255
  const key = keyTmp.toLowerCase() !== "default" ? `-${keyTmp}` : "";
4256
4256
  return `
4257
4257
  ${prefix}${key} {
4258
+ --ring-inset: var(--empty,/*!*/ /*!*/);
4259
+ --ring-offset-width: 0px;
4260
+ --ring-offset-color: #fff;
4261
+ --ring-color: rgba(59, 130, 246, 0.5);
4258
4262
  --ring-offset-shadow: var(--ring-inset) 0 0 0 var(--ring-offset-width) var(--ring-offset-color);
4259
4263
  --ring-shadow: var(--ring-inset) 0 0 0 calc(${value} + var(--ring-offset-width)) var(--ring-color);
4260
4264
  box-shadow: var(--ring-offset-shadow), var(--ring-shadow);
@@ -5678,28 +5682,62 @@ function jsonToStyle(json) {
5678
5682
  .join(" ");
5679
5683
  }
5680
5684
 
5681
- function replaceAndRemoveCSSVariables(styleString) {
5682
- const customProperties = {};
5683
- const variableRegex = /--([\w-]+):\s*([^;]+);/g;
5684
- let match;
5685
+ function separateAndResolveCSS(arr) {
5686
+ const cssProperties = [];
5687
+ const cssVariables = [];
5688
+ const variableMap = {};
5689
+
5690
+ arr.forEach((item) => {
5691
+ const declarations = item
5692
+ .split(";")
5693
+ .map((decl) => decl.trim())
5694
+ .filter((decl) => decl);
5695
+
5696
+ declarations.forEach((declaration) => {
5697
+ if (declaration.startsWith("--")) {
5698
+ const [key, value] = declaration.split(":").map((part) => part.trim());
5699
+ variableMap[key] = value;
5700
+ cssVariables.push(declaration + ";");
5701
+ } else {
5702
+ cssProperties.push(declaration + ";");
5703
+ }
5704
+ });
5705
+ });
5685
5706
 
5686
- while ((match = variableRegex.exec(styleString)) !== null) {
5687
- const [, variableName, value] = match;
5688
- customProperties[variableName] = value.trim();
5707
+ function resolveVariable(value) {
5708
+ return value.replace(/var\((--[\w-]+)\)/g, (_, varName) => {
5709
+ if (variableMap[varName]) {
5710
+ return resolveVariable(variableMap[varName]);
5711
+ }
5712
+ return `var(${varName})`;
5713
+ });
5689
5714
  }
5690
5715
 
5691
- let updatedStyleString = styleString.replace(
5692
- /var\(--([\w-]+)\)/g,
5693
- (_, variableName) => {
5694
- return customProperties[variableName] || `var(--${variableName})`;
5695
- }
5696
- );
5716
+ const resolvedVariables = cssVariables.map((variable) => {
5717
+ const [key, value] = variable.split(":").map((part) => part.trim());
5718
+ const resolvedValue = resolveVariable(value.slice(0, -1));
5719
+ return `${key}: ${resolvedValue};`;
5720
+ });
5697
5721
 
5698
- updatedStyleString = updatedStyleString
5699
- .replace(/--[\w-]+:\s*[^;]+;/g, "")
5700
- .trim();
5722
+ const uniqueVariables = [
5723
+ ...new Map(
5724
+ resolvedVariables.reverse().map((variable) => {
5725
+ const key = variable.split(":")[0].trim();
5726
+ return [key, variable];
5727
+ })
5728
+ ).values(),
5729
+ ].reverse();
5730
+
5731
+ uniqueVariables.forEach((variable) => {
5732
+ const [key, value] = variable.split(":").map((part) => part.trim());
5733
+ variableMap[key] = value.slice(0, -1);
5734
+ });
5735
+
5736
+ const resolvedCSSProperties = cssProperties.map((property) =>
5737
+ resolveVariable(property)
5738
+ );
5701
5739
 
5702
- return updatedStyleString;
5740
+ return resolvedCSSProperties;
5703
5741
  }
5704
5742
 
5705
5743
  const breakpoints = {
@@ -5745,8 +5783,8 @@ function tws(classNames, convertToJson) {
5745
5783
  return "";
5746
5784
  });
5747
5785
 
5748
- cssResult = replaceAndRemoveCSSVariables(cssResult.join(""));
5749
- cssResult = inlineStyleToJson(cssResult);
5786
+ cssResult = separateAndResolveCSS(cssResult);
5787
+ cssResult = inlineStyleToJson(cssResult.join(""));
5750
5788
 
5751
5789
  if (!convertToJson) {
5752
5790
  cssResult = jsonToStyle(cssResult);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "tailwind-to-style",
3
- "version": "1.1.6",
3
+ "version": "1.1.8",
4
4
  "description": "Convert tailwind classes to inline style",
5
5
  "main": "index.js",
6
6
  "scripts": {