tailwind-to-style 1.1.7 → 1.1.9

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 +39 -59
  2. package/package.json +1 -1
package/index.js CHANGED
@@ -1,4 +1,4 @@
1
- 'use strict';
1
+ "use strict";
2
2
 
3
3
  const theme = {
4
4
  accentColor: ({ theme }) => ({
@@ -1375,7 +1375,8 @@ function generator$2l(configOptions = {}) {
1375
1375
  `
1376
1376
  );
1377
1377
  return cssString;
1378
- });
1378
+ }
1379
+ );
1379
1380
 
1380
1381
  return responsiveCssString;
1381
1382
  }
@@ -2153,7 +2154,8 @@ function generator$1Y(configOptions = {}) {
2153
2154
  return str;
2154
2155
  });
2155
2156
  return cssString;
2156
- });
2157
+ }
2158
+ );
2157
2159
 
2158
2160
  return responsiveCssString;
2159
2161
  }
@@ -2262,7 +2264,8 @@ function generator$1U(configOptions = {}) {
2262
2264
  `
2263
2265
  );
2264
2266
  return cssString;
2265
- });
2267
+ }
2268
+ );
2266
2269
 
2267
2270
  return responsiveCssString;
2268
2271
  }
@@ -4255,6 +4258,10 @@ function generator$I(configOptions = {}) {
4255
4258
  const key = keyTmp.toLowerCase() !== "default" ? `-${keyTmp}` : "";
4256
4259
  return `
4257
4260
  ${prefix}${key} {
4261
+ --ring-inset: var(--empty,/*!*/ /*!*/);
4262
+ --ring-offset-width: 0px;
4263
+ --ring-offset-color: #fff;
4264
+ --ring-color: rgba(59, 130, 246, 0.5);
4258
4265
  --ring-offset-shadow: var(--ring-inset) 0 0 0 var(--ring-offset-width) var(--ring-offset-color);
4259
4266
  --ring-shadow: var(--ring-inset) 0 0 0 calc(${value} + var(--ring-offset-width)) var(--ring-color);
4260
4267
  box-shadow: var(--ring-offset-shadow), var(--ring-shadow);
@@ -4825,7 +4832,8 @@ function generator$p(configOptions = {}) {
4825
4832
  `
4826
4833
  );
4827
4834
  return cssString;
4828
- });
4835
+ }
4836
+ );
4829
4837
 
4830
4838
  return responsiveCssString;
4831
4839
  }
@@ -5666,23 +5674,8 @@ function inlineStyleToJson(styleString) {
5666
5674
  return styleObject;
5667
5675
  }
5668
5676
 
5669
- function jsonToStyle(json) {
5670
- return Object.entries(json)
5671
- .map(([key, value]) => {
5672
- const kebabCaseKey = key.replace(
5673
- /[A-Z]/g,
5674
- (letter) => `-${letter.toLowerCase()}`
5675
- );
5676
- return `${kebabCaseKey}: ${value};`;
5677
- })
5678
- .join(" ");
5679
- }
5680
-
5681
5677
  function separateAndResolveCSS(arr) {
5682
- const cssProperties = [];
5683
- const cssVariables = [];
5684
- const variableMap = {};
5685
-
5678
+ const cssProperties = {};
5686
5679
  arr.forEach((item) => {
5687
5680
  const declarations = item
5688
5681
  .split(";")
@@ -5690,50 +5683,38 @@ function separateAndResolveCSS(arr) {
5690
5683
  .filter((decl) => decl);
5691
5684
 
5692
5685
  declarations.forEach((declaration) => {
5693
- if (declaration.startsWith("--")) {
5694
- const [key, value] = declaration.split(":").map((part) => part.trim());
5695
- variableMap[key] = value;
5696
- cssVariables.push(declaration + ";");
5697
- } else {
5698
- cssProperties.push(declaration + ";");
5699
- }
5686
+ const [key, value] = declaration.split(":").map((part) => part.trim());
5687
+ cssProperties[key] = value;
5700
5688
  });
5701
5689
  });
5702
5690
 
5703
- function resolveVariable(value) {
5704
- return value.replace(/var\((--[\w-]+)\)/g, (_, varName) => {
5705
- if (variableMap[varName]) {
5706
- return resolveVariable(variableMap[varName]);
5691
+ const resolvedProperties = { ...cssProperties };
5692
+
5693
+ const resolveValue = (value, variables) => {
5694
+ return value.replace(
5695
+ /var\((--[a-zA-Z0-9-]+)(?:,\s*([^\)]+))?\)/g,
5696
+ (match, variable, fallback) => {
5697
+ return variables[variable] || fallback || match;
5707
5698
  }
5708
- return `var(${varName})`;
5709
- });
5710
- }
5699
+ );
5700
+ };
5711
5701
 
5712
- const resolvedVariables = cssVariables.map((variable) => {
5713
- const [key, value] = variable.split(":").map((part) => part.trim());
5714
- const resolvedValue = resolveVariable(value.slice(0, -1));
5715
- return `${key}: ${resolvedValue};`;
5702
+ Object.keys(resolvedProperties).forEach((key) => {
5703
+ resolvedProperties[key] = resolveValue(
5704
+ resolvedProperties[key],
5705
+ resolvedProperties
5706
+ );
5716
5707
  });
5717
5708
 
5718
- const uniqueVariables = [
5719
- ...new Map(
5720
- resolvedVariables.reverse().map((variable) => {
5721
- const key = variable.split(":")[0].trim();
5722
- return [key, variable];
5723
- })
5724
- ).values(),
5725
- ].reverse();
5726
-
5727
- uniqueVariables.forEach((variable) => {
5728
- const [key, value] = variable.split(":").map((part) => part.trim());
5729
- variableMap[key] = value.slice(0, -1);
5709
+ Object.keys(resolvedProperties).forEach((key) => {
5710
+ if (key.startsWith("--")) {
5711
+ delete resolvedProperties[key];
5712
+ }
5730
5713
  });
5731
5714
 
5732
- const resolvedCSSProperties = cssProperties.map((property) =>
5733
- resolveVariable(property)
5734
- );
5735
-
5736
- return resolvedCSSProperties;
5715
+ return Object.entries(resolvedProperties)
5716
+ .map(([key, value]) => `${key}: ${value};`)
5717
+ .join(" ");
5737
5718
  }
5738
5719
 
5739
5720
  const breakpoints = {
@@ -5780,10 +5761,9 @@ function tws(classNames, convertToJson) {
5780
5761
  });
5781
5762
 
5782
5763
  cssResult = separateAndResolveCSS(cssResult);
5783
- cssResult = inlineStyleToJson(cssResult.join(""));
5784
5764
 
5785
- if (!convertToJson) {
5786
- cssResult = jsonToStyle(cssResult);
5765
+ if (convertToJson) {
5766
+ cssResult = inlineStyleToJson(cssResult);
5787
5767
  }
5788
5768
 
5789
5769
  return cssResult;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "tailwind-to-style",
3
- "version": "1.1.7",
3
+ "version": "1.1.9",
4
4
  "description": "Convert tailwind classes to inline style",
5
5
  "main": "index.js",
6
6
  "scripts": {