tailwind-to-style 2.7.2 → 2.7.4
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 +252 -68
- package/dist/{index.cjs.js → index.cjs} +252 -68
- package/dist/index.d.ts +32 -7
- package/dist/index.esm.js +250 -69
- package/dist/index.min.js +1 -1
- package/dist/index.min.js.map +1 -1
- package/package.json +2 -2
package/dist/index.browser.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* tailwind-to-style v2.7.
|
|
2
|
+
* tailwind-to-style v2.7.4
|
|
3
3
|
* Convert tailwind classes to inline style
|
|
4
4
|
*
|
|
5
5
|
* @author Bigetion
|
|
@@ -1532,12 +1532,10 @@ var tailwindToStyle = (function (exports) {
|
|
|
1532
1532
|
const themeKeys = Object.keys(configOptions.theme);
|
|
1533
1533
|
themeKeys.forEach(key => {
|
|
1534
1534
|
newTheme[key] = theme[key] || configOptions.theme[key];
|
|
1535
|
-
|
|
1536
|
-
|
|
1537
|
-
|
|
1538
|
-
|
|
1539
|
-
}
|
|
1540
|
-
});
|
|
1535
|
+
});
|
|
1536
|
+
themeKeys.forEach(key => {
|
|
1537
|
+
if (themeExtend[key] && newTheme[key]) {
|
|
1538
|
+
newTheme[key] = Object.assign({}, newTheme[key], themeExtend[key]);
|
|
1541
1539
|
}
|
|
1542
1540
|
});
|
|
1543
1541
|
themeKeys.forEach(key => {
|
|
@@ -1548,9 +1546,6 @@ var tailwindToStyle = (function (exports) {
|
|
|
1548
1546
|
}
|
|
1549
1547
|
});
|
|
1550
1548
|
}
|
|
1551
|
-
if (themeExtend[key]) {
|
|
1552
|
-
newTheme[key] = Object.assign({}, newTheme[key], themeExtend[key]);
|
|
1553
|
-
}
|
|
1554
1549
|
});
|
|
1555
1550
|
return {
|
|
1556
1551
|
prefix: "",
|
|
@@ -6312,10 +6307,10 @@ var tailwindToStyle = (function (exports) {
|
|
|
6312
6307
|
return null;
|
|
6313
6308
|
}
|
|
6314
6309
|
|
|
6315
|
-
/**
|
|
6316
|
-
* Resolve all CSS custom properties (var) in a CSS string and output only clear CSS (no custom property)
|
|
6317
|
-
* @param {string} cssString
|
|
6318
|
-
* @returns {string} e.g. 'color: rgba(255,255,255,1); background: #fff;'
|
|
6310
|
+
/**
|
|
6311
|
+
* Resolve all CSS custom properties (var) in a CSS string and output only clear CSS (no custom property)
|
|
6312
|
+
* @param {string} cssString
|
|
6313
|
+
* @returns {string} e.g. 'color: rgba(255,255,255,1); background: #fff;'
|
|
6319
6314
|
*/
|
|
6320
6315
|
function resolveCssToClearCss(cssString) {
|
|
6321
6316
|
const customVars = {};
|
|
@@ -6382,19 +6377,196 @@ var tailwindToStyle = (function (exports) {
|
|
|
6382
6377
|
}
|
|
6383
6378
|
let twString = null;
|
|
6384
6379
|
let cssObject = null;
|
|
6385
|
-
|
|
6386
|
-
|
|
6380
|
+
|
|
6381
|
+
// Global config storage key
|
|
6382
|
+
const CONFIG_STORAGE_KEY = "__tailwind_to_style_global_config__";
|
|
6383
|
+
|
|
6384
|
+
// Default configuration
|
|
6385
|
+
const defaultConfig = {
|
|
6386
|
+
theme: {
|
|
6387
|
+
extend: {
|
|
6388
|
+
colors: {}
|
|
6389
|
+
},
|
|
6390
|
+
screens: {
|
|
6391
|
+
sm: "640px",
|
|
6392
|
+
md: "768px",
|
|
6393
|
+
lg: "1024px",
|
|
6394
|
+
xl: "1280px",
|
|
6395
|
+
"2xl": "1536px"
|
|
6396
|
+
}
|
|
6397
|
+
},
|
|
6398
|
+
inject: true
|
|
6399
|
+
};
|
|
6400
|
+
|
|
6401
|
+
// Detect environment and create global storage
|
|
6402
|
+
function getGlobalStorage() {
|
|
6403
|
+
if (typeof window !== "undefined") {
|
|
6404
|
+
// Browser environment - use window object
|
|
6405
|
+
if (!window[CONFIG_STORAGE_KEY]) {
|
|
6406
|
+
window[CONFIG_STORAGE_KEY] = {
|
|
6407
|
+
...defaultConfig
|
|
6408
|
+
};
|
|
6409
|
+
}
|
|
6410
|
+
return window[CONFIG_STORAGE_KEY];
|
|
6411
|
+
} else if (typeof global !== "undefined") {
|
|
6412
|
+
// Node.js environment - use global object
|
|
6413
|
+
if (!global[CONFIG_STORAGE_KEY]) {
|
|
6414
|
+
global[CONFIG_STORAGE_KEY] = {
|
|
6415
|
+
...defaultConfig
|
|
6416
|
+
};
|
|
6417
|
+
}
|
|
6418
|
+
return global[CONFIG_STORAGE_KEY];
|
|
6419
|
+
} else {
|
|
6420
|
+
// Fallback - use module-level variable (will work only within same file)
|
|
6421
|
+
console.warn("tailwind-to-style: Unable to create global config storage. Config will only work within the same module.");
|
|
6422
|
+
return defaultConfig;
|
|
6423
|
+
}
|
|
6424
|
+
}
|
|
6425
|
+
|
|
6426
|
+
// Get global config reference
|
|
6427
|
+
let globalConfig = getGlobalStorage();
|
|
6428
|
+
function initializeCss() {
|
|
6429
|
+
if (!twString) {
|
|
6430
|
+
// Always get fresh config from global storage
|
|
6431
|
+
const currentConfig = getGlobalStorage();
|
|
6432
|
+
const configForGeneration = {
|
|
6433
|
+
...currentConfig,
|
|
6434
|
+
theme: {
|
|
6435
|
+
...currentConfig.theme
|
|
6436
|
+
}
|
|
6437
|
+
};
|
|
6438
|
+
twString = generateTailwindCssString(configForGeneration).replace(/\s\s+/g, " ");
|
|
6439
|
+
}
|
|
6440
|
+
if (!cssObject) {
|
|
6441
|
+
cssObject = convertCssToObject(twString);
|
|
6442
|
+
}
|
|
6443
|
+
}
|
|
6444
|
+
initializeCss();
|
|
6445
|
+
function convertScreensToBreakpoints(screens) {
|
|
6446
|
+
const breakpoints = {};
|
|
6447
|
+
for (const [key, value] of Object.entries(screens)) {
|
|
6448
|
+
breakpoints[key] = `@media (min-width: ${value})`;
|
|
6449
|
+
}
|
|
6450
|
+
return breakpoints;
|
|
6387
6451
|
}
|
|
6388
|
-
|
|
6452
|
+
|
|
6453
|
+
/**
|
|
6454
|
+
* Set global configuration for both tws and twsx functions
|
|
6455
|
+
* @param {Object} config - Global configuration object
|
|
6456
|
+
* @returns {Object} Current global configuration
|
|
6457
|
+
*/
|
|
6458
|
+
function setConfig(config) {
|
|
6459
|
+
var _config$theme, _config$theme2, _config$theme2$extend, _config$theme3;
|
|
6460
|
+
// Reset CSS object cache when config changes
|
|
6461
|
+
twString = null;
|
|
6462
|
+
cssObject = null;
|
|
6463
|
+
configOptionsCache.clear();
|
|
6464
|
+
|
|
6465
|
+
// Get current global storage reference
|
|
6466
|
+
const globalStorage = getGlobalStorage();
|
|
6467
|
+
|
|
6468
|
+
// Update global storage directly
|
|
6469
|
+
Object.assign(globalStorage, {
|
|
6470
|
+
...globalStorage,
|
|
6471
|
+
...config,
|
|
6472
|
+
theme: {
|
|
6473
|
+
...globalStorage.theme,
|
|
6474
|
+
...(config.theme || {}),
|
|
6475
|
+
extend: {
|
|
6476
|
+
...globalStorage.theme.extend,
|
|
6477
|
+
...(((_config$theme = config.theme) === null || _config$theme === void 0 ? void 0 : _config$theme.extend) || {}),
|
|
6478
|
+
colors: {
|
|
6479
|
+
...globalStorage.theme.extend.colors,
|
|
6480
|
+
...(((_config$theme2 = config.theme) === null || _config$theme2 === void 0 ? void 0 : (_config$theme2$extend = _config$theme2.extend) === null || _config$theme2$extend === void 0 ? void 0 : _config$theme2$extend.colors) || {})
|
|
6481
|
+
}
|
|
6482
|
+
}
|
|
6483
|
+
}
|
|
6484
|
+
});
|
|
6485
|
+
|
|
6486
|
+
// Handle screens configuration
|
|
6487
|
+
if ((_config$theme3 = config.theme) !== null && _config$theme3 !== void 0 && _config$theme3.screens) {
|
|
6488
|
+
globalStorage.theme.screens = {
|
|
6489
|
+
...globalStorage.theme.screens,
|
|
6490
|
+
...config.theme.screens
|
|
6491
|
+
};
|
|
6492
|
+
}
|
|
6493
|
+
|
|
6494
|
+
// Handle legacy breakpoints with deprecation warning
|
|
6495
|
+
if (config.breakpoints) {
|
|
6496
|
+
console.warn("Warning: config.breakpoints is deprecated. Use config.theme.screens instead.");
|
|
6497
|
+
|
|
6498
|
+
// Convert legacy breakpoints to screens format
|
|
6499
|
+
const screens = {};
|
|
6500
|
+
for (const [key, value] of Object.entries(config.breakpoints)) {
|
|
6501
|
+
// Extract min-width value from media query
|
|
6502
|
+
const match = value.match(/min-width:\s*([^)]+)/);
|
|
6503
|
+
if (match) {
|
|
6504
|
+
screens[key] = match[1].trim();
|
|
6505
|
+
}
|
|
6506
|
+
}
|
|
6507
|
+
globalStorage.theme.screens = {
|
|
6508
|
+
...globalStorage.theme.screens,
|
|
6509
|
+
...screens
|
|
6510
|
+
};
|
|
6511
|
+
}
|
|
6512
|
+
|
|
6513
|
+
// Update local reference
|
|
6514
|
+
globalConfig = globalStorage;
|
|
6515
|
+
initializeCss();
|
|
6516
|
+
return {
|
|
6517
|
+
...globalConfig
|
|
6518
|
+
};
|
|
6519
|
+
}
|
|
6520
|
+
|
|
6521
|
+
/**
|
|
6522
|
+
* Get current global configuration
|
|
6523
|
+
* @returns {Object} Current global configuration
|
|
6524
|
+
*/
|
|
6525
|
+
function getConfig() {
|
|
6526
|
+
// Always get fresh reference from global storage
|
|
6527
|
+
globalConfig = getGlobalStorage();
|
|
6528
|
+
return {
|
|
6529
|
+
...globalConfig
|
|
6530
|
+
};
|
|
6531
|
+
}
|
|
6532
|
+
|
|
6533
|
+
/**
|
|
6534
|
+
* Reset global configuration to default
|
|
6535
|
+
* @returns {Object} Default configuration
|
|
6536
|
+
*/
|
|
6537
|
+
function resetConfig() {
|
|
6538
|
+
twString = null;
|
|
6539
|
+
cssObject = null;
|
|
6540
|
+
configOptionsCache.clear();
|
|
6541
|
+
|
|
6542
|
+
// Get global storage reference and reset it
|
|
6543
|
+
const globalStorage = getGlobalStorage();
|
|
6544
|
+
|
|
6545
|
+
// Reset to default config
|
|
6546
|
+
Object.assign(globalStorage, {
|
|
6547
|
+
theme: {
|
|
6548
|
+
extend: {
|
|
6549
|
+
colors: {}
|
|
6550
|
+
},
|
|
6551
|
+
screens: {
|
|
6552
|
+
sm: "640px",
|
|
6553
|
+
md: "768px",
|
|
6554
|
+
lg: "1024px",
|
|
6555
|
+
xl: "1280px",
|
|
6556
|
+
"2xl": "1536px"
|
|
6557
|
+
}
|
|
6558
|
+
},
|
|
6559
|
+
inject: true
|
|
6560
|
+
});
|
|
6561
|
+
|
|
6562
|
+
// Update local reference
|
|
6563
|
+
globalConfig = globalStorage;
|
|
6564
|
+
twString = generateTailwindCssString(globalConfig).replace(/\s\s+/g, " ");
|
|
6389
6565
|
cssObject = convertCssToObject(twString);
|
|
6566
|
+
return {
|
|
6567
|
+
...globalConfig
|
|
6568
|
+
};
|
|
6390
6569
|
}
|
|
6391
|
-
const breakpoints = {
|
|
6392
|
-
sm: "@media (min-width: 640px)",
|
|
6393
|
-
md: "@media (min-width: 768px)",
|
|
6394
|
-
lg: "@media (min-width: 1024px)",
|
|
6395
|
-
xl: "@media (min-width: 1280px)",
|
|
6396
|
-
"2xl": "@media (min-width: 1536px)"
|
|
6397
|
-
};
|
|
6398
6570
|
const pseudoVariants = new Set(["hover", "focus", "focus-within", "active", "visited", "disabled", "first", "last", "checked", "invalid", "required"]);
|
|
6399
6571
|
const specialVariants = {
|
|
6400
6572
|
group: (state, sel) => `.group:${state} ${sel}`,
|
|
@@ -6444,6 +6616,9 @@ var tailwindToStyle = (function (exports) {
|
|
|
6444
6616
|
let media = null;
|
|
6445
6617
|
let finalSelector = selector;
|
|
6446
6618
|
for (const v of variants) {
|
|
6619
|
+
// Always get fresh config from global storage
|
|
6620
|
+
const currentConfig = getGlobalStorage();
|
|
6621
|
+
const breakpoints = convertScreensToBreakpoints(currentConfig.theme.screens || {});
|
|
6447
6622
|
if (breakpoints[v]) {
|
|
6448
6623
|
media = breakpoints[v];
|
|
6449
6624
|
} else if (pseudoVariants.has(v)) {
|
|
@@ -6505,7 +6680,7 @@ var tailwindToStyle = (function (exports) {
|
|
|
6505
6680
|
callCount++;
|
|
6506
6681
|
clearTimeout(timeout);
|
|
6507
6682
|
timeout = setTimeout(() => {
|
|
6508
|
-
const marker = performanceMonitor.start(`debounced:${func.name ||
|
|
6683
|
+
const marker = performanceMonitor.start(`debounced:${func.name || "anonymous"}`);
|
|
6509
6684
|
try {
|
|
6510
6685
|
const result = func.apply(context, args);
|
|
6511
6686
|
performanceMonitor.end(marker);
|
|
@@ -6593,11 +6768,11 @@ var tailwindToStyle = (function (exports) {
|
|
|
6593
6768
|
}
|
|
6594
6769
|
}
|
|
6595
6770
|
|
|
6596
|
-
/**
|
|
6597
|
-
* Process opacity modifier from class name (e.g., text-red-500/50 -> 50% opacity)
|
|
6598
|
-
* @param {string} className - Class name with potential opacity modifier
|
|
6599
|
-
* @param {string} cssDeclaration - CSS declaration to modify
|
|
6600
|
-
* @returns {string} Modified CSS declaration with opacity applied
|
|
6771
|
+
/**
|
|
6772
|
+
* Process opacity modifier from class name (e.g., text-red-500/50 -> 50% opacity)
|
|
6773
|
+
* @param {string} className - Class name with potential opacity modifier
|
|
6774
|
+
* @param {string} cssDeclaration - CSS declaration to modify
|
|
6775
|
+
* @returns {string} Modified CSS declaration with opacity applied
|
|
6601
6776
|
*/
|
|
6602
6777
|
function processOpacityModifier(className, cssDeclaration) {
|
|
6603
6778
|
const opacityMatch = className.match(/\/(\d+)$/);
|
|
@@ -6610,20 +6785,20 @@ var tailwindToStyle = (function (exports) {
|
|
|
6610
6785
|
let modifiedDeclaration = cssDeclaration;
|
|
6611
6786
|
|
|
6612
6787
|
// Replace opacity custom properties
|
|
6613
|
-
const opacityProperties = [
|
|
6788
|
+
const opacityProperties = ["--text-opacity", "--bg-opacity", "--border-opacity", "--ring-opacity", "--divide-opacity", "--placeholder-opacity", "--text-decoration-opacity", "--outline-opacity", "--accent-opacity", "--caret-opacity"];
|
|
6614
6789
|
opacityProperties.forEach(prop => {
|
|
6615
|
-
const propRegex = new RegExp(`${prop}\\s*:\\s*[\\d.]+`,
|
|
6790
|
+
const propRegex = new RegExp(`${prop}\\s*:\\s*[\\d.]+`, "gi");
|
|
6616
6791
|
modifiedDeclaration = modifiedDeclaration.replace(propRegex, `${prop}: ${alphaValue}`);
|
|
6617
6792
|
});
|
|
6618
6793
|
|
|
6619
6794
|
// Also handle direct color values that might not use CSS variables
|
|
6620
|
-
const colorProperties = [
|
|
6795
|
+
const colorProperties = ["color", "background-color", "border-color", "text-decoration-color", "outline-color", "fill", "stroke", "caret-color", "accent-color"];
|
|
6621
6796
|
colorProperties.forEach(prop => {
|
|
6622
6797
|
// Match rgb(), rgba(), hsl(), hsla() functions
|
|
6623
|
-
const rgbRegex = new RegExp(`(${prop}\\s*:\\s*)rgb\\((\\d+),\\s*(\\d+),\\s*(\\d+)\\)`,
|
|
6624
|
-
const rgbaRegex = new RegExp(`(${prop}\\s*:\\s*)rgba\\((\\d+),\\s*(\\d+),\\s*(\\d+),\\s*[\\d.]+\\)`,
|
|
6625
|
-
const hslRegex = new RegExp(`(${prop}\\s*:\\s*)hsl\\((\\d+),\\s*([\\d.]+%),\\s*([\\d.]+%)\\)`,
|
|
6626
|
-
const hslaRegex = new RegExp(`(${prop}\\s*:\\s*)hsla\\((\\d+),\\s*([\\d.]+%),\\s*([\\d.]+%),\\s*[\\d.]+\\)`,
|
|
6798
|
+
const rgbRegex = new RegExp(`(${prop}\\s*:\\s*)rgb\\((\\d+),\\s*(\\d+),\\s*(\\d+)\\)`, "gi");
|
|
6799
|
+
const rgbaRegex = new RegExp(`(${prop}\\s*:\\s*)rgba\\((\\d+),\\s*(\\d+),\\s*(\\d+),\\s*[\\d.]+\\)`, "gi");
|
|
6800
|
+
const hslRegex = new RegExp(`(${prop}\\s*:\\s*)hsl\\((\\d+),\\s*([\\d.]+%),\\s*([\\d.]+%)\\)`, "gi");
|
|
6801
|
+
const hslaRegex = new RegExp(`(${prop}\\s*:\\s*)hsla\\((\\d+),\\s*([\\d.]+%),\\s*([\\d.]+%),\\s*[\\d.]+\\)`, "gi");
|
|
6627
6802
|
|
|
6628
6803
|
// Convert rgb to rgba with opacity
|
|
6629
6804
|
modifiedDeclaration = modifiedDeclaration.replace(rgbRegex, `$1rgba($2, $3, $4, ${alphaValue})`);
|
|
@@ -6638,10 +6813,10 @@ var tailwindToStyle = (function (exports) {
|
|
|
6638
6813
|
modifiedDeclaration = modifiedDeclaration.replace(hslaRegex, `$1hsla($2, $3, $4, ${alphaValue})`);
|
|
6639
6814
|
|
|
6640
6815
|
// Handle hex colors
|
|
6641
|
-
const hexRegex = new RegExp(`(${prop}\\s*:\\s*)(#[0-9a-fA-F]{3,6})`,
|
|
6642
|
-
modifiedDeclaration = modifiedDeclaration.replace(hexRegex, (
|
|
6816
|
+
const hexRegex = new RegExp(`(${prop}\\s*:\\s*)(#[0-9a-fA-F]{3,6})`, "gi");
|
|
6817
|
+
modifiedDeclaration = modifiedDeclaration.replace(hexRegex, (_, propPart, hexColor) => {
|
|
6643
6818
|
// Convert hex to rgba
|
|
6644
|
-
const hex = hexColor.replace(
|
|
6819
|
+
const hex = hexColor.replace("#", "");
|
|
6645
6820
|
let r, g, b;
|
|
6646
6821
|
if (hex.length === 3) {
|
|
6647
6822
|
r = parseInt(hex[0] + hex[0], 16);
|
|
@@ -6658,15 +6833,17 @@ var tailwindToStyle = (function (exports) {
|
|
|
6658
6833
|
return modifiedDeclaration;
|
|
6659
6834
|
}
|
|
6660
6835
|
|
|
6661
|
-
/**
|
|
6662
|
-
* Convert Tailwind class string to inline CSS styles or JSON object
|
|
6663
|
-
* @param {string} classNames - String containing Tailwind classes to convert
|
|
6664
|
-
* @param {boolean} convertToJson - If true, result will be JSON object, if false becomes CSS string
|
|
6665
|
-
* @returns {string|Object} Inline CSS string or style JSON object
|
|
6836
|
+
/**
|
|
6837
|
+
* Convert Tailwind class string to inline CSS styles or JSON object
|
|
6838
|
+
* @param {string} classNames - String containing Tailwind classes to convert
|
|
6839
|
+
* @param {boolean} convertToJson - If true, result will be JSON object, if false becomes CSS string
|
|
6840
|
+
* @returns {string|Object} Inline CSS string or style JSON object
|
|
6666
6841
|
*/
|
|
6667
6842
|
function tws(classNames, convertToJson) {
|
|
6668
6843
|
const totalMarker = performanceMonitor.start("tws:total");
|
|
6669
6844
|
try {
|
|
6845
|
+
// Ensure CSS is initialized with current global config
|
|
6846
|
+
initializeCss();
|
|
6670
6847
|
if ([!classNames, typeof classNames !== "string", classNames.trim() === ""].includes(true)) {
|
|
6671
6848
|
performanceMonitor.end(totalMarker);
|
|
6672
6849
|
return convertToJson ? {} : "";
|
|
@@ -6693,11 +6870,11 @@ var tailwindToStyle = (function (exports) {
|
|
|
6693
6870
|
const processMarker = performanceMonitor.start("tws:process");
|
|
6694
6871
|
let cssResult = classes.map(className => {
|
|
6695
6872
|
// Extract base class name without opacity modifier
|
|
6696
|
-
const baseClassName = className.replace(/\/\d+$/,
|
|
6873
|
+
const baseClassName = className.replace(/\/\d+$/, "");
|
|
6697
6874
|
let result = cssObject[baseClassName] || cssObject[baseClassName.replace(/(\/)/g, "\\$1")] || cssObject[baseClassName.replace(/\./g, "\\.")];
|
|
6698
6875
|
if (result) {
|
|
6699
6876
|
// Apply opacity modifier if present
|
|
6700
|
-
if (className.includes(
|
|
6877
|
+
if (className.includes("/") && /\/\d+$/.test(className)) {
|
|
6701
6878
|
result = processOpacityModifier(className, result);
|
|
6702
6879
|
}
|
|
6703
6880
|
return resolveCssToClearCss(result);
|
|
@@ -6709,7 +6886,7 @@ var tailwindToStyle = (function (exports) {
|
|
|
6709
6886
|
if (cssObject[`${baseKey}custom`]) {
|
|
6710
6887
|
let customResult = cssObject[`${baseKey}custom`].replace(/custom_value/g, customValue);
|
|
6711
6888
|
// Apply opacity modifier to custom values too
|
|
6712
|
-
if (className.includes(
|
|
6889
|
+
if (className.includes("/") && /\/\d+$/.test(className)) {
|
|
6713
6890
|
customResult = processOpacityModifier(className, customResult);
|
|
6714
6891
|
}
|
|
6715
6892
|
return customResult;
|
|
@@ -6845,7 +7022,7 @@ var tailwindToStyle = (function (exports) {
|
|
|
6845
7022
|
} = resolveVariants(selector, rawVariants);
|
|
6846
7023
|
|
|
6847
7024
|
// Extract base class name without opacity modifier for CSS lookup
|
|
6848
|
-
const baseClassName = pureClassName.replace(/\/\d+$/,
|
|
7025
|
+
const baseClassName = pureClassName.replace(/\/\d+$/, "");
|
|
6849
7026
|
let declarations = cssObject[baseClassName] || cssObject[baseClassName.replace(/(\/)/g, "\\$1")] || cssObject[baseClassName.replace(/\./g, "\\.")];
|
|
6850
7027
|
if (!declarations && baseClassName.includes("[")) {
|
|
6851
7028
|
const match = baseClassName.match(/^(.+?)\[(.+)\]$/);
|
|
@@ -6866,7 +7043,7 @@ var tailwindToStyle = (function (exports) {
|
|
|
6866
7043
|
}
|
|
6867
7044
|
|
|
6868
7045
|
// Apply opacity modifier if present
|
|
6869
|
-
if (pureClassName.includes(
|
|
7046
|
+
if (pureClassName.includes("/") && /\/\d+$/.test(pureClassName)) {
|
|
6870
7047
|
declarations = processOpacityModifier(pureClassName, declarations);
|
|
6871
7048
|
}
|
|
6872
7049
|
if (isImportant) {
|
|
@@ -7041,12 +7218,12 @@ var tailwindToStyle = (function (exports) {
|
|
|
7041
7218
|
return cssString.trim();
|
|
7042
7219
|
}
|
|
7043
7220
|
|
|
7044
|
-
/**
|
|
7045
|
-
* Generate CSS string from style object with SCSS-like syntax
|
|
7046
|
-
* Supports nested selectors, state variants, responsive variants, and @css directives
|
|
7047
|
-
* @param {Object} obj - Object with SCSS-like style format
|
|
7048
|
-
* @param {Object} [options] - Additional options,
|
|
7049
|
-
* @returns {string} Generated CSS string
|
|
7221
|
+
/**
|
|
7222
|
+
* Generate CSS string from style object with SCSS-like syntax
|
|
7223
|
+
* Supports nested selectors, state variants, responsive variants, and @css directives
|
|
7224
|
+
* @param {Object} obj - Object with SCSS-like style format
|
|
7225
|
+
* @param {Object} [options] - Additional options, merges with global config
|
|
7226
|
+
* @returns {string} Generated CSS string
|
|
7050
7227
|
*/
|
|
7051
7228
|
function twsx(obj) {
|
|
7052
7229
|
let options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
@@ -7056,9 +7233,13 @@ var tailwindToStyle = (function (exports) {
|
|
|
7056
7233
|
console.warn("twsx: Expected an object but received:", obj);
|
|
7057
7234
|
return "";
|
|
7058
7235
|
}
|
|
7236
|
+
const mergedOptions = {
|
|
7237
|
+
...getGlobalStorage(),
|
|
7238
|
+
...options
|
|
7239
|
+
};
|
|
7059
7240
|
const {
|
|
7060
7241
|
inject = true
|
|
7061
|
-
} =
|
|
7242
|
+
} = mergedOptions;
|
|
7062
7243
|
const styles = {};
|
|
7063
7244
|
|
|
7064
7245
|
// Create walk function with closure over styles
|
|
@@ -7153,19 +7334,19 @@ var tailwindToStyle = (function (exports) {
|
|
|
7153
7334
|
}
|
|
7154
7335
|
|
|
7155
7336
|
// Enhanced debounced functions with performance monitoring configuration
|
|
7156
|
-
/**
|
|
7157
|
-
* Debounced version of tws function with performance monitoring
|
|
7158
|
-
* @param {string} classNames - String containing Tailwind classes to convert
|
|
7159
|
-
* @param {boolean} convertToJson - If true, result will be JSON object, if false becomes CSS string
|
|
7160
|
-
* @returns {string|Object} Inline CSS string or style JSON object
|
|
7337
|
+
/**
|
|
7338
|
+
* Debounced version of tws function with performance monitoring
|
|
7339
|
+
* @param {string} classNames - String containing Tailwind classes to convert
|
|
7340
|
+
* @param {boolean} convertToJson - If true, result will be JSON object, if false becomes CSS string
|
|
7341
|
+
* @returns {string|Object} Inline CSS string or style JSON object
|
|
7161
7342
|
*/
|
|
7162
7343
|
const debouncedTws = debounce(tws, 50); // Faster debounce for tws
|
|
7163
7344
|
|
|
7164
|
-
/**
|
|
7165
|
-
* Debounced version of twsx function with performance monitoring
|
|
7166
|
-
* @param {Object} obj - Object with SCSS-like style format
|
|
7167
|
-
* @param {Object} [options] - Additional options
|
|
7168
|
-
* @returns {string} Generated CSS string
|
|
7345
|
+
/**
|
|
7346
|
+
* Debounced version of twsx function with performance monitoring
|
|
7347
|
+
* @param {Object} obj - Object with SCSS-like style format
|
|
7348
|
+
* @param {Object} [options] - Additional options
|
|
7349
|
+
* @returns {string} Generated CSS string
|
|
7169
7350
|
*/
|
|
7170
7351
|
const debouncedTwsx = debounce(twsx, 100); // Standard debounce for twsx
|
|
7171
7352
|
|
|
@@ -7197,13 +7378,16 @@ var tailwindToStyle = (function (exports) {
|
|
|
7197
7378
|
enablePerformanceLogging() {
|
|
7198
7379
|
let enabled = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : true;
|
|
7199
7380
|
performanceMonitor.enabled = enabled && typeof performance !== "undefined";
|
|
7200
|
-
console.log(`Performance monitoring ${enabled ?
|
|
7381
|
+
console.log(`Performance monitoring ${enabled ? "enabled" : "disabled"}`);
|
|
7201
7382
|
}
|
|
7202
7383
|
};
|
|
7203
7384
|
|
|
7204
7385
|
exports.debouncedTws = debouncedTws;
|
|
7205
7386
|
exports.debouncedTwsx = debouncedTwsx;
|
|
7387
|
+
exports.getConfig = getConfig;
|
|
7206
7388
|
exports.performanceUtils = performanceUtils;
|
|
7389
|
+
exports.resetConfig = resetConfig;
|
|
7390
|
+
exports.setConfig = setConfig;
|
|
7207
7391
|
exports.tws = tws;
|
|
7208
7392
|
exports.twsx = twsx;
|
|
7209
7393
|
|