tailwind-to-style 2.7.2 → 2.7.3
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 +174 -68
- package/dist/{index.cjs.js → index.cjs} +174 -68
- package/dist/index.d.ts +32 -7
- package/dist/index.esm.js +172 -69
- package/dist/index.min.js +1 -1
- package/dist/index.min.js.map +1 -1
- package/package.json +2 -2
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* tailwind-to-style v2.7.
|
|
2
|
+
* tailwind-to-style v2.7.3
|
|
3
3
|
* Convert tailwind classes to inline style
|
|
4
4
|
*
|
|
5
5
|
* @author Bigetion
|
|
@@ -1533,12 +1533,10 @@ function getConfigOptions() {
|
|
|
1533
1533
|
const themeKeys = Object.keys(configOptions.theme);
|
|
1534
1534
|
themeKeys.forEach(key => {
|
|
1535
1535
|
newTheme[key] = theme[key] || configOptions.theme[key];
|
|
1536
|
-
|
|
1537
|
-
|
|
1538
|
-
|
|
1539
|
-
|
|
1540
|
-
}
|
|
1541
|
-
});
|
|
1536
|
+
});
|
|
1537
|
+
themeKeys.forEach(key => {
|
|
1538
|
+
if (themeExtend[key] && newTheme[key]) {
|
|
1539
|
+
newTheme[key] = Object.assign({}, newTheme[key], themeExtend[key]);
|
|
1542
1540
|
}
|
|
1543
1541
|
});
|
|
1544
1542
|
themeKeys.forEach(key => {
|
|
@@ -1549,9 +1547,6 @@ function getConfigOptions() {
|
|
|
1549
1547
|
}
|
|
1550
1548
|
});
|
|
1551
1549
|
}
|
|
1552
|
-
if (themeExtend[key]) {
|
|
1553
|
-
newTheme[key] = Object.assign({}, newTheme[key], themeExtend[key]);
|
|
1554
|
-
}
|
|
1555
1550
|
});
|
|
1556
1551
|
return {
|
|
1557
1552
|
prefix: "",
|
|
@@ -6313,10 +6308,10 @@ function parseCustomClassWithPatterns(className) {
|
|
|
6313
6308
|
return null;
|
|
6314
6309
|
}
|
|
6315
6310
|
|
|
6316
|
-
/**
|
|
6317
|
-
* Resolve all CSS custom properties (var) in a CSS string and output only clear CSS (no custom property)
|
|
6318
|
-
* @param {string} cssString
|
|
6319
|
-
* @returns {string} e.g. 'color: rgba(255,255,255,1); background: #fff;'
|
|
6311
|
+
/**
|
|
6312
|
+
* Resolve all CSS custom properties (var) in a CSS string and output only clear CSS (no custom property)
|
|
6313
|
+
* @param {string} cssString
|
|
6314
|
+
* @returns {string} e.g. 'color: rgba(255,255,255,1); background: #fff;'
|
|
6320
6315
|
*/
|
|
6321
6316
|
function resolveCssToClearCss(cssString) {
|
|
6322
6317
|
const customVars = {};
|
|
@@ -6383,19 +6378,120 @@ function convertCssToObject(cssString) {
|
|
|
6383
6378
|
}
|
|
6384
6379
|
let twString = null;
|
|
6385
6380
|
let cssObject = null;
|
|
6386
|
-
|
|
6387
|
-
|
|
6381
|
+
let globalConfig = {
|
|
6382
|
+
theme: {
|
|
6383
|
+
extend: {
|
|
6384
|
+
colors: {}
|
|
6385
|
+
},
|
|
6386
|
+
screens: {
|
|
6387
|
+
sm: "640px",
|
|
6388
|
+
md: "768px",
|
|
6389
|
+
lg: "1024px",
|
|
6390
|
+
xl: "1280px",
|
|
6391
|
+
"2xl": "1536px"
|
|
6392
|
+
}
|
|
6393
|
+
},
|
|
6394
|
+
inject: true
|
|
6395
|
+
};
|
|
6396
|
+
function initializeCss() {
|
|
6397
|
+
if (!twString) {
|
|
6398
|
+
const configForGeneration = {
|
|
6399
|
+
...globalConfig,
|
|
6400
|
+
theme: {
|
|
6401
|
+
...globalConfig.theme
|
|
6402
|
+
}
|
|
6403
|
+
};
|
|
6404
|
+
twString = generateTailwindCssString(configForGeneration).replace(/\s\s+/g, " ");
|
|
6405
|
+
}
|
|
6406
|
+
if (!cssObject) {
|
|
6407
|
+
cssObject = convertCssToObject(twString);
|
|
6408
|
+
}
|
|
6409
|
+
}
|
|
6410
|
+
initializeCss();
|
|
6411
|
+
function convertScreensToBreakpoints(screens) {
|
|
6412
|
+
const breakpoints = {};
|
|
6413
|
+
for (const [key, value] of Object.entries(screens)) {
|
|
6414
|
+
breakpoints[key] = `@media (min-width: ${value})`;
|
|
6415
|
+
}
|
|
6416
|
+
return breakpoints;
|
|
6417
|
+
}
|
|
6418
|
+
|
|
6419
|
+
/**
|
|
6420
|
+
* Set global configuration for both tws and twsx functions
|
|
6421
|
+
* @param {Object} config - Global configuration object
|
|
6422
|
+
* @returns {Object} Current global configuration
|
|
6423
|
+
*/
|
|
6424
|
+
function setConfig(config) {
|
|
6425
|
+
var _config$theme, _config$theme2, _config$theme2$extend, _config$theme3;
|
|
6426
|
+
// Reset CSS object cache when config changes
|
|
6427
|
+
twString = null;
|
|
6428
|
+
cssObject = null;
|
|
6429
|
+
configOptionsCache.clear();
|
|
6430
|
+
globalConfig = {
|
|
6431
|
+
...globalConfig,
|
|
6432
|
+
...config,
|
|
6433
|
+
theme: {
|
|
6434
|
+
...globalConfig.theme,
|
|
6435
|
+
...(config.theme || {}),
|
|
6436
|
+
extend: {
|
|
6437
|
+
...globalConfig.theme.extend,
|
|
6438
|
+
...(((_config$theme = config.theme) === null || _config$theme === void 0 ? void 0 : _config$theme.extend) || {}),
|
|
6439
|
+
colors: {
|
|
6440
|
+
...globalConfig.theme.extend.colors,
|
|
6441
|
+
...(((_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) || {})
|
|
6442
|
+
}
|
|
6443
|
+
}
|
|
6444
|
+
}
|
|
6445
|
+
};
|
|
6446
|
+
|
|
6447
|
+
// Handle screens configuration
|
|
6448
|
+
if ((_config$theme3 = config.theme) !== null && _config$theme3 !== void 0 && _config$theme3.screens) {
|
|
6449
|
+
globalConfig.theme.screens = {
|
|
6450
|
+
...globalConfig.theme.screens,
|
|
6451
|
+
...config.theme.screens
|
|
6452
|
+
};
|
|
6453
|
+
}
|
|
6454
|
+
initializeCss();
|
|
6455
|
+
return globalConfig;
|
|
6388
6456
|
}
|
|
6389
|
-
|
|
6457
|
+
|
|
6458
|
+
/**
|
|
6459
|
+
* Get current global configuration
|
|
6460
|
+
* @returns {Object} Current global configuration
|
|
6461
|
+
*/
|
|
6462
|
+
function getConfig() {
|
|
6463
|
+
return {
|
|
6464
|
+
...globalConfig
|
|
6465
|
+
};
|
|
6466
|
+
}
|
|
6467
|
+
|
|
6468
|
+
/**
|
|
6469
|
+
* Reset global configuration to default
|
|
6470
|
+
* @returns {Object} Default configuration
|
|
6471
|
+
*/
|
|
6472
|
+
function resetConfig() {
|
|
6473
|
+
twString = null;
|
|
6474
|
+
cssObject = null;
|
|
6475
|
+
configOptionsCache.clear();
|
|
6476
|
+
globalConfig = {
|
|
6477
|
+
theme: {
|
|
6478
|
+
extend: {
|
|
6479
|
+
colors: {}
|
|
6480
|
+
},
|
|
6481
|
+
screens: {
|
|
6482
|
+
sm: "640px",
|
|
6483
|
+
md: "768px",
|
|
6484
|
+
lg: "1024px",
|
|
6485
|
+
xl: "1280px",
|
|
6486
|
+
"2xl": "1536px"
|
|
6487
|
+
}
|
|
6488
|
+
},
|
|
6489
|
+
inject: true
|
|
6490
|
+
};
|
|
6491
|
+
twString = generateTailwindCssString(globalConfig).replace(/\s\s+/g, " ");
|
|
6390
6492
|
cssObject = convertCssToObject(twString);
|
|
6493
|
+
return globalConfig;
|
|
6391
6494
|
}
|
|
6392
|
-
const breakpoints = {
|
|
6393
|
-
sm: "@media (min-width: 640px)",
|
|
6394
|
-
md: "@media (min-width: 768px)",
|
|
6395
|
-
lg: "@media (min-width: 1024px)",
|
|
6396
|
-
xl: "@media (min-width: 1280px)",
|
|
6397
|
-
"2xl": "@media (min-width: 1536px)"
|
|
6398
|
-
};
|
|
6399
6495
|
const pseudoVariants = new Set(["hover", "focus", "focus-within", "active", "visited", "disabled", "first", "last", "checked", "invalid", "required"]);
|
|
6400
6496
|
const specialVariants = {
|
|
6401
6497
|
group: (state, sel) => `.group:${state} ${sel}`,
|
|
@@ -6445,6 +6541,7 @@ function resolveVariants(selector, variants) {
|
|
|
6445
6541
|
let media = null;
|
|
6446
6542
|
let finalSelector = selector;
|
|
6447
6543
|
for (const v of variants) {
|
|
6544
|
+
const breakpoints = convertScreensToBreakpoints(globalConfig.theme.screens || {});
|
|
6448
6545
|
if (breakpoints[v]) {
|
|
6449
6546
|
media = breakpoints[v];
|
|
6450
6547
|
} else if (pseudoVariants.has(v)) {
|
|
@@ -6506,7 +6603,7 @@ function debounce(func) {
|
|
|
6506
6603
|
callCount++;
|
|
6507
6604
|
clearTimeout(timeout);
|
|
6508
6605
|
timeout = setTimeout(() => {
|
|
6509
|
-
const marker = performanceMonitor.start(`debounced:${func.name ||
|
|
6606
|
+
const marker = performanceMonitor.start(`debounced:${func.name || "anonymous"}`);
|
|
6510
6607
|
try {
|
|
6511
6608
|
const result = func.apply(context, args);
|
|
6512
6609
|
performanceMonitor.end(marker);
|
|
@@ -6594,11 +6691,11 @@ function separateAndResolveCSS(arr) {
|
|
|
6594
6691
|
}
|
|
6595
6692
|
}
|
|
6596
6693
|
|
|
6597
|
-
/**
|
|
6598
|
-
* Process opacity modifier from class name (e.g., text-red-500/50 -> 50% opacity)
|
|
6599
|
-
* @param {string} className - Class name with potential opacity modifier
|
|
6600
|
-
* @param {string} cssDeclaration - CSS declaration to modify
|
|
6601
|
-
* @returns {string} Modified CSS declaration with opacity applied
|
|
6694
|
+
/**
|
|
6695
|
+
* Process opacity modifier from class name (e.g., text-red-500/50 -> 50% opacity)
|
|
6696
|
+
* @param {string} className - Class name with potential opacity modifier
|
|
6697
|
+
* @param {string} cssDeclaration - CSS declaration to modify
|
|
6698
|
+
* @returns {string} Modified CSS declaration with opacity applied
|
|
6602
6699
|
*/
|
|
6603
6700
|
function processOpacityModifier(className, cssDeclaration) {
|
|
6604
6701
|
const opacityMatch = className.match(/\/(\d+)$/);
|
|
@@ -6611,20 +6708,20 @@ function processOpacityModifier(className, cssDeclaration) {
|
|
|
6611
6708
|
let modifiedDeclaration = cssDeclaration;
|
|
6612
6709
|
|
|
6613
6710
|
// Replace opacity custom properties
|
|
6614
|
-
const opacityProperties = [
|
|
6711
|
+
const opacityProperties = ["--text-opacity", "--bg-opacity", "--border-opacity", "--ring-opacity", "--divide-opacity", "--placeholder-opacity", "--text-decoration-opacity", "--outline-opacity", "--accent-opacity", "--caret-opacity"];
|
|
6615
6712
|
opacityProperties.forEach(prop => {
|
|
6616
|
-
const propRegex = new RegExp(`${prop}\\s*:\\s*[\\d.]+`,
|
|
6713
|
+
const propRegex = new RegExp(`${prop}\\s*:\\s*[\\d.]+`, "gi");
|
|
6617
6714
|
modifiedDeclaration = modifiedDeclaration.replace(propRegex, `${prop}: ${alphaValue}`);
|
|
6618
6715
|
});
|
|
6619
6716
|
|
|
6620
6717
|
// Also handle direct color values that might not use CSS variables
|
|
6621
|
-
const colorProperties = [
|
|
6718
|
+
const colorProperties = ["color", "background-color", "border-color", "text-decoration-color", "outline-color", "fill", "stroke", "caret-color", "accent-color"];
|
|
6622
6719
|
colorProperties.forEach(prop => {
|
|
6623
6720
|
// Match rgb(), rgba(), hsl(), hsla() functions
|
|
6624
|
-
const rgbRegex = new RegExp(`(${prop}\\s*:\\s*)rgb\\((\\d+),\\s*(\\d+),\\s*(\\d+)\\)`,
|
|
6625
|
-
const rgbaRegex = new RegExp(`(${prop}\\s*:\\s*)rgba\\((\\d+),\\s*(\\d+),\\s*(\\d+),\\s*[\\d.]+\\)`,
|
|
6626
|
-
const hslRegex = new RegExp(`(${prop}\\s*:\\s*)hsl\\((\\d+),\\s*([\\d.]+%),\\s*([\\d.]+%)\\)`,
|
|
6627
|
-
const hslaRegex = new RegExp(`(${prop}\\s*:\\s*)hsla\\((\\d+),\\s*([\\d.]+%),\\s*([\\d.]+%),\\s*[\\d.]+\\)`,
|
|
6721
|
+
const rgbRegex = new RegExp(`(${prop}\\s*:\\s*)rgb\\((\\d+),\\s*(\\d+),\\s*(\\d+)\\)`, "gi");
|
|
6722
|
+
const rgbaRegex = new RegExp(`(${prop}\\s*:\\s*)rgba\\((\\d+),\\s*(\\d+),\\s*(\\d+),\\s*[\\d.]+\\)`, "gi");
|
|
6723
|
+
const hslRegex = new RegExp(`(${prop}\\s*:\\s*)hsl\\((\\d+),\\s*([\\d.]+%),\\s*([\\d.]+%)\\)`, "gi");
|
|
6724
|
+
const hslaRegex = new RegExp(`(${prop}\\s*:\\s*)hsla\\((\\d+),\\s*([\\d.]+%),\\s*([\\d.]+%),\\s*[\\d.]+\\)`, "gi");
|
|
6628
6725
|
|
|
6629
6726
|
// Convert rgb to rgba with opacity
|
|
6630
6727
|
modifiedDeclaration = modifiedDeclaration.replace(rgbRegex, `$1rgba($2, $3, $4, ${alphaValue})`);
|
|
@@ -6639,10 +6736,10 @@ function processOpacityModifier(className, cssDeclaration) {
|
|
|
6639
6736
|
modifiedDeclaration = modifiedDeclaration.replace(hslaRegex, `$1hsla($2, $3, $4, ${alphaValue})`);
|
|
6640
6737
|
|
|
6641
6738
|
// Handle hex colors
|
|
6642
|
-
const hexRegex = new RegExp(`(${prop}\\s*:\\s*)(#[0-9a-fA-F]{3,6})`,
|
|
6643
|
-
modifiedDeclaration = modifiedDeclaration.replace(hexRegex, (
|
|
6739
|
+
const hexRegex = new RegExp(`(${prop}\\s*:\\s*)(#[0-9a-fA-F]{3,6})`, "gi");
|
|
6740
|
+
modifiedDeclaration = modifiedDeclaration.replace(hexRegex, (_, propPart, hexColor) => {
|
|
6644
6741
|
// Convert hex to rgba
|
|
6645
|
-
const hex = hexColor.replace(
|
|
6742
|
+
const hex = hexColor.replace("#", "");
|
|
6646
6743
|
let r, g, b;
|
|
6647
6744
|
if (hex.length === 3) {
|
|
6648
6745
|
r = parseInt(hex[0] + hex[0], 16);
|
|
@@ -6659,15 +6756,17 @@ function processOpacityModifier(className, cssDeclaration) {
|
|
|
6659
6756
|
return modifiedDeclaration;
|
|
6660
6757
|
}
|
|
6661
6758
|
|
|
6662
|
-
/**
|
|
6663
|
-
* Convert Tailwind class string to inline CSS styles or JSON object
|
|
6664
|
-
* @param {string} classNames - String containing Tailwind classes to convert
|
|
6665
|
-
* @param {boolean} convertToJson - If true, result will be JSON object, if false becomes CSS string
|
|
6666
|
-
* @returns {string|Object} Inline CSS string or style JSON object
|
|
6759
|
+
/**
|
|
6760
|
+
* Convert Tailwind class string to inline CSS styles or JSON object
|
|
6761
|
+
* @param {string} classNames - String containing Tailwind classes to convert
|
|
6762
|
+
* @param {boolean} convertToJson - If true, result will be JSON object, if false becomes CSS string
|
|
6763
|
+
* @returns {string|Object} Inline CSS string or style JSON object
|
|
6667
6764
|
*/
|
|
6668
6765
|
function tws(classNames, convertToJson) {
|
|
6669
6766
|
const totalMarker = performanceMonitor.start("tws:total");
|
|
6670
6767
|
try {
|
|
6768
|
+
// Ensure CSS is initialized with current global config
|
|
6769
|
+
initializeCss();
|
|
6671
6770
|
if ([!classNames, typeof classNames !== "string", classNames.trim() === ""].includes(true)) {
|
|
6672
6771
|
performanceMonitor.end(totalMarker);
|
|
6673
6772
|
return convertToJson ? {} : "";
|
|
@@ -6694,11 +6793,11 @@ function tws(classNames, convertToJson) {
|
|
|
6694
6793
|
const processMarker = performanceMonitor.start("tws:process");
|
|
6695
6794
|
let cssResult = classes.map(className => {
|
|
6696
6795
|
// Extract base class name without opacity modifier
|
|
6697
|
-
const baseClassName = className.replace(/\/\d+$/,
|
|
6796
|
+
const baseClassName = className.replace(/\/\d+$/, "");
|
|
6698
6797
|
let result = cssObject[baseClassName] || cssObject[baseClassName.replace(/(\/)/g, "\\$1")] || cssObject[baseClassName.replace(/\./g, "\\.")];
|
|
6699
6798
|
if (result) {
|
|
6700
6799
|
// Apply opacity modifier if present
|
|
6701
|
-
if (className.includes(
|
|
6800
|
+
if (className.includes("/") && /\/\d+$/.test(className)) {
|
|
6702
6801
|
result = processOpacityModifier(className, result);
|
|
6703
6802
|
}
|
|
6704
6803
|
return resolveCssToClearCss(result);
|
|
@@ -6710,7 +6809,7 @@ function tws(classNames, convertToJson) {
|
|
|
6710
6809
|
if (cssObject[`${baseKey}custom`]) {
|
|
6711
6810
|
let customResult = cssObject[`${baseKey}custom`].replace(/custom_value/g, customValue);
|
|
6712
6811
|
// Apply opacity modifier to custom values too
|
|
6713
|
-
if (className.includes(
|
|
6812
|
+
if (className.includes("/") && /\/\d+$/.test(className)) {
|
|
6714
6813
|
customResult = processOpacityModifier(className, customResult);
|
|
6715
6814
|
}
|
|
6716
6815
|
return customResult;
|
|
@@ -6846,7 +6945,7 @@ function processClass(cls, selector, styles) {
|
|
|
6846
6945
|
} = resolveVariants(selector, rawVariants);
|
|
6847
6946
|
|
|
6848
6947
|
// Extract base class name without opacity modifier for CSS lookup
|
|
6849
|
-
const baseClassName = pureClassName.replace(/\/\d+$/,
|
|
6948
|
+
const baseClassName = pureClassName.replace(/\/\d+$/, "");
|
|
6850
6949
|
let declarations = cssObject[baseClassName] || cssObject[baseClassName.replace(/(\/)/g, "\\$1")] || cssObject[baseClassName.replace(/\./g, "\\.")];
|
|
6851
6950
|
if (!declarations && baseClassName.includes("[")) {
|
|
6852
6951
|
const match = baseClassName.match(/^(.+?)\[(.+)\]$/);
|
|
@@ -6867,7 +6966,7 @@ function processClass(cls, selector, styles) {
|
|
|
6867
6966
|
}
|
|
6868
6967
|
|
|
6869
6968
|
// Apply opacity modifier if present
|
|
6870
|
-
if (pureClassName.includes(
|
|
6969
|
+
if (pureClassName.includes("/") && /\/\d+$/.test(pureClassName)) {
|
|
6871
6970
|
declarations = processOpacityModifier(pureClassName, declarations);
|
|
6872
6971
|
}
|
|
6873
6972
|
if (isImportant) {
|
|
@@ -7042,12 +7141,12 @@ function generateCssString(styles) {
|
|
|
7042
7141
|
return cssString.trim();
|
|
7043
7142
|
}
|
|
7044
7143
|
|
|
7045
|
-
/**
|
|
7046
|
-
* Generate CSS string from style object with SCSS-like syntax
|
|
7047
|
-
* Supports nested selectors, state variants, responsive variants, and @css directives
|
|
7048
|
-
* @param {Object} obj - Object with SCSS-like style format
|
|
7049
|
-
* @param {Object} [options] - Additional options,
|
|
7050
|
-
* @returns {string} Generated CSS string
|
|
7144
|
+
/**
|
|
7145
|
+
* Generate CSS string from style object with SCSS-like syntax
|
|
7146
|
+
* Supports nested selectors, state variants, responsive variants, and @css directives
|
|
7147
|
+
* @param {Object} obj - Object with SCSS-like style format
|
|
7148
|
+
* @param {Object} [options] - Additional options, merges with global config
|
|
7149
|
+
* @returns {string} Generated CSS string
|
|
7051
7150
|
*/
|
|
7052
7151
|
function twsx(obj) {
|
|
7053
7152
|
let options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
@@ -7057,9 +7156,13 @@ function twsx(obj) {
|
|
|
7057
7156
|
console.warn("twsx: Expected an object but received:", obj);
|
|
7058
7157
|
return "";
|
|
7059
7158
|
}
|
|
7159
|
+
const mergedOptions = {
|
|
7160
|
+
...globalConfig,
|
|
7161
|
+
...options
|
|
7162
|
+
};
|
|
7060
7163
|
const {
|
|
7061
7164
|
inject = true
|
|
7062
|
-
} =
|
|
7165
|
+
} = mergedOptions;
|
|
7063
7166
|
const styles = {};
|
|
7064
7167
|
|
|
7065
7168
|
// Create walk function with closure over styles
|
|
@@ -7154,19 +7257,19 @@ function autoInjectCss(cssString) {
|
|
|
7154
7257
|
}
|
|
7155
7258
|
|
|
7156
7259
|
// Enhanced debounced functions with performance monitoring configuration
|
|
7157
|
-
/**
|
|
7158
|
-
* Debounced version of tws function with performance monitoring
|
|
7159
|
-
* @param {string} classNames - String containing Tailwind classes to convert
|
|
7160
|
-
* @param {boolean} convertToJson - If true, result will be JSON object, if false becomes CSS string
|
|
7161
|
-
* @returns {string|Object} Inline CSS string or style JSON object
|
|
7260
|
+
/**
|
|
7261
|
+
* Debounced version of tws function with performance monitoring
|
|
7262
|
+
* @param {string} classNames - String containing Tailwind classes to convert
|
|
7263
|
+
* @param {boolean} convertToJson - If true, result will be JSON object, if false becomes CSS string
|
|
7264
|
+
* @returns {string|Object} Inline CSS string or style JSON object
|
|
7162
7265
|
*/
|
|
7163
7266
|
const debouncedTws = debounce(tws, 50); // Faster debounce for tws
|
|
7164
7267
|
|
|
7165
|
-
/**
|
|
7166
|
-
* Debounced version of twsx function with performance monitoring
|
|
7167
|
-
* @param {Object} obj - Object with SCSS-like style format
|
|
7168
|
-
* @param {Object} [options] - Additional options
|
|
7169
|
-
* @returns {string} Generated CSS string
|
|
7268
|
+
/**
|
|
7269
|
+
* Debounced version of twsx function with performance monitoring
|
|
7270
|
+
* @param {Object} obj - Object with SCSS-like style format
|
|
7271
|
+
* @param {Object} [options] - Additional options
|
|
7272
|
+
* @returns {string} Generated CSS string
|
|
7170
7273
|
*/
|
|
7171
7274
|
const debouncedTwsx = debounce(twsx, 100); // Standard debounce for twsx
|
|
7172
7275
|
|
|
@@ -7198,12 +7301,15 @@ const performanceUtils = {
|
|
|
7198
7301
|
enablePerformanceLogging() {
|
|
7199
7302
|
let enabled = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : true;
|
|
7200
7303
|
performanceMonitor.enabled = enabled && typeof performance !== "undefined";
|
|
7201
|
-
console.log(`Performance monitoring ${enabled ?
|
|
7304
|
+
console.log(`Performance monitoring ${enabled ? "enabled" : "disabled"}`);
|
|
7202
7305
|
}
|
|
7203
7306
|
};
|
|
7204
7307
|
|
|
7205
7308
|
exports.debouncedTws = debouncedTws;
|
|
7206
7309
|
exports.debouncedTwsx = debouncedTwsx;
|
|
7310
|
+
exports.getConfig = getConfig;
|
|
7207
7311
|
exports.performanceUtils = performanceUtils;
|
|
7312
|
+
exports.resetConfig = resetConfig;
|
|
7313
|
+
exports.setConfig = setConfig;
|
|
7208
7314
|
exports.tws = tws;
|
|
7209
7315
|
exports.twsx = twsx;
|
package/dist/index.d.ts
CHANGED
|
@@ -7,6 +7,18 @@ export interface TwsxOptions {
|
|
|
7
7
|
[key: string]: any;
|
|
8
8
|
}
|
|
9
9
|
|
|
10
|
+
export interface GlobalConfig {
|
|
11
|
+
theme: {
|
|
12
|
+
extend: {
|
|
13
|
+
colors: Record<string, string | Record<string, string>>;
|
|
14
|
+
[key: string]: any;
|
|
15
|
+
};
|
|
16
|
+
screens: Record<string, string>;
|
|
17
|
+
[key: string]: any;
|
|
18
|
+
};
|
|
19
|
+
inject: boolean;
|
|
20
|
+
}
|
|
21
|
+
|
|
10
22
|
export interface PerformanceStats {
|
|
11
23
|
cacheStats: {
|
|
12
24
|
cssResolution: number;
|
|
@@ -44,24 +56,37 @@ export function tws(classNames: string, convertToJson?: boolean): string | Recor
|
|
|
44
56
|
* Generates CSS string from style object with SCSS-like syntax
|
|
45
57
|
* Supports nested selectors, state variants, responsive variants, and @css directives
|
|
46
58
|
* @param obj - Object with SCSS-like style format
|
|
47
|
-
* @param options - Additional options
|
|
59
|
+
* @param options - Additional options, merges with global config
|
|
48
60
|
* @returns Generated CSS string
|
|
49
61
|
*/
|
|
50
62
|
export function twsx(obj: StyleObject, options?: TwsxOptions): string;
|
|
51
63
|
|
|
64
|
+
/**
|
|
65
|
+
* Set global configuration for both tws and twsx
|
|
66
|
+
* @param config - Global configuration object
|
|
67
|
+
* @returns Current global configuration
|
|
68
|
+
*/
|
|
69
|
+
export function setConfig(config: Partial<GlobalConfig>): GlobalConfig;
|
|
70
|
+
|
|
71
|
+
/**
|
|
72
|
+
* Get current global configuration for both tws and twsx
|
|
73
|
+
* @returns Current global configuration
|
|
74
|
+
*/
|
|
75
|
+
export function getConfig(): GlobalConfig;
|
|
76
|
+
|
|
77
|
+
/**
|
|
78
|
+
* Reset global configuration to default
|
|
79
|
+
* @returns Default configuration
|
|
80
|
+
*/
|
|
81
|
+
export function resetConfig(): GlobalConfig;
|
|
82
|
+
|
|
52
83
|
/**
|
|
53
84
|
* Debounced version of tws function with performance monitoring
|
|
54
|
-
* @param classNames - String containing Tailwind classes to convert
|
|
55
|
-
* @param convertToJson - If true, returns JSON object, if false returns CSS string
|
|
56
|
-
* @returns CSS inline string or style JSON object
|
|
57
85
|
*/
|
|
58
86
|
export const debouncedTws: typeof tws;
|
|
59
87
|
|
|
60
88
|
/**
|
|
61
89
|
* Debounced version of twsx function with performance monitoring
|
|
62
|
-
* @param obj - Object with SCSS-like style format
|
|
63
|
-
* @param options - Additional options
|
|
64
|
-
* @returns Generated CSS string
|
|
65
90
|
*/
|
|
66
91
|
export const debouncedTwsx: typeof twsx;
|
|
67
92
|
|