react-inline-styler-processor-rtl
Advanced tools
Comparing version 1.1.3 to 1.1.4
@@ -1,1 +0,1 @@ | ||
'use strict';Object.defineProperty(exports,"__esModule",{value:true});exports.inlineStylerRTLProccessorHelpers=undefined;var _assign=require('babel-runtime/core-js/object/assign');var _assign2=_interopRequireDefault(_assign);var _entries=require('babel-runtime/core-js/object/entries');var _entries2=_interopRequireDefault(_entries);exports.default=processor;var _invariant=require('invariant');var _invariant2=_interopRequireDefault(_invariant);function _interopRequireDefault(obj){return obj&&obj.__esModule?obj:{default:obj};}const reTranslate=/((^|\s)translate(3d|X)?\()(\-?[\d]+)/;const reSkew=/((^|\s)skew(x|y)?\()\s*(\-?[\d]+)(deg|rad|grad)(,\s*(\-?[\d]+)(deg|rad|grad))?/;const UNDEFINED_IS_RTL_ERROR="isRTL is undefined. isRTL should be supplied to the configurations of the react-inline-styler Provider component";const maybeUpperCaseFirst=function maybeUpperCaseFirst(str,cond){return cond?str.charAt(0).toUpperCase()+str.substring(1):str;};const startEndReplacer=function startEndReplacer(str,{startReplacement,endReplacement}){return str.replace(/(s|S)tart|(?:e|E)nd/,function(match,isStart,index){const replacement=isStart?startReplacement:endReplacement,shouldUpperCase=index>0;return maybeUpperCaseFirst(replacement,shouldUpperCase);});};const getLeftRightRepalcements=function getLeftRightRepalcements(isRTL){return{startReplacement:isRTL?'right':'left',endReplacement:isRTL?'left':'right'};};const getDirectionReplacements=function getDirectionReplacements(isRTL){return{startReplacement:isRTL?'rtl':'ltr',endReplacement:isRTL?'ltr':'rtl'};};const attributeKeyReplacementFactory=function attributeKeyReplacementFactory(isRTL){const leftRightReplacements=getLeftRightRepalcements(isRTL);return function(key){return startEndReplacer(key,leftRightReplacements);};};const attributeValueReplacementFactory=function attributeValueReplacementFactory(isRTL){const leftRightReplacements=getLeftRightRepalcements(isRTL);const directionReplacements=getDirectionReplacements(isRTL);return function(attrubuteKey,attrubuteValue){switch(attrubuteKey){case'textAlign':case'float':case'transformOrigin':return startEndReplacer(attrubuteValue,leftRightReplacements);case'direction':return startEndReplacer(attrubuteValue,directionReplacements);default:return attrubuteValue;}};};const inlineStylerRTLProccessorHelpers=exports.inlineStylerRTLProccessorHelpers=function inlineStylerRTLProccessorHelpers(isRTL){const onRTL=function onRTL(rtlStyle,lrtStyle){return isRTL?rtlStyle:lrtStyle;};return{onlyRTL:function onlyRTL(rtl){return onRTL(rtl,null);},onlyLTR:function onlyLTR(lrt){return onRTL(null,lrt);},onRTL};};function processor(styleObject,configurations){const isRTL=configurations.isRTL;(0,_invariant2.default)(typeof isRTL!=="undefined",UNDEFINED_IS_RTL_ERROR);const transformAttributeKey=attributeKeyReplacementFactory(isRTL);const transformAttributeValue=attributeValueReplacementFactory(isRTL);return(0,_entries2.default)(styleObject).reduce(function(acc,[key,value]){const transformedKey=transformAttributeKey(key);const transformedValue=transformAttributeValue(key,value);return(0,_assign2.default)(acc,{[transformedKey]:transformedValue});},{});} | ||
'use strict';Object.defineProperty(exports,"__esModule",{value:true});exports.inlineStylerRTLProccessorHelpers=undefined;var _assign=require('babel-runtime/core-js/object/assign');var _assign2=_interopRequireDefault(_assign);var _entries=require('babel-runtime/core-js/object/entries');var _entries2=_interopRequireDefault(_entries);exports.default=processor;var _invariant=require('invariant');var _invariant2=_interopRequireDefault(_invariant);function _interopRequireDefault(obj){return obj&&obj.__esModule?obj:{default:obj};}const reTranslate=/((^|\s)translate(3d|X)?\()(\-?[\d]+)/;const reSkew=/((^|\s)skew(x|y)?\()\s*(\-?[\d]+)(deg|rad|grad)(,\s*(\-?[\d]+)(deg|rad|grad))?/;const UNDEFINED_IS_RTL_ERROR="isRTL is undefined. isRTL should be supplied to the configurations of the react-inline-styler Provider component";const maybeUpperCaseFirst=function maybeUpperCaseFirst(str,cond){return cond?str.charAt(0).toUpperCase()+str.substring(1):str;};const startEndReplacer=function startEndReplacer(str,{startReplacement,endReplacement}){if(!str)return;return str.replace(/(s|S)tart|(?:e|E)nd/,function(match,isStart,index){const replacement=isStart?startReplacement:endReplacement,shouldUpperCase=index>0;return maybeUpperCaseFirst(replacement,shouldUpperCase);});};const getLeftRightRepalcements=function getLeftRightRepalcements(isRTL){return{startReplacement:isRTL?'right':'left',endReplacement:isRTL?'left':'right'};};const getDirectionReplacements=function getDirectionReplacements(isRTL){return{startReplacement:isRTL?'rtl':'ltr',endReplacement:isRTL?'ltr':'rtl'};};const attributeKeyReplacementFactory=function attributeKeyReplacementFactory(isRTL){const leftRightReplacements=getLeftRightRepalcements(isRTL);return function(key){return startEndReplacer(key,leftRightReplacements);};};const attributeValueReplacementFactory=function attributeValueReplacementFactory(isRTL){const leftRightReplacements=getLeftRightRepalcements(isRTL);const directionReplacements=getDirectionReplacements(isRTL);return function(attrubuteKey,attrubuteValue){switch(attrubuteKey){case'textAlign':case'float':case'transformOrigin':return startEndReplacer(attrubuteValue,leftRightReplacements);case'direction':return startEndReplacer(attrubuteValue,directionReplacements);default:return attrubuteValue;}};};const inlineStylerRTLProccessorHelpers=exports.inlineStylerRTLProccessorHelpers=function inlineStylerRTLProccessorHelpers(isRTL){const onRTL=function onRTL(rtlStyle,lrtStyle){return isRTL?rtlStyle:lrtStyle;};return{onlyRTL:function onlyRTL(rtl){return onRTL(rtl,null);},onlyLTR:function onlyLTR(lrt){return onRTL(null,lrt);},onRTL};};function processor(styleObject,configurations){const{isRTL}=configurations;(0,_invariant2.default)(typeof isRTL!=="undefined",UNDEFINED_IS_RTL_ERROR);const transformAttributeKey=attributeKeyReplacementFactory(isRTL);const transformAttributeValue=attributeValueReplacementFactory(isRTL);return(0,_entries2.default)(styleObject).reduce(function(acc,[key,value]){const transformedKey=transformAttributeKey(key);const transformedValue=transformAttributeValue(key,value);return(0,_assign2.default)(acc,{[transformedKey]:transformedValue});},{});} |
{ | ||
"name": "react-inline-styler-processor-rtl", | ||
"version": "1.1.3", | ||
"version": "1.1.4", | ||
"description": "React Inline Styler RTL Processors.", | ||
@@ -5,0 +5,0 @@ "main": "./distribution/index.js", |
119708