tailwind-merge
Advanced tools
Comparing version 0.5.1 to 0.5.2
@@ -34,7 +34,3 @@ import HLRU from 'hashlru'; | ||
function createClassUtils(config) { | ||
const classMap = { | ||
nextPart: {}, | ||
validators: [] | ||
}; | ||
processClassGroups(config, classMap); | ||
const classMap = createClassMap(config); | ||
@@ -85,7 +81,16 @@ function getClassGroupId(className) { | ||
} | ||
/** | ||
* Exported for testing only | ||
*/ | ||
function processClassGroups(config, classMap) { | ||
function createClassMap(config) { | ||
const classMap = { | ||
nextPart: {}, | ||
validators: [] | ||
}; | ||
Object.entries(config.classGroups).forEach(([classGroupId, classGroup]) => { | ||
processClassesRecursively(classGroup, classMap, classGroupId); | ||
}); | ||
return classMap; | ||
} | ||
@@ -162,2 +167,5 @@ | ||
function isLength(classPart) { | ||
return isCustomLength(classPart) || !Number.isNaN(Number(classPart)) || stringLengths.has(classPart) || fractionRegex.test(classPart); | ||
} | ||
function isCustomLength(classPart) { | ||
var _customValueRegex$exe; | ||
@@ -171,3 +179,3 @@ | ||
return !Number.isNaN(Number(classPart)) || stringLengths.has(classPart) || fractionRegex.test(classPart); | ||
return false; | ||
} | ||
@@ -203,3 +211,3 @@ function isInteger(classPart) { | ||
const POSITIONS = ['bottom', 'center', 'left', 'left-bottom', 'left-top', 'right', 'right-bottom', 'right-top', 'top']; | ||
const ROUNDED = ['none', '', ...SIZES_SIMPLE, '3xl', 'full']; | ||
const ROUNDED = ['none', '', ...SIZES_SIMPLE, '3xl', 'full', isCustomLength]; | ||
const BORDER_STYLES = ['solid', 'dashed', 'dotted', 'double', 'none']; | ||
@@ -439,3 +447,3 @@ const BLEND_MODES = [{ | ||
flex: [{ | ||
flex: ['1', 'auto', 'initial', 'none'] | ||
flex: ['1', 'auto', 'initial', 'none', isCustomValue] | ||
}], | ||
@@ -853,3 +861,3 @@ | ||
'font-family': [{ | ||
font: ['sans', 'serif', 'mono'] | ||
font: ANY | ||
}], | ||
@@ -862,3 +870,3 @@ | ||
'font-size': [{ | ||
text: ['xs', ...SIZES_SIMPLE, 'base', ...SIZES_EXTENDED, '8xl', '9xl'] | ||
text: ['xs', ...SIZES_SIMPLE, 'base', ...SIZES_EXTENDED, '8xl', '9xl', isCustomLength] | ||
}], | ||
@@ -890,5 +898,35 @@ | ||
*/ | ||
'font-variant-numeric': ['normal-nums', 'ordinal', 'slashed-zero', 'lining-nums', 'oldstyle-nums', 'tabular-nums', 'diagonal-nums', 'stacked-fractons'], | ||
'fvn-normal': ['normal-nums'], | ||
/** | ||
* Font Variant Numeric | ||
* @see https://tailwindcss.com/docs/font-variant-numeric | ||
*/ | ||
'fvn-ordinal': ['ordinal'], | ||
/** | ||
* Font Variant Numeric | ||
* @see https://tailwindcss.com/docs/font-variant-numeric | ||
*/ | ||
'fvn-slashed-zero': ['slashed-zero'], | ||
/** | ||
* Font Variant Numeric | ||
* @see https://tailwindcss.com/docs/font-variant-numeric | ||
*/ | ||
'fvn-figure': ['lining-nums', 'oldstyle-nums'], | ||
/** | ||
* Font Variant Numeric | ||
* @see https://tailwindcss.com/docs/font-variant-numeric | ||
*/ | ||
'fvn-spacing': ['proportional-nums', 'tabular-nums'], | ||
/** | ||
* Font Variant Numeric | ||
* @see https://tailwindcss.com/docs/font-variant-numeric | ||
*/ | ||
'fvn-fraction': ['diagonal-fractions', 'stacked-fractons'], | ||
/** | ||
* Letter Spacing | ||
@@ -898,3 +936,3 @@ * @see https://tailwindcss.com/docs/letter-spacing | ||
tracking: [{ | ||
tracking: ['tighter', 'tight', 'normal', 'wide', 'wider', 'widest'] | ||
tracking: ['tighter', 'tight', 'normal', 'wide', 'wider', 'widest', isCustomLength] | ||
}], | ||
@@ -1423,3 +1461,3 @@ | ||
blur: [{ | ||
blur: ['none', '', ...SIZES_SIMPLE, '3xl'] | ||
blur: ['none', '', ...SIZES_SIMPLE, '3xl', isCustomLength] | ||
}], | ||
@@ -1722,3 +1760,3 @@ | ||
cursor: [{ | ||
cursor: ['auto', 'default', 'pointer', 'wait', 'text', 'move', 'help', 'not-allowed'] | ||
cursor: ['auto', 'default', 'pointer', 'wait', 'text', 'move', 'help', 'not-allowed', isCustomValue] | ||
}], | ||
@@ -1822,2 +1860,8 @@ | ||
'font-size': ['leading'], | ||
'fvn-normal': ['fvn-ordinal', 'fvn-slashed-zero', 'fvn-figure', 'fvn-spacing', 'fvn-fraction'], | ||
'fvn-ordinal': ['fvn-normal'], | ||
'fvn-slashed-zero': ['fvn-normal'], | ||
'fvn-figure': ['fvn-normal'], | ||
'fvn-spacing': ['fvn-normal'], | ||
'fvn-fraction': ['fvn-normal'], | ||
rounded: ['rounded-t', 'rounded-r', 'rounded-b', 'rounded-l', 'rounded-tl', 'rounded-tr', 'rounded-br', 'rounded-bl'], | ||
@@ -1824,0 +1868,0 @@ 'rounded-t': ['rounded-tl', 'rounded-tr'], |
@@ -36,7 +36,3 @@ import HLRU from 'hashlru'; | ||
function createClassUtils(config) { | ||
var classMap = { | ||
nextPart: {}, | ||
validators: [] | ||
}; | ||
processClassGroups(config, classMap); | ||
var classMap = createClassMap(config); | ||
@@ -88,4 +84,12 @@ function getClassGroupId(className) { | ||
} | ||
/** | ||
* Exported for testing only | ||
*/ | ||
function processClassGroups(config, classMap) { | ||
function createClassMap(config) { | ||
var classMap = { | ||
nextPart: {}, | ||
validators: [] | ||
}; | ||
Object.entries(config.classGroups).forEach(function (_ref2) { | ||
@@ -96,2 +100,3 @@ var classGroupId = _ref2[0], | ||
}); | ||
return classMap; | ||
} | ||
@@ -180,2 +185,5 @@ | ||
function isLength(classPart) { | ||
return isCustomLength(classPart) || !Number.isNaN(Number(classPart)) || stringLengths.has(classPart) || fractionRegex.test(classPart); | ||
} | ||
function isCustomLength(classPart) { | ||
var _customValueRegex$exe; | ||
@@ -189,3 +197,3 @@ | ||
return !Number.isNaN(Number(classPart)) || stringLengths.has(classPart) || fractionRegex.test(classPart); | ||
return false; | ||
} | ||
@@ -221,3 +229,3 @@ function isInteger(classPart) { | ||
var POSITIONS = ['bottom', 'center', 'left', 'left-bottom', 'left-top', 'right', 'right-bottom', 'right-top', 'top']; | ||
var ROUNDED = ['none', ''].concat(SIZES_SIMPLE, ['3xl', 'full']); | ||
var ROUNDED = ['none', ''].concat(SIZES_SIMPLE, ['3xl', 'full', isCustomLength]); | ||
var BORDER_STYLES = ['solid', 'dashed', 'dotted', 'double', 'none']; | ||
@@ -457,3 +465,3 @@ var BLEND_MODES = [{ | ||
flex: [{ | ||
flex: ['1', 'auto', 'initial', 'none'] | ||
flex: ['1', 'auto', 'initial', 'none', isCustomValue] | ||
}], | ||
@@ -871,3 +879,3 @@ | ||
'font-family': [{ | ||
font: ['sans', 'serif', 'mono'] | ||
font: ANY | ||
}], | ||
@@ -880,3 +888,3 @@ | ||
'font-size': [{ | ||
text: ['xs'].concat(SIZES_SIMPLE, ['base'], SIZES_EXTENDED, ['8xl', '9xl']) | ||
text: ['xs'].concat(SIZES_SIMPLE, ['base'], SIZES_EXTENDED, ['8xl', '9xl', isCustomLength]) | ||
}], | ||
@@ -908,5 +916,35 @@ | ||
*/ | ||
'font-variant-numeric': ['normal-nums', 'ordinal', 'slashed-zero', 'lining-nums', 'oldstyle-nums', 'tabular-nums', 'diagonal-nums', 'stacked-fractons'], | ||
'fvn-normal': ['normal-nums'], | ||
/** | ||
* Font Variant Numeric | ||
* @see https://tailwindcss.com/docs/font-variant-numeric | ||
*/ | ||
'fvn-ordinal': ['ordinal'], | ||
/** | ||
* Font Variant Numeric | ||
* @see https://tailwindcss.com/docs/font-variant-numeric | ||
*/ | ||
'fvn-slashed-zero': ['slashed-zero'], | ||
/** | ||
* Font Variant Numeric | ||
* @see https://tailwindcss.com/docs/font-variant-numeric | ||
*/ | ||
'fvn-figure': ['lining-nums', 'oldstyle-nums'], | ||
/** | ||
* Font Variant Numeric | ||
* @see https://tailwindcss.com/docs/font-variant-numeric | ||
*/ | ||
'fvn-spacing': ['proportional-nums', 'tabular-nums'], | ||
/** | ||
* Font Variant Numeric | ||
* @see https://tailwindcss.com/docs/font-variant-numeric | ||
*/ | ||
'fvn-fraction': ['diagonal-fractions', 'stacked-fractons'], | ||
/** | ||
* Letter Spacing | ||
@@ -916,3 +954,3 @@ * @see https://tailwindcss.com/docs/letter-spacing | ||
tracking: [{ | ||
tracking: ['tighter', 'tight', 'normal', 'wide', 'wider', 'widest'] | ||
tracking: ['tighter', 'tight', 'normal', 'wide', 'wider', 'widest', isCustomLength] | ||
}], | ||
@@ -1441,3 +1479,3 @@ | ||
blur: [{ | ||
blur: ['none', ''].concat(SIZES_SIMPLE, ['3xl']) | ||
blur: ['none', ''].concat(SIZES_SIMPLE, ['3xl', isCustomLength]) | ||
}], | ||
@@ -1740,3 +1778,3 @@ | ||
cursor: [{ | ||
cursor: ['auto', 'default', 'pointer', 'wait', 'text', 'move', 'help', 'not-allowed'] | ||
cursor: ['auto', 'default', 'pointer', 'wait', 'text', 'move', 'help', 'not-allowed', isCustomValue] | ||
}], | ||
@@ -1840,2 +1878,8 @@ | ||
'font-size': ['leading'], | ||
'fvn-normal': ['fvn-ordinal', 'fvn-slashed-zero', 'fvn-figure', 'fvn-spacing', 'fvn-fraction'], | ||
'fvn-ordinal': ['fvn-normal'], | ||
'fvn-slashed-zero': ['fvn-normal'], | ||
'fvn-figure': ['fvn-normal'], | ||
'fvn-spacing': ['fvn-normal'], | ||
'fvn-fraction': ['fvn-normal'], | ||
rounded: ['rounded-t', 'rounded-r', 'rounded-b', 'rounded-l', 'rounded-tl', 'rounded-tr', 'rounded-br', 'rounded-bl'], | ||
@@ -1842,0 +1886,0 @@ 'rounded-t': ['rounded-tl', 'rounded-tr'], |
@@ -1,2 +0,11 @@ | ||
import { ClassGroupId, Config } from './types'; | ||
import { ClassGroupId, Config, ClassValidator } from './types'; | ||
export interface ClassPartObject { | ||
nextPart: Record<string, ClassPartObject>; | ||
validators: ClassValidatorObject[]; | ||
classGroupId?: ClassGroupId; | ||
} | ||
interface ClassValidatorObject { | ||
classGroupId: ClassGroupId; | ||
validator: ClassValidator; | ||
} | ||
export declare function createClassUtils(config: Config): { | ||
@@ -6,1 +15,6 @@ getClassGroupId: (className: string) => string | undefined; | ||
}; | ||
/** | ||
* Exported for testing only | ||
*/ | ||
export declare function createClassMap(config: Config): ClassPartObject; | ||
export {}; |
export declare function isLength(classPart: string): boolean; | ||
export declare function isCustomLength(classPart: string): boolean; | ||
export declare function isInteger(classPart: string): boolean; | ||
export declare function isCustomValue(classPart: string): boolean; | ||
export declare function isAny(): boolean; |
@@ -1,2 +0,2 @@ | ||
import { isAny, isCustomValue, isInteger, isLength } from './config-validators'; | ||
import { isAny, isCustomLength, isCustomValue, isInteger, isLength } from './config-validators'; | ||
export declare function getDefaultConfig(): { | ||
@@ -193,3 +193,3 @@ readonly cacheSize: 500; | ||
readonly flex: readonly [{ | ||
readonly flex: readonly ["1", "auto", "initial", "none"]; | ||
readonly flex: readonly ["1", "auto", "initial", "none", typeof isCustomValue]; | ||
}]; | ||
@@ -553,3 +553,3 @@ /** | ||
readonly 'font-family': readonly [{ | ||
readonly font: readonly ["sans", "serif", "mono"]; | ||
readonly font: readonly [typeof isAny]; | ||
}]; | ||
@@ -561,3 +561,3 @@ /** | ||
readonly 'font-size': readonly [{ | ||
readonly text: readonly ["xs", "sm", "md", "lg", "xl", "2xl", "base", "3xl", "4xl", "5xl", "6xl", "7xl", "8xl", "9xl"]; | ||
readonly text: readonly ["xs", "sm", "md", "lg", "xl", "2xl", "base", "3xl", "4xl", "5xl", "6xl", "7xl", "8xl", "9xl", typeof isCustomLength]; | ||
}]; | ||
@@ -585,4 +585,29 @@ /** | ||
*/ | ||
readonly 'font-variant-numeric': readonly ["normal-nums", "ordinal", "slashed-zero", "lining-nums", "oldstyle-nums", "tabular-nums", "diagonal-nums", "stacked-fractons"]; | ||
readonly 'fvn-normal': readonly ["normal-nums"]; | ||
/** | ||
* Font Variant Numeric | ||
* @see https://tailwindcss.com/docs/font-variant-numeric | ||
*/ | ||
readonly 'fvn-ordinal': readonly ["ordinal"]; | ||
/** | ||
* Font Variant Numeric | ||
* @see https://tailwindcss.com/docs/font-variant-numeric | ||
*/ | ||
readonly 'fvn-slashed-zero': readonly ["slashed-zero"]; | ||
/** | ||
* Font Variant Numeric | ||
* @see https://tailwindcss.com/docs/font-variant-numeric | ||
*/ | ||
readonly 'fvn-figure': readonly ["lining-nums", "oldstyle-nums"]; | ||
/** | ||
* Font Variant Numeric | ||
* @see https://tailwindcss.com/docs/font-variant-numeric | ||
*/ | ||
readonly 'fvn-spacing': readonly ["proportional-nums", "tabular-nums"]; | ||
/** | ||
* Font Variant Numeric | ||
* @see https://tailwindcss.com/docs/font-variant-numeric | ||
*/ | ||
readonly 'fvn-fraction': readonly ["diagonal-fractions", "stacked-fractons"]; | ||
/** | ||
* Letter Spacing | ||
@@ -592,3 +617,3 @@ * @see https://tailwindcss.com/docs/letter-spacing | ||
readonly tracking: readonly [{ | ||
readonly tracking: readonly ["tighter", "tight", "normal", "wide", "wider", "widest"]; | ||
readonly tracking: readonly ["tighter", "tight", "normal", "wide", "wider", "widest", typeof isCustomLength]; | ||
}]; | ||
@@ -789,3 +814,3 @@ /** | ||
readonly rounded: readonly [{ | ||
readonly rounded: readonly ["none", "", "sm", "md", "lg", "xl", "2xl", "3xl", "full"]; | ||
readonly rounded: readonly ["none", "", "sm", "md", "lg", "xl", "2xl", "3xl", "full", typeof isCustomLength]; | ||
}]; | ||
@@ -797,3 +822,3 @@ /** | ||
readonly 'rounded-t': readonly [{ | ||
readonly 'rounded-t': readonly ["none", "", "sm", "md", "lg", "xl", "2xl", "3xl", "full"]; | ||
readonly 'rounded-t': readonly ["none", "", "sm", "md", "lg", "xl", "2xl", "3xl", "full", typeof isCustomLength]; | ||
}]; | ||
@@ -805,3 +830,3 @@ /** | ||
readonly 'rounded-r': readonly [{ | ||
readonly 'rounded-r': readonly ["none", "", "sm", "md", "lg", "xl", "2xl", "3xl", "full"]; | ||
readonly 'rounded-r': readonly ["none", "", "sm", "md", "lg", "xl", "2xl", "3xl", "full", typeof isCustomLength]; | ||
}]; | ||
@@ -813,3 +838,3 @@ /** | ||
readonly 'rounded-b': readonly [{ | ||
readonly 'rounded-b': readonly ["none", "", "sm", "md", "lg", "xl", "2xl", "3xl", "full"]; | ||
readonly 'rounded-b': readonly ["none", "", "sm", "md", "lg", "xl", "2xl", "3xl", "full", typeof isCustomLength]; | ||
}]; | ||
@@ -821,3 +846,3 @@ /** | ||
readonly 'rounded-l': readonly [{ | ||
readonly 'rounded-l': readonly ["none", "", "sm", "md", "lg", "xl", "2xl", "3xl", "full"]; | ||
readonly 'rounded-l': readonly ["none", "", "sm", "md", "lg", "xl", "2xl", "3xl", "full", typeof isCustomLength]; | ||
}]; | ||
@@ -829,3 +854,3 @@ /** | ||
readonly 'rounded-tl': readonly [{ | ||
readonly 'rounded-tl': readonly ["none", "", "sm", "md", "lg", "xl", "2xl", "3xl", "full"]; | ||
readonly 'rounded-tl': readonly ["none", "", "sm", "md", "lg", "xl", "2xl", "3xl", "full", typeof isCustomLength]; | ||
}]; | ||
@@ -837,3 +862,3 @@ /** | ||
readonly 'rounded-tr': readonly [{ | ||
readonly 'rounded-tr': readonly ["none", "", "sm", "md", "lg", "xl", "2xl", "3xl", "full"]; | ||
readonly 'rounded-tr': readonly ["none", "", "sm", "md", "lg", "xl", "2xl", "3xl", "full", typeof isCustomLength]; | ||
}]; | ||
@@ -845,3 +870,3 @@ /** | ||
readonly 'rounded-br': readonly [{ | ||
readonly 'rounded-br': readonly ["none", "", "sm", "md", "lg", "xl", "2xl", "3xl", "full"]; | ||
readonly 'rounded-br': readonly ["none", "", "sm", "md", "lg", "xl", "2xl", "3xl", "full", typeof isCustomLength]; | ||
}]; | ||
@@ -853,3 +878,3 @@ /** | ||
readonly 'rounded-bl': readonly [{ | ||
readonly 'rounded-bl': readonly ["none", "", "sm", "md", "lg", "xl", "2xl", "3xl", "full"]; | ||
readonly 'rounded-bl': readonly ["none", "", "sm", "md", "lg", "xl", "2xl", "3xl", "full", typeof isCustomLength]; | ||
}]; | ||
@@ -1060,3 +1085,3 @@ /** | ||
readonly blur: readonly [{ | ||
readonly blur: readonly ["none", "", "sm", "md", "lg", "xl", "2xl", "3xl"]; | ||
readonly blur: readonly ["none", "", "sm", "md", "lg", "xl", "2xl", "3xl", typeof isCustomLength]; | ||
}]; | ||
@@ -1318,3 +1343,3 @@ /** | ||
readonly cursor: readonly [{ | ||
readonly cursor: readonly ["auto", "default", "pointer", "wait", "text", "move", "help", "not-allowed"]; | ||
readonly cursor: readonly ["auto", "default", "pointer", "wait", "text", "move", "help", "not-allowed", typeof isCustomValue]; | ||
}]; | ||
@@ -1405,2 +1430,8 @@ /** | ||
readonly 'font-size': readonly ["leading"]; | ||
readonly 'fvn-normal': readonly ["fvn-ordinal", "fvn-slashed-zero", "fvn-figure", "fvn-spacing", "fvn-fraction"]; | ||
readonly 'fvn-ordinal': readonly ["fvn-normal"]; | ||
readonly 'fvn-slashed-zero': readonly ["fvn-normal"]; | ||
readonly 'fvn-figure': readonly ["fvn-normal"]; | ||
readonly 'fvn-spacing': readonly ["fvn-normal"]; | ||
readonly 'fvn-fraction': readonly ["fvn-normal"]; | ||
readonly rounded: readonly ["rounded-t", "rounded-r", "rounded-b", "rounded-l", "rounded-tl", "rounded-tr", "rounded-br", "rounded-bl"]; | ||
@@ -1407,0 +1438,0 @@ readonly 'rounded-t': readonly ["rounded-tl", "rounded-tr"]; |
{ | ||
"name": "tailwind-merge", | ||
"version": "0.5.1", | ||
"version": "0.5.2", | ||
"description": "Merge Tailwind CSS classes without style conflicts", | ||
@@ -42,4 +42,5 @@ "keywords": [ | ||
"lint": "eslint --max-warnings 0 '**'", | ||
"preversion-paused": "git checkout main && git pull", | ||
"version": "zx scripts/update-readme.js", | ||
"postversion": "git push --follow-tags && open https://github.com/dcastil/tailwind-merge/releases" | ||
"postversion-paused": "git push --follow-tags && open https://github.com/dcastil/tailwind-merge/releases" | ||
}, | ||
@@ -64,3 +65,4 @@ "dependencies": { | ||
"zx": "^2.0.0" | ||
} | ||
}, | ||
"packageManager": "yarn@3.0.1" | ||
} |
<div align="center"> | ||
<br /> | ||
<a href="https://github.com/dcastil/tailwind-merge"> | ||
<!-- AUTOGENERATED START logo-image --><img src="https://github.com/dcastil/tailwind-merge/raw/v0.5.1/assets/logo.svg" alt="tailwind-merge" width="221px" /><!-- AUTOGENERATED END --> | ||
<!-- AUTOGENERATED START logo-image --><img src="https://github.com/dcastil/tailwind-merge/raw/v0.5.2/assets/logo.svg" alt="tailwind-merge" width="221px" /><!-- AUTOGENERATED END --> | ||
</a> | ||
@@ -22,3 +22,3 @@ </div> | ||
- Fully typed | ||
- [<!-- AUTOGENERATED START package-gzip-size -->4.7 kB<!-- AUTOGENERATED END --> minified + gzipped](https://bundlephobia.com/package/tailwind-merge) (<!-- AUTOGENERATED START package-composition -->96.1% self, 3.9% hashlru<!-- AUTOGENERATED END -->) | ||
- [<!-- AUTOGENERATED START package-gzip-size -->4.8 kB<!-- AUTOGENERATED END --> minified + gzipped](https://bundlephobia.com/package/tailwind-merge) (<!-- AUTOGENERATED START package-composition -->96.2% self, 3.8% hashlru<!-- AUTOGENERATED END -->) | ||
@@ -25,0 +25,0 @@ ## Early development |
import { ClassGroupId, Config, ClassGroup, ClassValidator } from './types' | ||
interface ClassPartObject { | ||
export interface ClassPartObject { | ||
nextPart: Record<string, ClassPartObject> | ||
@@ -17,9 +17,4 @@ validators: ClassValidatorObject[] | ||
export function createClassUtils(config: Config) { | ||
const classMap: ClassPartObject = { | ||
nextPart: {}, | ||
validators: [], | ||
} | ||
const classMap = createClassMap(config) | ||
processClassGroups(config, classMap) | ||
function getClassGroupId(className: string) { | ||
@@ -73,6 +68,16 @@ const classParts = className.split(CLASS_PART_SEPARATOR) | ||
function processClassGroups(config: Config, classMap: ClassPartObject) { | ||
/** | ||
* Exported for testing only | ||
*/ | ||
export function createClassMap(config: Config) { | ||
const classMap: ClassPartObject = { | ||
nextPart: {}, | ||
validators: [], | ||
} | ||
Object.entries(config.classGroups).forEach(([classGroupId, classGroup]) => { | ||
processClassesRecursively(classGroup, classMap, classGroupId) | ||
}) | ||
return classMap | ||
} | ||
@@ -79,0 +84,0 @@ |
@@ -7,2 +7,11 @@ const customValueRegex = /^\[(.+)\]$/ | ||
export function isLength(classPart: string) { | ||
return ( | ||
isCustomLength(classPart) || | ||
!Number.isNaN(Number(classPart)) || | ||
stringLengths.has(classPart) || | ||
fractionRegex.test(classPart) | ||
) | ||
} | ||
export function isCustomLength(classPart: string) { | ||
const customValue = customValueRegex.exec(classPart)?.[1] | ||
@@ -14,7 +23,3 @@ | ||
return ( | ||
!Number.isNaN(Number(classPart)) || | ||
stringLengths.has(classPart) || | ||
fractionRegex.test(classPart) | ||
) | ||
return false | ||
} | ||
@@ -21,0 +26,0 @@ |
@@ -1,2 +0,2 @@ | ||
import { isAny, isCustomValue, isInteger, isLength } from './config-validators' | ||
import { isAny, isCustomLength, isCustomValue, isInteger, isLength } from './config-validators' | ||
@@ -24,3 +24,3 @@ const SIZES_SIMPLE = ['sm', 'md', 'lg', 'xl', '2xl'] as const | ||
] as const | ||
const ROUNDED = ['none', '', ...SIZES_SIMPLE, '3xl', 'full'] as const | ||
const ROUNDED = ['none', '', ...SIZES_SIMPLE, '3xl', 'full', isCustomLength] as const | ||
const BORDER_STYLES = ['solid', 'dashed', 'dotted', 'double', 'none'] as const | ||
@@ -275,3 +275,3 @@ const BLEND_MODES = [ | ||
*/ | ||
flex: [{ flex: ['1', 'auto', 'initial', 'none'] }], | ||
flex: [{ flex: ['1', 'auto', 'initial', 'none', isCustomValue] }], | ||
/** | ||
@@ -548,3 +548,3 @@ * Flex Grow | ||
*/ | ||
'font-family': [{ font: ['sans', 'serif', 'mono'] }], | ||
'font-family': [{ font: ANY }], | ||
/** | ||
@@ -555,3 +555,13 @@ * Font Size | ||
'font-size': [ | ||
{ text: ['xs', ...SIZES_SIMPLE, 'base', ...SIZES_EXTENDED, '8xl', '9xl'] }, | ||
{ | ||
text: [ | ||
'xs', | ||
...SIZES_SIMPLE, | ||
'base', | ||
...SIZES_EXTENDED, | ||
'8xl', | ||
'9xl', | ||
isCustomLength, | ||
], | ||
}, | ||
], | ||
@@ -591,17 +601,45 @@ /** | ||
*/ | ||
'font-variant-numeric': [ | ||
'normal-nums', | ||
'ordinal', | ||
'slashed-zero', | ||
'lining-nums', | ||
'oldstyle-nums', | ||
'tabular-nums', | ||
'diagonal-nums', | ||
'stacked-fractons', | ||
], | ||
'fvn-normal': ['normal-nums'], | ||
/** | ||
* Font Variant Numeric | ||
* @see https://tailwindcss.com/docs/font-variant-numeric | ||
*/ | ||
'fvn-ordinal': ['ordinal'], | ||
/** | ||
* Font Variant Numeric | ||
* @see https://tailwindcss.com/docs/font-variant-numeric | ||
*/ | ||
'fvn-slashed-zero': ['slashed-zero'], | ||
/** | ||
* Font Variant Numeric | ||
* @see https://tailwindcss.com/docs/font-variant-numeric | ||
*/ | ||
'fvn-figure': ['lining-nums', 'oldstyle-nums'], | ||
/** | ||
* Font Variant Numeric | ||
* @see https://tailwindcss.com/docs/font-variant-numeric | ||
*/ | ||
'fvn-spacing': ['proportional-nums', 'tabular-nums'], | ||
/** | ||
* Font Variant Numeric | ||
* @see https://tailwindcss.com/docs/font-variant-numeric | ||
*/ | ||
'fvn-fraction': ['diagonal-fractions', 'stacked-fractons'], | ||
/** | ||
* Letter Spacing | ||
* @see https://tailwindcss.com/docs/letter-spacing | ||
*/ | ||
tracking: [{ tracking: ['tighter', 'tight', 'normal', 'wide', 'wider', 'widest'] }], | ||
tracking: [ | ||
{ | ||
tracking: [ | ||
'tighter', | ||
'tight', | ||
'normal', | ||
'wide', | ||
'wider', | ||
'widest', | ||
isCustomLength, | ||
], | ||
}, | ||
], | ||
/** | ||
@@ -946,3 +984,3 @@ * Line Height | ||
*/ | ||
blur: [{ blur: ['none', '', ...SIZES_SIMPLE, '3xl'] }], | ||
blur: [{ blur: ['none', '', ...SIZES_SIMPLE, '3xl', isCustomLength] }], | ||
/** | ||
@@ -1163,2 +1201,3 @@ * Brightness | ||
'not-allowed', | ||
isCustomValue, | ||
], | ||
@@ -1238,2 +1277,14 @@ }, | ||
'font-size': ['leading'], | ||
'fvn-normal': [ | ||
'fvn-ordinal', | ||
'fvn-slashed-zero', | ||
'fvn-figure', | ||
'fvn-spacing', | ||
'fvn-fraction', | ||
], | ||
'fvn-ordinal': ['fvn-normal'], | ||
'fvn-slashed-zero': ['fvn-normal'], | ||
'fvn-figure': ['fvn-normal'], | ||
'fvn-spacing': ['fvn-normal'], | ||
'fvn-fraction': ['fvn-normal'], | ||
rounded: [ | ||
@@ -1240,0 +1291,0 @@ 'rounded-t', |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
538095
8332