tailwind-to-style 2.5.1 → 2.5.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.
@@ -1,5 +1,5 @@
1
1
  /**
2
- * tailwind-to-style v2.5.0
2
+ * tailwind-to-style v2.5.2
3
3
  * Convert tailwind classes to inline style
4
4
  *
5
5
  * @author Bigetion
@@ -5590,7 +5590,7 @@ var tailwindToStyle = (function (exports) {
5590
5590
  return responsiveCssString;
5591
5591
  }
5592
5592
 
5593
- const patterns$1 = {
5593
+ const transition = {
5594
5594
  transitionNone: {
5595
5595
  regex: /^transition-none$/,
5596
5596
  cssProp: "transition-property",
@@ -5641,7 +5641,7 @@ var tailwindToStyle = (function (exports) {
5641
5641
  };
5642
5642
 
5643
5643
  const patterns = {
5644
- ...patterns$1
5644
+ ...transition
5645
5645
  };
5646
5646
 
5647
5647
  const plugins = {
@@ -5818,6 +5818,33 @@ var tailwindToStyle = (function (exports) {
5818
5818
  return null;
5819
5819
  }
5820
5820
 
5821
+ /**
5822
+ * Resolve all CSS custom properties (var) in a CSS string and output only clear CSS (no custom property)
5823
+ * @param {string} cssString
5824
+ * @returns {string} e.g. 'color: rgba(255,255,255,1); background: #fff;'
5825
+ */
5826
+ function resolveCssToClearCss(cssString) {
5827
+ const customVars = {};
5828
+ const props = {};
5829
+ cssString.split(";").forEach(decl => {
5830
+ const [key, value] = decl.split(":").map(s => s && s.trim());
5831
+ if (!key || !value) return;
5832
+ if (key.startsWith("--")) {
5833
+ customVars[key] = value;
5834
+ } else {
5835
+ props[key] = value;
5836
+ }
5837
+ });
5838
+ // Replace var(--foo) in all values
5839
+ Object.keys(props).forEach(key => {
5840
+ let val = props[key];
5841
+ val = val.replace(/var\((--[a-zA-Z0-9-_]+)\)/g, (m, v) => customVars[v] !== undefined ? customVars[v] : m);
5842
+ props[key] = val;
5843
+ });
5844
+ // Build CSS string
5845
+ return Object.entries(props).map(([k, v]) => `${k}: ${v};`).join(" ");
5846
+ }
5847
+
5821
5848
  // Cache untuk getConfigOptions
5822
5849
  const configOptionsCache = new Map();
5823
5850
  const cacheKey = options => JSON.stringify(options);
@@ -5953,7 +5980,8 @@ var tailwindToStyle = (function (exports) {
5953
5980
  // Cache untuk CSS resolusi
5954
5981
  const cssResolutionCache = new Map();
5955
5982
  function separateAndResolveCSS(arr) {
5956
- // Membuat kunci cache const cacheKey = arr.join('|');
5983
+ // Perbaiki: cacheKey harus unik untuk setiap input array
5984
+ const cacheKey = Array.isArray(arr) ? arr.join('|') : String(arr);
5957
5985
  if (cssResolutionCache.has(cacheKey)) {
5958
5986
  return cssResolutionCache.get(cacheKey);
5959
5987
  }
@@ -5965,13 +5993,13 @@ var tailwindToStyle = (function (exports) {
5965
5993
  if (!item) return;
5966
5994
  const declarations = item.split(";").map(decl => decl.trim()).filter(decl => decl);
5967
5995
  declarations.forEach(declaration => {
5968
- const colonIndex = declaration.indexOf(':');
5996
+ const colonIndex = declaration.indexOf(":");
5969
5997
  if (colonIndex === -1) return;
5970
5998
  const key = declaration.substring(0, colonIndex).trim();
5971
5999
  const value = declaration.substring(colonIndex + 1).trim();
5972
6000
  if (key && value) {
5973
6001
  // Prioritaskan nilai yang lebih spesifik (misalnya !important)
5974
- if (value.includes('!important') || !cssProperties[key]) {
6002
+ if (value.includes("!important") || !cssProperties[key]) {
5975
6003
  cssProperties[key] = value;
5976
6004
  }
5977
6005
  }
@@ -5981,7 +6009,7 @@ var tailwindToStyle = (function (exports) {
5981
6009
  ...cssProperties
5982
6010
  };
5983
6011
  const resolveValue = (value, variables) => {
5984
- if (!value || !value.includes('var(')) return value;
6012
+ if (!value || !value.includes("var(")) return value;
5985
6013
  return value.replace(/var\((--[a-zA-Z0-9-]+)(?:,\s*([^)]+))?\)/g, (match, variable, fallback) => {
5986
6014
  return variables[variable] || fallback || match;
5987
6015
  });
@@ -6035,7 +6063,7 @@ var tailwindToStyle = (function (exports) {
6035
6063
  }
6036
6064
  let classes;
6037
6065
  try {
6038
- classes = classNames.match(/[\w-]+\[[^\]]+\]|[\w-]+\.\d+|[\w-]+/g);
6066
+ classes = classNames.match(/[\w-\/]+(?:\[[^\]]+\])?/g);
6039
6067
 
6040
6068
  // Jika tidak ada class yang valid ditemukan
6041
6069
  if (!classes || classes.length === 0) {
@@ -6047,8 +6075,9 @@ var tailwindToStyle = (function (exports) {
6047
6075
  return convertToJson ? {} : "";
6048
6076
  }
6049
6077
  let cssResult = classes.map(className => {
6050
- if (cssObject[className]) {
6051
- return cssObject[className];
6078
+ let result = cssObject[className] || cssObject[className.replace(/(\/)/g, "\\$1")] || cssObject[className.replace(/\./g, "\\.")];
6079
+ if (result) {
6080
+ return resolveCssToClearCss(result);
6052
6081
  } else if (className.includes("[")) {
6053
6082
  const match = className.match(/\[([^\]]+)\]/);
6054
6083
  if (match) {
@@ -6075,9 +6104,9 @@ var tailwindToStyle = (function (exports) {
6075
6104
  * @returns {string} String CSS yang dihasilkan
6076
6105
  */
6077
6106
  function twsx(obj) {
6078
- if (!obj || typeof obj !== 'object') {
6079
- console.warn('twsx: Expected an object but received:', obj);
6080
- return '';
6107
+ if (!obj || typeof obj !== "object") {
6108
+ console.warn("twsx: Expected an object but received:", obj);
6109
+ return "";
6081
6110
  }
6082
6111
  const styles = {};
6083
6112
  function expandGroupedClass(input) {
@@ -6116,8 +6145,8 @@ var tailwindToStyle = (function (exports) {
6116
6145
  return result;
6117
6146
  }
6118
6147
  function walk(selector, val) {
6119
- if (!selector || typeof selector !== 'string') {
6120
- console.warn('Invalid selector in walk function:', selector);
6148
+ if (!selector || typeof selector !== "string") {
6149
+ console.warn("Invalid selector in walk function:", selector);
6121
6150
  return;
6122
6151
  }
6123
6152
  const {
@@ -6229,8 +6258,8 @@ var tailwindToStyle = (function (exports) {
6229
6258
  return parseSelectorCache.get(selector);
6230
6259
  }
6231
6260
  let result;
6232
- if (selector.includes('@css')) {
6233
- const parts = selector.split('@css');
6261
+ if (selector.includes("@css")) {
6262
+ const parts = selector.split("@css");
6234
6263
  const baseSelector = parts[0].trim();
6235
6264
  const cssProperty = parts[1]?.trim();
6236
6265
  result = {