tailwind-merge-rtl-plugin
Version:
RTL Plugin for tailwind-merge
1 lines • 7.71 kB
Source Map (JSON)
{"version":3,"file":"index.cjs","sources":["../src/with-rtl.ts"],"sourcesContent":["import { Config, mergeConfigs, validators } from 'tailwind-merge'\n\nexport const withRtl = (prevConfig: Config): Config => {\n const getLength = () => [validators.isLength] as const\n const getLengthWithAuto = () => ['auto', validators.isLength] as const\n const getLengthWithEmpty = () => ['', validators.isLength] as const\n const getAny = () => [validators.isAny] as const\n const getRounded = () =>\n [\n 'none',\n '',\n 'sm',\n 'md',\n 'lg',\n 'xl',\n '2xl',\n '3xl',\n 'full',\n validators.isArbitraryLength,\n ] as const\n\n return mergeConfigs(prevConfig, {\n classGroups: {\n float: [{ float: ['start', 'end'] }],\n clear: [{ clear: ['start', 'end'] }],\n 'text-alignment': [{ text: ['start', 'end'] }],\n /**\n * Left\n * @see https://tailwindcss.com/docs/top-right-bottom-left\n * @see https://github.com/20lives/tailwindcss-rtl#utilities\n */\n 'rtl.start': [{ start: getLengthWithAuto() }],\n /**\n * Left\n * @see https://tailwindcss.com/docs/top-right-bottom-left\n * @see https://github.com/20lives/tailwindcss-rtl#utilities\n */\n 'rtl.end': [{ end: getLengthWithAuto() }],\n /**\n * Padding start\n * @see https://github.com/20lives/tailwindcss-rtl#utilities\n */\n 'rtl.ps': [{ ps: getLength() }],\n\n /**\n * Padding end\n * @see https://github.com/20lives/tailwindcss-rtl#utilities\n */\n 'rtl.pe': [{ pe: getLength() }],\n /**\n * Margin start\n * @see https://github.com/20lives/tailwindcss-rtl#utilities\n */\n 'rtl.ms': [{ ms: getLength() }],\n\n /**\n * Margin end\n * @see https://github.com/20lives/tailwindcss-rtl#utilities\n */\n 'rtl.me': [{ me: getLength() }],\n /**\n * Space Between Start Direction\n * @see https://tailwindcss.com/docs/space\n * @see https://github.com/20lives/tailwindcss-rtl#utilities\n */\n 'rtl.space-s': [{ 'space-s': getLength() }],\n /**\n * Border Radius Start\n * @see https://github.com/20lives/tailwindcss-rtl#utilities\n */\n 'rtl.rounded-s': [{ 'rounded-s': getRounded() }],\n /**\n * Border Radius End\n * @see https://github.com/20lives/tailwindcss-rtl#utilities\n */\n 'rtl.rounded-e': [{ 'rounded-e': getRounded() }],\n /**\n * Border Radius Top Start\n * @see https://github.com/20lives/tailwindcss-rtl#utilities\n */\n 'rtl.rounded-ts': [{ 'rounded-ts': getRounded() }],\n /**\n * Border Radius Top End\n * @see https://github.com/20lives/tailwindcss-rtl#utilities\n */\n 'rtl.rounded-te': [{ 'rounded-te': getRounded() }],\n /**\n * Border Radius Bottom Start\n * @see https://github.com/20lives/tailwindcss-rtl#utilities\n */\n 'rtl.rounded-bs': [{ 'rounded-bs': getRounded() }],\n /**\n * Border Radius Bottom End\n * @see https://github.com/20lives/tailwindcss-rtl#utilities\n */\n 'rtl.rounded-be': [{ 'rounded-be': getRounded() }],\n /**\n * Border Width Start\n * @see https://tailwindcss.com/docs/border-width\n * @see https://github.com/20lives/tailwindcss-rtl#utilities\n */\n 'rtl.border-w-s': [{ 'border-s': getLengthWithEmpty() }],\n /**\n * Border Width End\n * @see https://tailwindcss.com/docs/border-width\n * @see https://github.com/20lives/tailwindcss-rtl#utilities\n */\n 'rtl.border-w-e': [{ 'border-e': getLengthWithEmpty() }],\n /**\n * Divide Width Start Direction\n * @see https://tailwindcss.com/docs/divide-width\n * @see https://github.com/20lives/tailwindcss-rtl#utilities\n */\n 'rtl.divide-s': [{ 'divide-s': getLengthWithEmpty() }],\n /**\n * Border Color Start\n * @see https://tailwindcss.com/docs/border-color\n * @see https://github.com/20lives/tailwindcss-rtl#utilities\n */\n 'rtl.border-color-s': [{ 'border-s': getAny() }],\n /**\n * Border Color End\n * @see https://tailwindcss.com/docs/border-color\n * @see https://github.com/20lives/tailwindcss-rtl#utilities\n */\n 'rtl.border-color-e': [{ 'border-e': getAny() }],\n },\n conflictingClassGroups: {\n inset: ['rtl.start', 'rtl.end'],\n 'inset-x': ['rtl.start', 'rtl.end'],\n p: ['rtl.ps', 'rtl.pe'],\n px: ['rtl.ps', 'rtl.pe'],\n m: ['rtl.ms', 'rtl.me'],\n mx: ['rtl.ms', 'rtl.me'],\n 'space-x': ['rtl.space-s'],\n 'rtl.space-s': ['space-x'],\n rounded: [\n 'rtl.rounded-s',\n 'rtl.rounded-e',\n 'rtl.rounded-ts',\n 'rtl.rounded-te',\n 'rtl.rounded-bs',\n 'rtl.rounded-be',\n ],\n 'rtl.rounded-s': ['rtl.rounded-ts', 'rtl.rounded-bs'],\n 'rtl.rounded-e': ['rtl.rounded-te', 'rtl.rounded-be'],\n 'border-w': ['rtl.border-w-s', 'rtl.border-w-e'],\n 'divide-x': ['rtl.divide-s'],\n 'rtl.divide-s': ['divide-x'],\n 'border-color': ['rtl.border-color-s', 'rtl.border-color-e'],\n },\n })\n}\n"],"names":["prevConfig","getLength","validators","isLength","getLengthWithAuto","getLengthWithEmpty","getAny","isAny","getRounded","isArbitraryLength","mergeConfigs","classGroups","float","clear","text","start","end","ps","pe","ms","me","conflictingClassGroups","inset","p","px","m","mx","rounded"],"mappings":"6DAEuB,SAACA,GACpB,IAAMC,EAAY,iBAAM,CAACC,aAAWC,WAC9BC,EAAoB,iBAAM,CAAC,OAAQF,aAAWC,WAC9CE,EAAqB,iBAAM,CAAC,GAAIH,aAAWC,WAC3CG,EAAS,iBAAM,CAACJ,aAAWK,QAC3BC,EAAa,iBACf,CACI,OACA,GACA,KACA,KACA,KACA,KACA,MACA,MACA,OACAN,aAAWO,oBAGnB,OAAOC,eAAaV,EAAY,CAC5BW,YAAa,CACTC,MAAO,CAAC,CAAEA,MAAO,CAAC,QAAS,SAC3BC,MAAO,CAAC,CAAEA,MAAO,CAAC,QAAS,SAC3B,iBAAkB,CAAC,CAAEC,KAAM,CAAC,QAAS,SAMrC,YAAa,CAAC,CAAEC,MAAOX,MAMvB,UAAW,CAAC,CAAEY,IAAKZ,MAKnB,SAAU,CAAC,CAAEa,GAAIhB,MAMjB,SAAU,CAAC,CAAEiB,GAAIjB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