UNPKG

tailwindcss-vanilla-rtl

Version:

Simple right-to-left (RTL) language support for Tailwind, switching vanilla utilities to CSS logical properties and values

1 lines 8.78 kB
"use strict";Object.defineProperty(exports,"__esModule",{value:true});Object.defineProperty(exports,"corePlugins",{enumerable:true,get:()=>corePlugins});const _createUtilityPlugin=_interopRequireDefault(require("tailwindcss/lib/util/createUtilityPlugin"));const _flattenColorPalette=_interopRequireDefault(require("tailwindcss/lib/util/flattenColorPalette"));const _withAlphaVariable=_interopRequireWildcard(require("tailwindcss/lib/util/withAlphaVariable"));const _toColorValue=_interopRequireDefault(require("tailwindcss/lib/util/toColorValue"));function _interopRequireDefault(obj){return obj&&obj.__esModule?obj:{default:obj}}function _getRequireWildcardCache(nodeInterop){if(typeof WeakMap!=="function")return null;var cacheBabelInterop=new WeakMap;var cacheNodeInterop=new WeakMap;return(_getRequireWildcardCache=function(nodeInterop){return nodeInterop?cacheNodeInterop:cacheBabelInterop})(nodeInterop)}function _interopRequireWildcard(obj,nodeInterop){if(!nodeInterop&&obj&&obj.__esModule){return obj}if(obj===null||typeof obj!=="object"&&typeof obj!=="function"){return{default:obj}}var cache=_getRequireWildcardCache(nodeInterop);if(cache&&cache.has(obj)){return cache.get(obj)}var newObj={};var hasPropertyDescriptor=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var key in obj){if(key!=="default"&&Object.prototype.hasOwnProperty.call(obj,key)){var desc=hasPropertyDescriptor?Object.getOwnPropertyDescriptor(obj,key):null;if(desc&&(desc.get||desc.set)){Object.defineProperty(newObj,key,desc)}else{newObj[key]=obj[key]}}}newObj.default=obj;if(cache){cache.set(obj,newObj)}return newObj}let corePlugins={inset:(0,_createUtilityPlugin.default)("inset",[["inset",["top","inset-inline-end","bottom","inset-inline-start"]],[["inset-x",["inset-inline-start","inset-inline-end"]],["inset-y",["top","bottom"]]],[["top",["top"]],["right",["inset-inline-end"]],["bottom",["bottom"]],["left",["inset-inline-start"]]]],{supportsNegativeValues:true}),margin:(0,_createUtilityPlugin.default)("margin",[["m",["margin"]],[["mx",["margin-inline-start","margin-inline-end"]],["my",["margin-top","margin-bottom"]]],[["mt",["margin-top"]],["mr",["margin-inline-end"]],["mb",["margin-bottom"]],["ml",["margin-inline-start"]]]],{supportsNegativeValues:true}),scrollMargin:(0,_createUtilityPlugin.default)("scrollMargin",[["scroll-m",["scroll-margin"]],[["scroll-mx",["scroll-margin-inline-start","scroll-margin-inline-end"]],["scroll-my",["scroll-margin-top","scroll-margin-bottom"]]],[["scroll-mt",["scroll-margin-top"]],["scroll-mr",["scroll-margin-inline-end"]],["scroll-mb",["scroll-margin-bottom"]],["scroll-ml",["scroll-margin-inline-start"]]]],{supportsNegativeValues:true}),scrollPadding:(0,_createUtilityPlugin.default)("scrollPadding",[["scroll-p",["scroll-padding"]],[["scroll-px",["scroll-padding-inline-start","scroll-padding-inline-end"]],["scroll-py",["scroll-padding-top","scroll-padding-bottom"]]],[["scroll-pt",["scroll-padding-top"]],["scroll-pr",["scroll-padding-inline-end"]],["scroll-pb",["scroll-padding-bottom"]],["scroll-pl",["scroll-padding-inline-start"]]]]),space:({matchUtilities,addUtilities,theme})=>{matchUtilities({"space-x":value=>{value=value==="0"?"0px":value;return{"& > :not([hidden]) ~ :not([hidden])":{"--tw-space-x-reverse":"0","margin-inline-end":`calc(${value} * var(--tw-space-x-reverse))`,"margin-inline-start":`calc(${value} * calc(1 - var(--tw-space-x-reverse)))`}}},"space-y":value=>{value=value==="0"?"0px":value;return{"& > :not([hidden]) ~ :not([hidden])":{"--tw-space-y-reverse":"0","margin-top":`calc(${value} * calc(1 - var(--tw-space-y-reverse)))`,"margin-bottom":`calc(${value} * var(--tw-space-y-reverse))`}}}},{values:theme("space"),supportsNegativeValues:true});addUtilities({".space-y-reverse > :not([hidden]) ~ :not([hidden])":{"--tw-space-y-reverse":"1"},".space-x-reverse > :not([hidden]) ~ :not([hidden])":{"--tw-space-x-reverse":"1"}})},divideWidth:({matchUtilities,addUtilities,theme})=>{matchUtilities({"divide-x":value=>{value=value==="0"?"0px":value;return{"& > :not([hidden]) ~ :not([hidden])":{"@defaults border-width":{},"--tw-divide-x-reverse":"0","border-inline-end-width":`calc(${value} * var(--tw-divide-x-reverse))`,"border-inline-start-width":`calc(${value} * calc(1 - var(--tw-divide-x-reverse)))`}}},"divide-y":value=>{value=value==="0"?"0px":value;return{"& > :not([hidden]) ~ :not([hidden])":{"@defaults border-width":{},"--tw-divide-y-reverse":"0","border-top-width":`calc(${value} * calc(1 - var(--tw-divide-y-reverse)))`,"border-bottom-width":`calc(${value} * var(--tw-divide-y-reverse))`}}}},{values:theme("divideWidth"),type:["line-width","length","any"]});addUtilities({".divide-y-reverse > :not([hidden]) ~ :not([hidden])":{"@defaults border-width":{},"--tw-divide-y-reverse":"1"},".divide-x-reverse > :not([hidden]) ~ :not([hidden])":{"@defaults border-width":{},"--tw-divide-x-reverse":"1"}})},borderRadius:(0,_createUtilityPlugin.default)("borderRadius",[["rounded",["border-radius"]],[["rounded-t",["border-start-start-radius","border-start-end-radius"]],["rounded-r",["border-start-end-radius","border-end-end-radius"]],["rounded-b",["border-end-end-radius","border-end-start-radius"]],["rounded-l",["border-start-start-radius","border-end-start-radius"]]],[["rounded-tl",["border-start-start-radius"]],["rounded-tr",["border-start-end-radius"]],["rounded-br",["border-end-end-radius"]],["rounded-bl",["border-end-start-radius"]]]]),borderWidth:(0,_createUtilityPlugin.default)("borderWidth",[["border",[["@defaults border-width",{}],"border-width"]],[["border-x",[["@defaults border-width",{}],"border-inline-start-width","border-inline-end-width"]],["border-y",[["@defaults border-width",{}],"border-top-width","border-bottom-width"]]],[["border-t",[["@defaults border-width",{}],"border-top-width"]],["border-r",[["@defaults border-width",{}],"border-inline-end-width"]],["border-b",[["@defaults border-width",{}],"border-bottom-width"]],["border-l",[["@defaults border-width",{}],"border-inline-start-width"]]]],{type:["line-width","length"]}),borderColor:({matchUtilities,theme,corePlugins})=>{matchUtilities({border:value=>{if(!true){return{"border-color":(0,_toColorValue.default)(value)}}return(0,_withAlphaVariable.default)({color:value,property:"border-color",variable:"--tw-border-opacity"})}},{values:(({DEFAULT:_,...colors})=>colors)((0,_flattenColorPalette.default)(theme("borderColor"))),type:["color","any"]});matchUtilities({"border-x":value=>{if(!true){return{"border-inline-start-color":(0,_toColorValue.default)(value),"border-inline-end-color":(0,_toColorValue.default)(value)}}return(0,_withAlphaVariable.default)({color:value,property:["border-inline-start-color","border-inline-end-color"],variable:"--tw-border-opacity"})},"border-y":value=>{if(!true){return{"border-top-color":(0,_toColorValue.default)(value),"border-bottom-color":(0,_toColorValue.default)(value)}}return(0,_withAlphaVariable.default)({color:value,property:["border-top-color","border-bottom-color"],variable:"--tw-border-opacity"})}},{values:(({DEFAULT:_,...colors})=>colors)((0,_flattenColorPalette.default)(theme("borderColor"))),type:["color","any"]});matchUtilities({"border-t":value=>{if(!true){return{"border-top-color":(0,_toColorValue.default)(value)}}return(0,_withAlphaVariable.default)({color:value,property:"border-top-color",variable:"--tw-border-opacity"})},"border-r":value=>{if(!true){return{"border-inline-end-color":(0,_toColorValue.default)(value)}}return(0,_withAlphaVariable.default)({color:value,property:"border-inline-end-color",variable:"--tw-border-opacity"})},"border-b":value=>{if(!true){return{"border-bottom-color":(0,_toColorValue.default)(value)}}return(0,_withAlphaVariable.default)({color:value,property:"border-bottom-color",variable:"--tw-border-opacity"})},"border-l":value=>{if(!true){return{"border-inline-start-color":(0,_toColorValue.default)(value)}}return(0,_withAlphaVariable.default)({color:value,property:"border-inline-start-color",variable:"--tw-border-opacity"})}},{values:(({DEFAULT:_,...colors})=>colors)((0,_flattenColorPalette.default)(theme("borderColor"))),type:["color","any"]})},borderOpacity:(0,_createUtilityPlugin.default)("borderOpacity",[["border-opacity",["--tw-border-opacity"]]]),padding:(0,_createUtilityPlugin.default)("padding",[["p",["padding"]],[["px",["padding-inline-start","padding-inline-end"]],["py",["padding-top","padding-bottom"]]],[["pt",["padding-top"]],["pr",["padding-inline-end"]],["pb",["padding-bottom"]],["pl",["padding-inline-start"]]]]),textAlign:({addUtilities})=>{addUtilities({".text-left":{"text-align":"start"},".text-center":{"text-align":"center"},".text-right":{"text-align":"end"},".text-justify":{"text-align":"justify"},".text-start":{"text-align":"start"},".text-end":{"text-align":"end"}})}};