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