polished.cjs.js 124 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040
  1. 'use strict';
  2. Object.defineProperty(exports, '__esModule', { value: true });
  3. var _extends = require('@babel/runtime/helpers/extends');
  4. var _assertThisInitialized = require('@babel/runtime/helpers/assertThisInitialized');
  5. var _inheritsLoose = require('@babel/runtime/helpers/inheritsLoose');
  6. var _wrapNativeSuper = require('@babel/runtime/helpers/wrapNativeSuper');
  7. var _taggedTemplateLiteralLoose = require('@babel/runtime/helpers/taggedTemplateLiteralLoose');
  8. function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
  9. var _extends__default = /*#__PURE__*/_interopDefaultLegacy(_extends);
  10. var _assertThisInitialized__default = /*#__PURE__*/_interopDefaultLegacy(_assertThisInitialized);
  11. var _inheritsLoose__default = /*#__PURE__*/_interopDefaultLegacy(_inheritsLoose);
  12. var _wrapNativeSuper__default = /*#__PURE__*/_interopDefaultLegacy(_wrapNativeSuper);
  13. var _taggedTemplateLiteralLoose__default = /*#__PURE__*/_interopDefaultLegacy(_taggedTemplateLiteralLoose);
  14. function last() {
  15. var _ref;
  16. return _ref = arguments.length - 1, _ref < 0 || arguments.length <= _ref ? undefined : arguments[_ref];
  17. }
  18. function negation(a) {
  19. return -a;
  20. }
  21. function addition(a, b) {
  22. return a + b;
  23. }
  24. function subtraction(a, b) {
  25. return a - b;
  26. }
  27. function multiplication(a, b) {
  28. return a * b;
  29. }
  30. function division(a, b) {
  31. return a / b;
  32. }
  33. function max() {
  34. return Math.max.apply(Math, arguments);
  35. }
  36. function min() {
  37. return Math.min.apply(Math, arguments);
  38. }
  39. function comma() {
  40. return Array.of.apply(Array, arguments);
  41. }
  42. var defaultSymbols = {
  43. symbols: {
  44. '*': {
  45. infix: {
  46. symbol: '*',
  47. f: multiplication,
  48. notation: 'infix',
  49. precedence: 4,
  50. rightToLeft: 0,
  51. argCount: 2
  52. },
  53. symbol: '*',
  54. regSymbol: '\\*'
  55. },
  56. '/': {
  57. infix: {
  58. symbol: '/',
  59. f: division,
  60. notation: 'infix',
  61. precedence: 4,
  62. rightToLeft: 0,
  63. argCount: 2
  64. },
  65. symbol: '/',
  66. regSymbol: '/'
  67. },
  68. '+': {
  69. infix: {
  70. symbol: '+',
  71. f: addition,
  72. notation: 'infix',
  73. precedence: 2,
  74. rightToLeft: 0,
  75. argCount: 2
  76. },
  77. prefix: {
  78. symbol: '+',
  79. f: last,
  80. notation: 'prefix',
  81. precedence: 3,
  82. rightToLeft: 0,
  83. argCount: 1
  84. },
  85. symbol: '+',
  86. regSymbol: '\\+'
  87. },
  88. '-': {
  89. infix: {
  90. symbol: '-',
  91. f: subtraction,
  92. notation: 'infix',
  93. precedence: 2,
  94. rightToLeft: 0,
  95. argCount: 2
  96. },
  97. prefix: {
  98. symbol: '-',
  99. f: negation,
  100. notation: 'prefix',
  101. precedence: 3,
  102. rightToLeft: 0,
  103. argCount: 1
  104. },
  105. symbol: '-',
  106. regSymbol: '-'
  107. },
  108. ',': {
  109. infix: {
  110. symbol: ',',
  111. f: comma,
  112. notation: 'infix',
  113. precedence: 1,
  114. rightToLeft: 0,
  115. argCount: 2
  116. },
  117. symbol: ',',
  118. regSymbol: ','
  119. },
  120. '(': {
  121. prefix: {
  122. symbol: '(',
  123. f: last,
  124. notation: 'prefix',
  125. precedence: 0,
  126. rightToLeft: 0,
  127. argCount: 1
  128. },
  129. symbol: '(',
  130. regSymbol: '\\('
  131. },
  132. ')': {
  133. postfix: {
  134. symbol: ')',
  135. f: undefined,
  136. notation: 'postfix',
  137. precedence: 0,
  138. rightToLeft: 0,
  139. argCount: 1
  140. },
  141. symbol: ')',
  142. regSymbol: '\\)'
  143. },
  144. min: {
  145. func: {
  146. symbol: 'min',
  147. f: min,
  148. notation: 'func',
  149. precedence: 0,
  150. rightToLeft: 0,
  151. argCount: 1
  152. },
  153. symbol: 'min',
  154. regSymbol: 'min\\b'
  155. },
  156. max: {
  157. func: {
  158. symbol: 'max',
  159. f: max,
  160. notation: 'func',
  161. precedence: 0,
  162. rightToLeft: 0,
  163. argCount: 1
  164. },
  165. symbol: 'max',
  166. regSymbol: 'max\\b'
  167. }
  168. }
  169. };
  170. var defaultSymbolMap = defaultSymbols;
  171. // based on https://github.com/styled-components/styled-components/blob/fcf6f3804c57a14dd7984dfab7bc06ee2edca044/src/utils/error.js
  172. /**
  173. * Parse errors.md and turn it into a simple hash of code: message
  174. * @private
  175. */
  176. var ERRORS = {
  177. "1": "Passed invalid arguments to hsl, please pass multiple numbers e.g. hsl(360, 0.75, 0.4) or an object e.g. rgb({ hue: 255, saturation: 0.4, lightness: 0.75 }).\n\n",
  178. "2": "Passed invalid arguments to hsla, please pass multiple numbers e.g. hsla(360, 0.75, 0.4, 0.7) or an object e.g. rgb({ hue: 255, saturation: 0.4, lightness: 0.75, alpha: 0.7 }).\n\n",
  179. "3": "Passed an incorrect argument to a color function, please pass a string representation of a color.\n\n",
  180. "4": "Couldn't generate valid rgb string from %s, it returned %s.\n\n",
  181. "5": "Couldn't parse the color string. Please provide the color as a string in hex, rgb, rgba, hsl or hsla notation.\n\n",
  182. "6": "Passed invalid arguments to rgb, please pass multiple numbers e.g. rgb(255, 205, 100) or an object e.g. rgb({ red: 255, green: 205, blue: 100 }).\n\n",
  183. "7": "Passed invalid arguments to rgba, please pass multiple numbers e.g. rgb(255, 205, 100, 0.75) or an object e.g. rgb({ red: 255, green: 205, blue: 100, alpha: 0.75 }).\n\n",
  184. "8": "Passed invalid argument to toColorString, please pass a RgbColor, RgbaColor, HslColor or HslaColor object.\n\n",
  185. "9": "Please provide a number of steps to the modularScale helper.\n\n",
  186. "10": "Please pass a number or one of the predefined scales to the modularScale helper as the ratio.\n\n",
  187. "11": "Invalid value passed as base to modularScale, expected number or em string but got \"%s\"\n\n",
  188. "12": "Expected a string ending in \"px\" or a number passed as the first argument to %s(), got \"%s\" instead.\n\n",
  189. "13": "Expected a string ending in \"px\" or a number passed as the second argument to %s(), got \"%s\" instead.\n\n",
  190. "14": "Passed invalid pixel value (\"%s\") to %s(), please pass a value like \"12px\" or 12.\n\n",
  191. "15": "Passed invalid base value (\"%s\") to %s(), please pass a value like \"12px\" or 12.\n\n",
  192. "16": "You must provide a template to this method.\n\n",
  193. "17": "You passed an unsupported selector state to this method.\n\n",
  194. "18": "minScreen and maxScreen must be provided as stringified numbers with the same units.\n\n",
  195. "19": "fromSize and toSize must be provided as stringified numbers with the same units.\n\n",
  196. "20": "expects either an array of objects or a single object with the properties prop, fromSize, and toSize.\n\n",
  197. "21": "expects the objects in the first argument array to have the properties `prop`, `fromSize`, and `toSize`.\n\n",
  198. "22": "expects the first argument object to have the properties `prop`, `fromSize`, and `toSize`.\n\n",
  199. "23": "fontFace expects a name of a font-family.\n\n",
  200. "24": "fontFace expects either the path to the font file(s) or a name of a local copy.\n\n",
  201. "25": "fontFace expects localFonts to be an array.\n\n",
  202. "26": "fontFace expects fileFormats to be an array.\n\n",
  203. "27": "radialGradient requries at least 2 color-stops to properly render.\n\n",
  204. "28": "Please supply a filename to retinaImage() as the first argument.\n\n",
  205. "29": "Passed invalid argument to triangle, please pass correct pointingDirection e.g. 'right'.\n\n",
  206. "30": "Passed an invalid value to `height` or `width`. Please provide a pixel based unit.\n\n",
  207. "31": "The animation shorthand only takes 8 arguments. See the specification for more information: http://mdn.io/animation\n\n",
  208. "32": "To pass multiple animations please supply them in arrays, e.g. animation(['rotate', '2s'], ['move', '1s'])\nTo pass a single animation please supply them in simple values, e.g. animation('rotate', '2s')\n\n",
  209. "33": "The animation shorthand arrays can only have 8 elements. See the specification for more information: http://mdn.io/animation\n\n",
  210. "34": "borderRadius expects a radius value as a string or number as the second argument.\n\n",
  211. "35": "borderRadius expects one of \"top\", \"bottom\", \"left\" or \"right\" as the first argument.\n\n",
  212. "36": "Property must be a string value.\n\n",
  213. "37": "Syntax Error at %s.\n\n",
  214. "38": "Formula contains a function that needs parentheses at %s.\n\n",
  215. "39": "Formula is missing closing parenthesis at %s.\n\n",
  216. "40": "Formula has too many closing parentheses at %s.\n\n",
  217. "41": "All values in a formula must have the same unit or be unitless.\n\n",
  218. "42": "Please provide a number of steps to the modularScale helper.\n\n",
  219. "43": "Please pass a number or one of the predefined scales to the modularScale helper as the ratio.\n\n",
  220. "44": "Invalid value passed as base to modularScale, expected number or em/rem string but got %s.\n\n",
  221. "45": "Passed invalid argument to hslToColorString, please pass a HslColor or HslaColor object.\n\n",
  222. "46": "Passed invalid argument to rgbToColorString, please pass a RgbColor or RgbaColor object.\n\n",
  223. "47": "minScreen and maxScreen must be provided as stringified numbers with the same units.\n\n",
  224. "48": "fromSize and toSize must be provided as stringified numbers with the same units.\n\n",
  225. "49": "Expects either an array of objects or a single object with the properties prop, fromSize, and toSize.\n\n",
  226. "50": "Expects the objects in the first argument array to have the properties prop, fromSize, and toSize.\n\n",
  227. "51": "Expects the first argument object to have the properties prop, fromSize, and toSize.\n\n",
  228. "52": "fontFace expects either the path to the font file(s) or a name of a local copy.\n\n",
  229. "53": "fontFace expects localFonts to be an array.\n\n",
  230. "54": "fontFace expects fileFormats to be an array.\n\n",
  231. "55": "fontFace expects a name of a font-family.\n\n",
  232. "56": "linearGradient requries at least 2 color-stops to properly render.\n\n",
  233. "57": "radialGradient requries at least 2 color-stops to properly render.\n\n",
  234. "58": "Please supply a filename to retinaImage() as the first argument.\n\n",
  235. "59": "Passed invalid argument to triangle, please pass correct pointingDirection e.g. 'right'.\n\n",
  236. "60": "Passed an invalid value to `height` or `width`. Please provide a pixel based unit.\n\n",
  237. "61": "Property must be a string value.\n\n",
  238. "62": "borderRadius expects a radius value as a string or number as the second argument.\n\n",
  239. "63": "borderRadius expects one of \"top\", \"bottom\", \"left\" or \"right\" as the first argument.\n\n",
  240. "64": "The animation shorthand only takes 8 arguments. See the specification for more information: http://mdn.io/animation.\n\n",
  241. "65": "To pass multiple animations please supply them in arrays, e.g. animation(['rotate', '2s'], ['move', '1s'])\\nTo pass a single animation please supply them in simple values, e.g. animation('rotate', '2s').\n\n",
  242. "66": "The animation shorthand arrays can only have 8 elements. See the specification for more information: http://mdn.io/animation.\n\n",
  243. "67": "You must provide a template to this method.\n\n",
  244. "68": "You passed an unsupported selector state to this method.\n\n",
  245. "69": "Expected a string ending in \"px\" or a number passed as the first argument to %s(), got %s instead.\n\n",
  246. "70": "Expected a string ending in \"px\" or a number passed as the second argument to %s(), got %s instead.\n\n",
  247. "71": "Passed invalid pixel value %s to %s(), please pass a value like \"12px\" or 12.\n\n",
  248. "72": "Passed invalid base value %s to %s(), please pass a value like \"12px\" or 12.\n\n",
  249. "73": "Please provide a valid CSS variable.\n\n",
  250. "74": "CSS variable not found and no default was provided.\n\n",
  251. "75": "important requires a valid style object, got a %s instead.\n\n",
  252. "76": "fromSize and toSize must be provided as stringified numbers with the same units as minScreen and maxScreen.\n\n",
  253. "77": "remToPx expects a value in \"rem\" but you provided it in \"%s\".\n\n",
  254. "78": "base must be set in \"px\" or \"%\" but you set it in \"%s\".\n"
  255. };
  256. /**
  257. * super basic version of sprintf
  258. * @private
  259. */
  260. function format() {
  261. for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
  262. args[_key] = arguments[_key];
  263. }
  264. var a = args[0];
  265. var b = [];
  266. var c;
  267. for (c = 1; c < args.length; c += 1) {
  268. b.push(args[c]);
  269. }
  270. b.forEach(function (d) {
  271. a = a.replace(/%[a-z]/, d);
  272. });
  273. return a;
  274. }
  275. /**
  276. * Create an error file out of errors.md for development and a simple web link to the full errors
  277. * in production mode.
  278. * @private
  279. */
  280. var PolishedError = /*#__PURE__*/function (_Error) {
  281. _inheritsLoose__default["default"](PolishedError, _Error);
  282. function PolishedError(code) {
  283. var _this;
  284. if (process.env.NODE_ENV === 'production') {
  285. _this = _Error.call(this, "An error occurred. See https://github.com/styled-components/polished/blob/main/src/internalHelpers/errors.md#" + code + " for more information.") || this;
  286. } else {
  287. for (var _len2 = arguments.length, args = new Array(_len2 > 1 ? _len2 - 1 : 0), _key2 = 1; _key2 < _len2; _key2++) {
  288. args[_key2 - 1] = arguments[_key2];
  289. }
  290. _this = _Error.call(this, format.apply(void 0, [ERRORS[code]].concat(args))) || this;
  291. }
  292. return _assertThisInitialized__default["default"](_this);
  293. }
  294. return PolishedError;
  295. }( /*#__PURE__*/_wrapNativeSuper__default["default"](Error));
  296. var unitRegExp = /((?!\w)a|na|hc|mc|dg|me[r]?|xe|ni(?![a-zA-Z])|mm|cp|tp|xp|q(?!s)|hv|xamv|nimv|wv|sm|s(?!\D|$)|ged|darg?|nrut)/g;
  297. // Merges additional math functionality into the defaults.
  298. function mergeSymbolMaps(additionalSymbols) {
  299. var symbolMap = {};
  300. symbolMap.symbols = additionalSymbols ? _extends__default["default"]({}, defaultSymbolMap.symbols, additionalSymbols.symbols) : _extends__default["default"]({}, defaultSymbolMap.symbols);
  301. return symbolMap;
  302. }
  303. function exec(operators, values) {
  304. var _ref;
  305. var op = operators.pop();
  306. values.push(op.f.apply(op, (_ref = []).concat.apply(_ref, values.splice(-op.argCount))));
  307. return op.precedence;
  308. }
  309. function calculate(expression, additionalSymbols) {
  310. var symbolMap = mergeSymbolMaps(additionalSymbols);
  311. var match;
  312. var operators = [symbolMap.symbols['('].prefix];
  313. var values = [];
  314. var pattern = new RegExp( // Pattern for numbers
  315. "\\d+(?:\\.\\d+)?|" +
  316. // ...and patterns for individual operators/function names
  317. Object.keys(symbolMap.symbols).map(function (key) {
  318. return symbolMap.symbols[key];
  319. })
  320. // longer symbols should be listed first
  321. // $FlowFixMe
  322. .sort(function (a, b) {
  323. return b.symbol.length - a.symbol.length;
  324. })
  325. // $FlowFixMe
  326. .map(function (val) {
  327. return val.regSymbol;
  328. }).join('|') + "|(\\S)", 'g');
  329. pattern.lastIndex = 0; // Reset regular expression object
  330. var afterValue = false;
  331. do {
  332. match = pattern.exec(expression);
  333. var _ref2 = match || [')', undefined],
  334. token = _ref2[0],
  335. bad = _ref2[1];
  336. var notNumber = symbolMap.symbols[token];
  337. var notNewValue = notNumber && !notNumber.prefix && !notNumber.func;
  338. var notAfterValue = !notNumber || !notNumber.postfix && !notNumber.infix;
  339. // Check for syntax errors:
  340. if (bad || (afterValue ? notAfterValue : notNewValue)) {
  341. throw new PolishedError(37, match ? match.index : expression.length, expression);
  342. }
  343. if (afterValue) {
  344. // We either have an infix or postfix operator (they should be mutually exclusive)
  345. var curr = notNumber.postfix || notNumber.infix;
  346. do {
  347. var prev = operators[operators.length - 1];
  348. if ((curr.precedence - prev.precedence || prev.rightToLeft) > 0) break;
  349. // Apply previous operator, since it has precedence over current one
  350. } while (exec(operators, values)); // Exit loop after executing an opening parenthesis or function
  351. afterValue = curr.notation === 'postfix';
  352. if (curr.symbol !== ')') {
  353. operators.push(curr);
  354. // Postfix always has precedence over any operator that follows after it
  355. if (afterValue) exec(operators, values);
  356. }
  357. } else if (notNumber) {
  358. // prefix operator or function
  359. operators.push(notNumber.prefix || notNumber.func);
  360. if (notNumber.func) {
  361. // Require an opening parenthesis
  362. match = pattern.exec(expression);
  363. if (!match || match[0] !== '(') {
  364. throw new PolishedError(38, match ? match.index : expression.length, expression);
  365. }
  366. }
  367. } else {
  368. // number
  369. values.push(+token);
  370. afterValue = true;
  371. }
  372. } while (match && operators.length);
  373. if (operators.length) {
  374. throw new PolishedError(39, match ? match.index : expression.length, expression);
  375. } else if (match) {
  376. throw new PolishedError(40, match ? match.index : expression.length, expression);
  377. } else {
  378. return values.pop();
  379. }
  380. }
  381. function reverseString(str) {
  382. return str.split('').reverse().join('');
  383. }
  384. /**
  385. * Helper for doing math with CSS Units. Accepts a formula as a string. All values in the formula must have the same unit (or be unitless). Supports complex formulas utliziing addition, subtraction, multiplication, division, square root, powers, factorial, min, max, as well as parentheses for order of operation.
  386. *
  387. *In cases where you need to do calculations with mixed units where one unit is a [relative length unit](https://developer.mozilla.org/en-US/docs/Web/CSS/length#Relative_length_units), you will want to use [CSS Calc](https://developer.mozilla.org/en-US/docs/Web/CSS/calc).
  388. *
  389. * *warning* While we've done everything possible to ensure math safely evalutes formulas expressed as strings, you should always use extreme caution when passing `math` user provided values.
  390. * @example
  391. * // Styles as object usage
  392. * const styles = {
  393. * fontSize: math('12rem + 8rem'),
  394. * fontSize: math('(12px + 2px) * 3'),
  395. * fontSize: math('3px^2 + sqrt(4)'),
  396. * }
  397. *
  398. * // styled-components usage
  399. * const div = styled.div`
  400. * fontSize: ${math('12rem + 8rem')};
  401. * fontSize: ${math('(12px + 2px) * 3')};
  402. * fontSize: ${math('3px^2 + sqrt(4)')};
  403. * `
  404. *
  405. * // CSS as JS Output
  406. *
  407. * div: {
  408. * fontSize: '20rem',
  409. * fontSize: '42px',
  410. * fontSize: '11px',
  411. * }
  412. */
  413. function math(formula, additionalSymbols) {
  414. var reversedFormula = reverseString(formula);
  415. var formulaMatch = reversedFormula.match(unitRegExp);
  416. // Check that all units are the same
  417. if (formulaMatch && !formulaMatch.every(function (unit) {
  418. return unit === formulaMatch[0];
  419. })) {
  420. throw new PolishedError(41);
  421. }
  422. var cleanFormula = reverseString(reversedFormula.replace(unitRegExp, ''));
  423. return "" + calculate(cleanFormula, additionalSymbols) + (formulaMatch ? reverseString(formulaMatch[0]) : '');
  424. }
  425. var cssVariableRegex = /--[\S]*/g;
  426. /**
  427. * Fetches the value of a passed CSS Variable in the :root scope, or otherwise returns a defaultValue if provided.
  428. *
  429. * @example
  430. * // Styles as object usage
  431. * const styles = {
  432. * 'background': cssVar('--background-color'),
  433. * }
  434. *
  435. * // styled-components usage
  436. * const div = styled.div`
  437. * background: ${cssVar('--background-color')};
  438. * `
  439. *
  440. * // CSS in JS Output
  441. *
  442. * element {
  443. * 'background': 'red'
  444. * }
  445. */
  446. function cssVar(cssVariable, defaultValue) {
  447. if (!cssVariable || !cssVariable.match(cssVariableRegex)) {
  448. throw new PolishedError(73);
  449. }
  450. var variableValue;
  451. /* eslint-disable */
  452. /* istanbul ignore next */
  453. if (typeof document !== 'undefined' && document.documentElement !== null) {
  454. variableValue = getComputedStyle(document.documentElement).getPropertyValue(cssVariable);
  455. }
  456. /* eslint-enable */
  457. if (variableValue) {
  458. return variableValue.trim();
  459. } else if (defaultValue) {
  460. return defaultValue;
  461. }
  462. throw new PolishedError(74);
  463. }
  464. // @private
  465. function capitalizeString(string) {
  466. return string.charAt(0).toUpperCase() + string.slice(1);
  467. }
  468. var positionMap$1 = ['Top', 'Right', 'Bottom', 'Left'];
  469. function generateProperty(property, position) {
  470. if (!property) return position.toLowerCase();
  471. var splitProperty = property.split('-');
  472. if (splitProperty.length > 1) {
  473. splitProperty.splice(1, 0, position);
  474. return splitProperty.reduce(function (acc, val) {
  475. return "" + acc + capitalizeString(val);
  476. });
  477. }
  478. var joinedProperty = property.replace(/([a-z])([A-Z])/g, "$1" + position + "$2");
  479. return property === joinedProperty ? "" + property + position : joinedProperty;
  480. }
  481. function generateStyles(property, valuesWithDefaults) {
  482. var styles = {};
  483. for (var i = 0; i < valuesWithDefaults.length; i += 1) {
  484. if (valuesWithDefaults[i] || valuesWithDefaults[i] === 0) {
  485. styles[generateProperty(property, positionMap$1[i])] = valuesWithDefaults[i];
  486. }
  487. }
  488. return styles;
  489. }
  490. /**
  491. * Enables shorthand for direction-based properties. It accepts a property (hyphenated or camelCased) and up to four values that map to top, right, bottom, and left, respectively. You can optionally pass an empty string to get only the directional values as properties. You can also optionally pass a null argument for a directional value to ignore it.
  492. * @example
  493. * // Styles as object usage
  494. * const styles = {
  495. * ...directionalProperty('padding', '12px', '24px', '36px', '48px')
  496. * }
  497. *
  498. * // styled-components usage
  499. * const div = styled.div`
  500. * ${directionalProperty('padding', '12px', '24px', '36px', '48px')}
  501. * `
  502. *
  503. * // CSS as JS Output
  504. *
  505. * div {
  506. * 'paddingTop': '12px',
  507. * 'paddingRight': '24px',
  508. * 'paddingBottom': '36px',
  509. * 'paddingLeft': '48px'
  510. * }
  511. */
  512. function directionalProperty(property) {
  513. for (var _len = arguments.length, values = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
  514. values[_key - 1] = arguments[_key];
  515. }
  516. // prettier-ignore
  517. var firstValue = values[0],
  518. _values$ = values[1],
  519. secondValue = _values$ === void 0 ? firstValue : _values$,
  520. _values$2 = values[2],
  521. thirdValue = _values$2 === void 0 ? firstValue : _values$2,
  522. _values$3 = values[3],
  523. fourthValue = _values$3 === void 0 ? secondValue : _values$3;
  524. var valuesWithDefaults = [firstValue, secondValue, thirdValue, fourthValue];
  525. return generateStyles(property, valuesWithDefaults);
  526. }
  527. /**
  528. * Check if a string ends with something
  529. * @private
  530. */
  531. function endsWith(string, suffix) {
  532. return string.substr(-suffix.length) === suffix;
  533. }
  534. var cssRegex$1 = /^([+-]?(?:\d+|\d*\.\d+))([a-z]*|%)$/;
  535. /**
  536. * Returns a given CSS value minus its unit of measure.
  537. *
  538. * @example
  539. * // Styles as object usage
  540. * const styles = {
  541. * '--dimension': stripUnit('100px')
  542. * }
  543. *
  544. * // styled-components usage
  545. * const div = styled.div`
  546. * --dimension: ${stripUnit('100px')};
  547. * `
  548. *
  549. * // CSS in JS Output
  550. *
  551. * element {
  552. * '--dimension': 100
  553. * }
  554. */
  555. function stripUnit(value) {
  556. if (typeof value !== 'string') return value;
  557. var matchedValue = value.match(cssRegex$1);
  558. return matchedValue ? parseFloat(value) : value;
  559. }
  560. /**
  561. * Factory function that creates pixel-to-x converters
  562. * @private
  563. */
  564. var pxtoFactory = function pxtoFactory(to) {
  565. return function (pxval, base) {
  566. if (base === void 0) {
  567. base = '16px';
  568. }
  569. var newPxval = pxval;
  570. var newBase = base;
  571. if (typeof pxval === 'string') {
  572. if (!endsWith(pxval, 'px')) {
  573. throw new PolishedError(69, to, pxval);
  574. }
  575. newPxval = stripUnit(pxval);
  576. }
  577. if (typeof base === 'string') {
  578. if (!endsWith(base, 'px')) {
  579. throw new PolishedError(70, to, base);
  580. }
  581. newBase = stripUnit(base);
  582. }
  583. if (typeof newPxval === 'string') {
  584. throw new PolishedError(71, pxval, to);
  585. }
  586. if (typeof newBase === 'string') {
  587. throw new PolishedError(72, base, to);
  588. }
  589. return "" + newPxval / newBase + to;
  590. };
  591. };
  592. var pixelsto = pxtoFactory;
  593. /**
  594. * Convert pixel value to ems. The default base value is 16px, but can be changed by passing a
  595. * second argument to the function.
  596. * @function
  597. * @param {string|number} pxval
  598. * @param {string|number} [base='16px']
  599. * @example
  600. * // Styles as object usage
  601. * const styles = {
  602. * 'height': em('16px')
  603. * }
  604. *
  605. * // styled-components usage
  606. * const div = styled.div`
  607. * height: ${em('16px')}
  608. * `
  609. *
  610. * // CSS in JS Output
  611. *
  612. * element {
  613. * 'height': '1em'
  614. * }
  615. */
  616. var em = pixelsto('em');
  617. var em$1 = em;
  618. var cssRegex = /^([+-]?(?:\d+|\d*\.\d+))([a-z]*|%)$/;
  619. /**
  620. * Returns a given CSS value and its unit as elements of an array.
  621. *
  622. * @example
  623. * // Styles as object usage
  624. * const styles = {
  625. * '--dimension': getValueAndUnit('100px')[0],
  626. * '--unit': getValueAndUnit('100px')[1],
  627. * }
  628. *
  629. * // styled-components usage
  630. * const div = styled.div`
  631. * --dimension: ${getValueAndUnit('100px')[0]};
  632. * --unit: ${getValueAndUnit('100px')[1]};
  633. * `
  634. *
  635. * // CSS in JS Output
  636. *
  637. * element {
  638. * '--dimension': 100,
  639. * '--unit': 'px',
  640. * }
  641. */
  642. function getValueAndUnit(value) {
  643. if (typeof value !== 'string') return [value, ''];
  644. var matchedValue = value.match(cssRegex);
  645. if (matchedValue) return [parseFloat(value), matchedValue[2]];
  646. return [value, undefined];
  647. }
  648. /**
  649. * Helper for targeting rules in a style block generated by polished modules that need !important-level specificity. Can optionally specify a rule (or rules) to target specific rules.
  650. *
  651. * @example
  652. * // Styles as object usage
  653. * const styles = {
  654. * ...important(cover())
  655. * }
  656. *
  657. * // styled-components usage
  658. * const div = styled.div`
  659. * ${important(cover())}
  660. * `
  661. *
  662. * // CSS as JS Output
  663. *
  664. * div: {
  665. * 'position': 'absolute !important',
  666. * 'top': '0 !important',
  667. * 'right: '0 !important',
  668. * 'bottom': '0 !important',
  669. * 'left: '0 !important'
  670. * }
  671. */
  672. function important(styleBlock, rules) {
  673. if (typeof styleBlock !== 'object' || styleBlock === null) {
  674. throw new PolishedError(75, typeof styleBlock);
  675. }
  676. var newStyleBlock = {};
  677. Object.keys(styleBlock).forEach(function (key) {
  678. if (typeof styleBlock[key] === 'object' && styleBlock[key] !== null) {
  679. newStyleBlock[key] = important(styleBlock[key], rules);
  680. } else if (!rules || rules && (rules === key || rules.indexOf(key) >= 0)) {
  681. newStyleBlock[key] = styleBlock[key] + " !important";
  682. } else {
  683. newStyleBlock[key] = styleBlock[key];
  684. }
  685. });
  686. return newStyleBlock;
  687. }
  688. var ratioNames = {
  689. minorSecond: 1.067,
  690. majorSecond: 1.125,
  691. minorThird: 1.2,
  692. majorThird: 1.25,
  693. perfectFourth: 1.333,
  694. augFourth: 1.414,
  695. perfectFifth: 1.5,
  696. minorSixth: 1.6,
  697. goldenSection: 1.618,
  698. majorSixth: 1.667,
  699. minorSeventh: 1.778,
  700. majorSeventh: 1.875,
  701. octave: 2,
  702. majorTenth: 2.5,
  703. majorEleventh: 2.667,
  704. majorTwelfth: 3,
  705. doubleOctave: 4
  706. };
  707. function getRatio(ratioName) {
  708. return ratioNames[ratioName];
  709. }
  710. /**
  711. * Establish consistent measurements and spacial relationships throughout your projects by incrementing an em or rem value up or down a defined scale. We provide a list of commonly used scales as pre-defined variables.
  712. * @example
  713. * // Styles as object usage
  714. * const styles = {
  715. * // Increment two steps up the default scale
  716. * 'fontSize': modularScale(2)
  717. * }
  718. *
  719. * // styled-components usage
  720. * const div = styled.div`
  721. * // Increment two steps up the default scale
  722. * fontSize: ${modularScale(2)}
  723. * `
  724. *
  725. * // CSS in JS Output
  726. *
  727. * element {
  728. * 'fontSize': '1.77689em'
  729. * }
  730. */
  731. function modularScale(steps, base, ratio) {
  732. if (base === void 0) {
  733. base = '1em';
  734. }
  735. if (ratio === void 0) {
  736. ratio = 1.333;
  737. }
  738. if (typeof steps !== 'number') {
  739. throw new PolishedError(42);
  740. }
  741. if (typeof ratio === 'string' && !ratioNames[ratio]) {
  742. throw new PolishedError(43);
  743. }
  744. var _ref = typeof base === 'string' ? getValueAndUnit(base) : [base, ''],
  745. realBase = _ref[0],
  746. unit = _ref[1];
  747. var realRatio = typeof ratio === 'string' ? getRatio(ratio) : ratio;
  748. if (typeof realBase === 'string') {
  749. throw new PolishedError(44, base);
  750. }
  751. return "" + realBase * Math.pow(realRatio, steps) + (unit || '');
  752. }
  753. /**
  754. * Convert pixel value to rems. The default base value is 16px, but can be changed by passing a
  755. * second argument to the function.
  756. * @function
  757. * @param {string|number} pxval
  758. * @param {string|number} [base='16px']
  759. * @example
  760. * // Styles as object usage
  761. * const styles = {
  762. * 'height': rem('16px')
  763. * }
  764. *
  765. * // styled-components usage
  766. * const div = styled.div`
  767. * height: ${rem('16px')}
  768. * `
  769. *
  770. * // CSS in JS Output
  771. *
  772. * element {
  773. * 'height': '1rem'
  774. * }
  775. */
  776. var rem = pixelsto('rem');
  777. var rem$1 = rem;
  778. var defaultFontSize = 16;
  779. function convertBase(base) {
  780. var deconstructedValue = getValueAndUnit(base);
  781. if (deconstructedValue[1] === 'px') {
  782. return parseFloat(base);
  783. }
  784. if (deconstructedValue[1] === '%') {
  785. return parseFloat(base) / 100 * defaultFontSize;
  786. }
  787. throw new PolishedError(78, deconstructedValue[1]);
  788. }
  789. function getBaseFromDoc() {
  790. /* eslint-disable */
  791. /* istanbul ignore next */
  792. if (typeof document !== 'undefined' && document.documentElement !== null) {
  793. var rootFontSize = getComputedStyle(document.documentElement).fontSize;
  794. return rootFontSize ? convertBase(rootFontSize) : defaultFontSize;
  795. }
  796. /* eslint-enable */
  797. /* istanbul ignore next */
  798. return defaultFontSize;
  799. }
  800. /**
  801. * Convert rem values to px. By default, the base value is pulled from the font-size property on the root element (if it is set in % or px). It defaults to 16px if not found on the root. You can also override the base value by providing your own base in % or px.
  802. * @example
  803. * // Styles as object usage
  804. * const styles = {
  805. * 'height': remToPx('1.6rem')
  806. * 'height': remToPx('1.6rem', '10px')
  807. * }
  808. *
  809. * // styled-components usage
  810. * const div = styled.div`
  811. * height: ${remToPx('1.6rem')}
  812. * height: ${remToPx('1.6rem', '10px')}
  813. * `
  814. *
  815. * // CSS in JS Output
  816. *
  817. * element {
  818. * 'height': '25.6px',
  819. * 'height': '16px',
  820. * }
  821. */
  822. function remToPx(value, base) {
  823. var deconstructedValue = getValueAndUnit(value);
  824. if (deconstructedValue[1] !== 'rem' && deconstructedValue[1] !== '') {
  825. throw new PolishedError(77, deconstructedValue[1]);
  826. }
  827. var newBase = base ? convertBase(base) : getBaseFromDoc();
  828. return deconstructedValue[0] * newBase + "px";
  829. }
  830. var functionsMap$3 = {
  831. back: 'cubic-bezier(0.600, -0.280, 0.735, 0.045)',
  832. circ: 'cubic-bezier(0.600, 0.040, 0.980, 0.335)',
  833. cubic: 'cubic-bezier(0.550, 0.055, 0.675, 0.190)',
  834. expo: 'cubic-bezier(0.950, 0.050, 0.795, 0.035)',
  835. quad: 'cubic-bezier(0.550, 0.085, 0.680, 0.530)',
  836. quart: 'cubic-bezier(0.895, 0.030, 0.685, 0.220)',
  837. quint: 'cubic-bezier(0.755, 0.050, 0.855, 0.060)',
  838. sine: 'cubic-bezier(0.470, 0.000, 0.745, 0.715)'
  839. };
  840. /**
  841. * String to represent common easing functions as demonstrated here: (github.com/jaukia/easie).
  842. *
  843. * @example
  844. * // Styles as object usage
  845. * const styles = {
  846. * 'transitionTimingFunction': easeIn('quad')
  847. * }
  848. *
  849. * // styled-components usage
  850. * const div = styled.div`
  851. * transitionTimingFunction: ${easeIn('quad')};
  852. * `
  853. *
  854. * // CSS as JS Output
  855. *
  856. * 'div': {
  857. * 'transitionTimingFunction': 'cubic-bezier(0.550, 0.085, 0.680, 0.530)',
  858. * }
  859. */
  860. function easeIn(functionName) {
  861. return functionsMap$3[functionName.toLowerCase().trim()];
  862. }
  863. var functionsMap$2 = {
  864. back: 'cubic-bezier(0.680, -0.550, 0.265, 1.550)',
  865. circ: 'cubic-bezier(0.785, 0.135, 0.150, 0.860)',
  866. cubic: 'cubic-bezier(0.645, 0.045, 0.355, 1.000)',
  867. expo: 'cubic-bezier(1.000, 0.000, 0.000, 1.000)',
  868. quad: 'cubic-bezier(0.455, 0.030, 0.515, 0.955)',
  869. quart: 'cubic-bezier(0.770, 0.000, 0.175, 1.000)',
  870. quint: 'cubic-bezier(0.860, 0.000, 0.070, 1.000)',
  871. sine: 'cubic-bezier(0.445, 0.050, 0.550, 0.950)'
  872. };
  873. /**
  874. * String to represent common easing functions as demonstrated here: (github.com/jaukia/easie).
  875. *
  876. * @example
  877. * // Styles as object usage
  878. * const styles = {
  879. * 'transitionTimingFunction': easeInOut('quad')
  880. * }
  881. *
  882. * // styled-components usage
  883. * const div = styled.div`
  884. * transitionTimingFunction: ${easeInOut('quad')};
  885. * `
  886. *
  887. * // CSS as JS Output
  888. *
  889. * 'div': {
  890. * 'transitionTimingFunction': 'cubic-bezier(0.455, 0.030, 0.515, 0.955)',
  891. * }
  892. */
  893. function easeInOut(functionName) {
  894. return functionsMap$2[functionName.toLowerCase().trim()];
  895. }
  896. var functionsMap$1 = {
  897. back: 'cubic-bezier(0.175, 0.885, 0.320, 1.275)',
  898. cubic: 'cubic-bezier(0.215, 0.610, 0.355, 1.000)',
  899. circ: 'cubic-bezier(0.075, 0.820, 0.165, 1.000)',
  900. expo: 'cubic-bezier(0.190, 1.000, 0.220, 1.000)',
  901. quad: 'cubic-bezier(0.250, 0.460, 0.450, 0.940)',
  902. quart: 'cubic-bezier(0.165, 0.840, 0.440, 1.000)',
  903. quint: 'cubic-bezier(0.230, 1.000, 0.320, 1.000)',
  904. sine: 'cubic-bezier(0.390, 0.575, 0.565, 1.000)'
  905. };
  906. /**
  907. * String to represent common easing functions as demonstrated here: (github.com/jaukia/easie).
  908. *
  909. * @example
  910. * // Styles as object usage
  911. * const styles = {
  912. * 'transitionTimingFunction': easeOut('quad')
  913. * }
  914. *
  915. * // styled-components usage
  916. * const div = styled.div`
  917. * transitionTimingFunction: ${easeOut('quad')};
  918. * `
  919. *
  920. * // CSS as JS Output
  921. *
  922. * 'div': {
  923. * 'transitionTimingFunction': 'cubic-bezier(0.250, 0.460, 0.450, 0.940)',
  924. * }
  925. */
  926. function easeOut(functionName) {
  927. return functionsMap$1[functionName.toLowerCase().trim()];
  928. }
  929. /**
  930. * Returns a CSS calc formula for linear interpolation of a property between two values. Accepts optional minScreen (defaults to '320px') and maxScreen (defaults to '1200px').
  931. *
  932. * @example
  933. * // Styles as object usage
  934. * const styles = {
  935. * fontSize: between('20px', '100px', '400px', '1000px'),
  936. * fontSize: between('20px', '100px')
  937. * }
  938. *
  939. * // styled-components usage
  940. * const div = styled.div`
  941. * fontSize: ${between('20px', '100px', '400px', '1000px')};
  942. * fontSize: ${between('20px', '100px')}
  943. * `
  944. *
  945. * // CSS as JS Output
  946. *
  947. * h1: {
  948. * 'fontSize': 'calc(-33.33333333333334px + 13.333333333333334vw)',
  949. * 'fontSize': 'calc(-9.090909090909093px + 9.090909090909092vw)'
  950. * }
  951. */
  952. function between(fromSize, toSize, minScreen, maxScreen) {
  953. if (minScreen === void 0) {
  954. minScreen = '320px';
  955. }
  956. if (maxScreen === void 0) {
  957. maxScreen = '1200px';
  958. }
  959. var _getValueAndUnit = getValueAndUnit(fromSize),
  960. unitlessFromSize = _getValueAndUnit[0],
  961. fromSizeUnit = _getValueAndUnit[1];
  962. var _getValueAndUnit2 = getValueAndUnit(toSize),
  963. unitlessToSize = _getValueAndUnit2[0],
  964. toSizeUnit = _getValueAndUnit2[1];
  965. var _getValueAndUnit3 = getValueAndUnit(minScreen),
  966. unitlessMinScreen = _getValueAndUnit3[0],
  967. minScreenUnit = _getValueAndUnit3[1];
  968. var _getValueAndUnit4 = getValueAndUnit(maxScreen),
  969. unitlessMaxScreen = _getValueAndUnit4[0],
  970. maxScreenUnit = _getValueAndUnit4[1];
  971. if (typeof unitlessMinScreen !== 'number' || typeof unitlessMaxScreen !== 'number' || !minScreenUnit || !maxScreenUnit || minScreenUnit !== maxScreenUnit) {
  972. throw new PolishedError(47);
  973. }
  974. if (typeof unitlessFromSize !== 'number' || typeof unitlessToSize !== 'number' || fromSizeUnit !== toSizeUnit) {
  975. throw new PolishedError(48);
  976. }
  977. if (fromSizeUnit !== minScreenUnit || toSizeUnit !== maxScreenUnit) {
  978. throw new PolishedError(76);
  979. }
  980. var slope = (unitlessFromSize - unitlessToSize) / (unitlessMinScreen - unitlessMaxScreen);
  981. var base = unitlessToSize - slope * unitlessMaxScreen;
  982. return "calc(" + base.toFixed(2) + (fromSizeUnit || '') + " + " + (100 * slope).toFixed(2) + "vw)";
  983. }
  984. /**
  985. * CSS to contain a float (credit to CSSMojo).
  986. *
  987. * @example
  988. * // Styles as object usage
  989. * const styles = {
  990. * ...clearFix(),
  991. * }
  992. *
  993. * // styled-components usage
  994. * const div = styled.div`
  995. * ${clearFix()}
  996. * `
  997. *
  998. * // CSS as JS Output
  999. *
  1000. * '&::after': {
  1001. * 'clear': 'both',
  1002. * 'content': '""',
  1003. * 'display': 'table'
  1004. * }
  1005. */
  1006. function clearFix(parent) {
  1007. var _ref;
  1008. if (parent === void 0) {
  1009. parent = '&';
  1010. }
  1011. var pseudoSelector = parent + "::after";
  1012. return _ref = {}, _ref[pseudoSelector] = {
  1013. clear: 'both',
  1014. content: '""',
  1015. display: 'table'
  1016. }, _ref;
  1017. }
  1018. /**
  1019. * CSS to fully cover an area. Can optionally be passed an offset to act as a "padding".
  1020. *
  1021. * @example
  1022. * // Styles as object usage
  1023. * const styles = {
  1024. * ...cover()
  1025. * }
  1026. *
  1027. * // styled-components usage
  1028. * const div = styled.div`
  1029. * ${cover()}
  1030. * `
  1031. *
  1032. * // CSS as JS Output
  1033. *
  1034. * div: {
  1035. * 'position': 'absolute',
  1036. * 'top': '0',
  1037. * 'right: '0',
  1038. * 'bottom': '0',
  1039. * 'left: '0'
  1040. * }
  1041. */
  1042. function cover(offset) {
  1043. if (offset === void 0) {
  1044. offset = 0;
  1045. }
  1046. return {
  1047. position: 'absolute',
  1048. top: offset,
  1049. right: offset,
  1050. bottom: offset,
  1051. left: offset
  1052. };
  1053. }
  1054. /**
  1055. * CSS to represent truncated text with an ellipsis. You can optionally pass a max-width and number of lines before truncating.
  1056. *
  1057. * @example
  1058. * // Styles as object usage
  1059. * const styles = {
  1060. * ...ellipsis('250px')
  1061. * }
  1062. *
  1063. * // styled-components usage
  1064. * const div = styled.div`
  1065. * ${ellipsis('250px')}
  1066. * `
  1067. *
  1068. * // CSS as JS Output
  1069. *
  1070. * div: {
  1071. * 'display': 'inline-block',
  1072. * 'maxWidth': '250px',
  1073. * 'overflow': 'hidden',
  1074. * 'textOverflow': 'ellipsis',
  1075. * 'whiteSpace': 'nowrap',
  1076. * 'wordWrap': 'normal'
  1077. * }
  1078. */
  1079. function ellipsis(width, lines) {
  1080. if (lines === void 0) {
  1081. lines = 1;
  1082. }
  1083. var styles = {
  1084. display: 'inline-block',
  1085. maxWidth: width || '100%',
  1086. overflow: 'hidden',
  1087. textOverflow: 'ellipsis',
  1088. whiteSpace: 'nowrap',
  1089. wordWrap: 'normal'
  1090. };
  1091. return lines > 1 ? _extends__default["default"]({}, styles, {
  1092. WebkitBoxOrient: 'vertical',
  1093. WebkitLineClamp: lines,
  1094. display: '-webkit-box',
  1095. whiteSpace: 'normal'
  1096. }) : styles;
  1097. }
  1098. function _createForOfIteratorHelperLoose(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (it) return (it = it.call(o)).next.bind(it); if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; return function () { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
  1099. function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
  1100. function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
  1101. /**
  1102. * Returns a set of media queries that resizes a property (or set of properties) between a provided fromSize and toSize. Accepts optional minScreen (defaults to '320px') and maxScreen (defaults to '1200px') to constrain the interpolation.
  1103. *
  1104. * @example
  1105. * // Styles as object usage
  1106. * const styles = {
  1107. * ...fluidRange(
  1108. * {
  1109. * prop: 'padding',
  1110. * fromSize: '20px',
  1111. * toSize: '100px',
  1112. * },
  1113. * '400px',
  1114. * '1000px',
  1115. * )
  1116. * }
  1117. *
  1118. * // styled-components usage
  1119. * const div = styled.div`
  1120. * ${fluidRange(
  1121. * {
  1122. * prop: 'padding',
  1123. * fromSize: '20px',
  1124. * toSize: '100px',
  1125. * },
  1126. * '400px',
  1127. * '1000px',
  1128. * )}
  1129. * `
  1130. *
  1131. * // CSS as JS Output
  1132. *
  1133. * div: {
  1134. * "@media (min-width: 1000px)": Object {
  1135. * "padding": "100px",
  1136. * },
  1137. * "@media (min-width: 400px)": Object {
  1138. * "padding": "calc(-33.33333333333334px + 13.333333333333334vw)",
  1139. * },
  1140. * "padding": "20px",
  1141. * }
  1142. */
  1143. function fluidRange(cssProp, minScreen, maxScreen) {
  1144. if (minScreen === void 0) {
  1145. minScreen = '320px';
  1146. }
  1147. if (maxScreen === void 0) {
  1148. maxScreen = '1200px';
  1149. }
  1150. if (!Array.isArray(cssProp) && typeof cssProp !== 'object' || cssProp === null) {
  1151. throw new PolishedError(49);
  1152. }
  1153. if (Array.isArray(cssProp)) {
  1154. var mediaQueries = {};
  1155. var fallbacks = {};
  1156. for (var _iterator = _createForOfIteratorHelperLoose(cssProp), _step; !(_step = _iterator()).done;) {
  1157. var _extends2, _extends3;
  1158. var obj = _step.value;
  1159. if (!obj.prop || !obj.fromSize || !obj.toSize) {
  1160. throw new PolishedError(50);
  1161. }
  1162. fallbacks[obj.prop] = obj.fromSize;
  1163. mediaQueries["@media (min-width: " + minScreen + ")"] = _extends__default["default"]({}, mediaQueries["@media (min-width: " + minScreen + ")"], (_extends2 = {}, _extends2[obj.prop] = between(obj.fromSize, obj.toSize, minScreen, maxScreen), _extends2));
  1164. mediaQueries["@media (min-width: " + maxScreen + ")"] = _extends__default["default"]({}, mediaQueries["@media (min-width: " + maxScreen + ")"], (_extends3 = {}, _extends3[obj.prop] = obj.toSize, _extends3));
  1165. }
  1166. return _extends__default["default"]({}, fallbacks, mediaQueries);
  1167. } else {
  1168. var _ref, _ref2, _ref3;
  1169. if (!cssProp.prop || !cssProp.fromSize || !cssProp.toSize) {
  1170. throw new PolishedError(51);
  1171. }
  1172. return _ref3 = {}, _ref3[cssProp.prop] = cssProp.fromSize, _ref3["@media (min-width: " + minScreen + ")"] = (_ref = {}, _ref[cssProp.prop] = between(cssProp.fromSize, cssProp.toSize, minScreen, maxScreen), _ref), _ref3["@media (min-width: " + maxScreen + ")"] = (_ref2 = {}, _ref2[cssProp.prop] = cssProp.toSize, _ref2), _ref3;
  1173. }
  1174. }
  1175. var dataURIRegex = /^\s*data:([a-z]+\/[a-z-]+(;[a-z-]+=[a-z-]+)?)?(;charset=[a-z0-9-]+)?(;base64)?,[a-z0-9!$&',()*+,;=\-._~:@/?%\s]*\s*$/i;
  1176. var formatHintMap = {
  1177. woff: 'woff',
  1178. woff2: 'woff2',
  1179. ttf: 'truetype',
  1180. otf: 'opentype',
  1181. eot: 'embedded-opentype',
  1182. svg: 'svg',
  1183. svgz: 'svg'
  1184. };
  1185. function generateFormatHint(format, formatHint) {
  1186. if (!formatHint) return '';
  1187. return " format(\"" + formatHintMap[format] + "\")";
  1188. }
  1189. function isDataURI(fontFilePath) {
  1190. return !!fontFilePath.replace(/\s+/g, ' ').match(dataURIRegex);
  1191. }
  1192. function generateFileReferences(fontFilePath, fileFormats, formatHint) {
  1193. if (isDataURI(fontFilePath)) {
  1194. return "url(\"" + fontFilePath + "\")" + generateFormatHint(fileFormats[0], formatHint);
  1195. }
  1196. var fileFontReferences = fileFormats.map(function (format) {
  1197. return "url(\"" + fontFilePath + "." + format + "\")" + generateFormatHint(format, formatHint);
  1198. });
  1199. return fileFontReferences.join(', ');
  1200. }
  1201. function generateLocalReferences(localFonts) {
  1202. var localFontReferences = localFonts.map(function (font) {
  1203. return "local(\"" + font + "\")";
  1204. });
  1205. return localFontReferences.join(', ');
  1206. }
  1207. function generateSources(fontFilePath, localFonts, fileFormats, formatHint) {
  1208. var fontReferences = [];
  1209. if (localFonts) fontReferences.push(generateLocalReferences(localFonts));
  1210. if (fontFilePath) {
  1211. fontReferences.push(generateFileReferences(fontFilePath, fileFormats, formatHint));
  1212. }
  1213. return fontReferences.join(', ');
  1214. }
  1215. /**
  1216. * CSS for a @font-face declaration. Defaults to check for local copies of the font on the user's machine. You can disable this by passing `null` to localFonts.
  1217. *
  1218. * @example
  1219. * // Styles as object basic usage
  1220. * const styles = {
  1221. * ...fontFace({
  1222. * 'fontFamily': 'Sans-Pro',
  1223. * 'fontFilePath': 'path/to/file'
  1224. * })
  1225. * }
  1226. *
  1227. * // styled-components basic usage
  1228. * const GlobalStyle = createGlobalStyle`${
  1229. * fontFace({
  1230. * 'fontFamily': 'Sans-Pro',
  1231. * 'fontFilePath': 'path/to/file'
  1232. * }
  1233. * )}`
  1234. *
  1235. * // CSS as JS Output
  1236. *
  1237. * '@font-face': {
  1238. * 'fontFamily': 'Sans-Pro',
  1239. * 'src': 'url("path/to/file.eot"), url("path/to/file.woff2"), url("path/to/file.woff"), url("path/to/file.ttf"), url("path/to/file.svg")',
  1240. * }
  1241. */
  1242. function fontFace(_ref) {
  1243. var fontFamily = _ref.fontFamily,
  1244. fontFilePath = _ref.fontFilePath,
  1245. fontStretch = _ref.fontStretch,
  1246. fontStyle = _ref.fontStyle,
  1247. fontVariant = _ref.fontVariant,
  1248. fontWeight = _ref.fontWeight,
  1249. _ref$fileFormats = _ref.fileFormats,
  1250. fileFormats = _ref$fileFormats === void 0 ? ['eot', 'woff2', 'woff', 'ttf', 'svg'] : _ref$fileFormats,
  1251. _ref$formatHint = _ref.formatHint,
  1252. formatHint = _ref$formatHint === void 0 ? false : _ref$formatHint,
  1253. _ref$localFonts = _ref.localFonts,
  1254. localFonts = _ref$localFonts === void 0 ? [fontFamily] : _ref$localFonts,
  1255. unicodeRange = _ref.unicodeRange,
  1256. fontDisplay = _ref.fontDisplay,
  1257. fontVariationSettings = _ref.fontVariationSettings,
  1258. fontFeatureSettings = _ref.fontFeatureSettings;
  1259. // Error Handling
  1260. if (!fontFamily) throw new PolishedError(55);
  1261. if (!fontFilePath && !localFonts) {
  1262. throw new PolishedError(52);
  1263. }
  1264. if (localFonts && !Array.isArray(localFonts)) {
  1265. throw new PolishedError(53);
  1266. }
  1267. if (!Array.isArray(fileFormats)) {
  1268. throw new PolishedError(54);
  1269. }
  1270. var fontFaceDeclaration = {
  1271. '@font-face': {
  1272. fontFamily: fontFamily,
  1273. src: generateSources(fontFilePath, localFonts, fileFormats, formatHint),
  1274. unicodeRange: unicodeRange,
  1275. fontStretch: fontStretch,
  1276. fontStyle: fontStyle,
  1277. fontVariant: fontVariant,
  1278. fontWeight: fontWeight,
  1279. fontDisplay: fontDisplay,
  1280. fontVariationSettings: fontVariationSettings,
  1281. fontFeatureSettings: fontFeatureSettings
  1282. }
  1283. };
  1284. // Removes undefined fields for cleaner css object.
  1285. return JSON.parse(JSON.stringify(fontFaceDeclaration));
  1286. }
  1287. /**
  1288. * CSS to hide text to show a background image in a SEO-friendly way.
  1289. *
  1290. * @example
  1291. * // Styles as object usage
  1292. * const styles = {
  1293. * 'backgroundImage': 'url(logo.png)',
  1294. * ...hideText(),
  1295. * }
  1296. *
  1297. * // styled-components usage
  1298. * const div = styled.div`
  1299. * backgroundImage: url(logo.png);
  1300. * ${hideText()};
  1301. * `
  1302. *
  1303. * // CSS as JS Output
  1304. *
  1305. * 'div': {
  1306. * 'backgroundImage': 'url(logo.png)',
  1307. * 'textIndent': '101%',
  1308. * 'overflow': 'hidden',
  1309. * 'whiteSpace': 'nowrap',
  1310. * }
  1311. */
  1312. function hideText() {
  1313. return {
  1314. textIndent: '101%',
  1315. overflow: 'hidden',
  1316. whiteSpace: 'nowrap'
  1317. };
  1318. }
  1319. /**
  1320. * CSS to hide content visually but remain accessible to screen readers.
  1321. * from [HTML5 Boilerplate](https://github.com/h5bp/html5-boilerplate/blob/9a176f57af1cfe8ec70300da4621fb9b07e5fa31/src/css/main.css#L121)
  1322. *
  1323. * @example
  1324. * // Styles as object usage
  1325. * const styles = {
  1326. * ...hideVisually(),
  1327. * }
  1328. *
  1329. * // styled-components usage
  1330. * const div = styled.div`
  1331. * ${hideVisually()};
  1332. * `
  1333. *
  1334. * // CSS as JS Output
  1335. *
  1336. * 'div': {
  1337. * 'border': '0',
  1338. * 'clip': 'rect(0 0 0 0)',
  1339. * 'height': '1px',
  1340. * 'margin': '-1px',
  1341. * 'overflow': 'hidden',
  1342. * 'padding': '0',
  1343. * 'position': 'absolute',
  1344. * 'whiteSpace': 'nowrap',
  1345. * 'width': '1px',
  1346. * }
  1347. */
  1348. function hideVisually() {
  1349. return {
  1350. border: '0',
  1351. clip: 'rect(0 0 0 0)',
  1352. height: '1px',
  1353. margin: '-1px',
  1354. overflow: 'hidden',
  1355. padding: '0',
  1356. position: 'absolute',
  1357. whiteSpace: 'nowrap',
  1358. width: '1px'
  1359. };
  1360. }
  1361. /**
  1362. * Generates a media query to target HiDPI devices.
  1363. *
  1364. * @example
  1365. * // Styles as object usage
  1366. * const styles = {
  1367. * [hiDPI(1.5)]: {
  1368. * width: 200px;
  1369. * }
  1370. * }
  1371. *
  1372. * // styled-components usage
  1373. * const div = styled.div`
  1374. * ${hiDPI(1.5)} {
  1375. * width: 200px;
  1376. * }
  1377. * `
  1378. *
  1379. * // CSS as JS Output
  1380. *
  1381. * '@media only screen and (-webkit-min-device-pixel-ratio: 1.5),
  1382. * only screen and (min--moz-device-pixel-ratio: 1.5),
  1383. * only screen and (-o-min-device-pixel-ratio: 1.5/1),
  1384. * only screen and (min-resolution: 144dpi),
  1385. * only screen and (min-resolution: 1.5dppx)': {
  1386. * 'width': '200px',
  1387. * }
  1388. */
  1389. function hiDPI(ratio) {
  1390. if (ratio === void 0) {
  1391. ratio = 1.3;
  1392. }
  1393. return "\n @media only screen and (-webkit-min-device-pixel-ratio: " + ratio + "),\n only screen and (min--moz-device-pixel-ratio: " + ratio + "),\n only screen and (-o-min-device-pixel-ratio: " + ratio + "/1),\n only screen and (min-resolution: " + Math.round(ratio * 96) + "dpi),\n only screen and (min-resolution: " + ratio + "dppx)\n ";
  1394. }
  1395. function constructGradientValue(literals) {
  1396. var template = '';
  1397. for (var _len = arguments.length, substitutions = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
  1398. substitutions[_key - 1] = arguments[_key];
  1399. }
  1400. for (var i = 0; i < literals.length; i += 1) {
  1401. template += literals[i];
  1402. if (i === substitutions.length - 1 && substitutions[i]) {
  1403. var definedValues = substitutions.filter(function (substitute) {
  1404. return !!substitute;
  1405. });
  1406. // Adds leading coma if properties preceed color-stops
  1407. if (definedValues.length > 1) {
  1408. template = template.slice(0, -1);
  1409. template += ", " + substitutions[i];
  1410. // No trailing space if color-stops is the only param provided
  1411. } else if (definedValues.length === 1) {
  1412. template += "" + substitutions[i];
  1413. }
  1414. } else if (substitutions[i]) {
  1415. template += substitutions[i] + " ";
  1416. }
  1417. }
  1418. return template.trim();
  1419. }
  1420. var _templateObject$1;
  1421. /**
  1422. * CSS for declaring a linear gradient, including a fallback background-color. The fallback is either the first color-stop or an explicitly passed fallback color.
  1423. *
  1424. * @example
  1425. * // Styles as object usage
  1426. * const styles = {
  1427. * ...linearGradient({
  1428. colorStops: ['#00FFFF 0%', 'rgba(0, 0, 255, 0) 50%', '#0000FF 95%'],
  1429. toDirection: 'to top right',
  1430. fallback: '#FFF',
  1431. })
  1432. * }
  1433. *
  1434. * // styled-components usage
  1435. * const div = styled.div`
  1436. * ${linearGradient({
  1437. colorStops: ['#00FFFF 0%', 'rgba(0, 0, 255, 0) 50%', '#0000FF 95%'],
  1438. toDirection: 'to top right',
  1439. fallback: '#FFF',
  1440. })}
  1441. *`
  1442. *
  1443. * // CSS as JS Output
  1444. *
  1445. * div: {
  1446. * 'backgroundColor': '#FFF',
  1447. * 'backgroundImage': 'linear-gradient(to top right, #00FFFF 0%, rgba(0, 0, 255, 0) 50%, #0000FF 95%)',
  1448. * }
  1449. */
  1450. function linearGradient(_ref) {
  1451. var colorStops = _ref.colorStops,
  1452. fallback = _ref.fallback,
  1453. _ref$toDirection = _ref.toDirection,
  1454. toDirection = _ref$toDirection === void 0 ? '' : _ref$toDirection;
  1455. if (!colorStops || colorStops.length < 2) {
  1456. throw new PolishedError(56);
  1457. }
  1458. return {
  1459. backgroundColor: fallback || colorStops[0].replace(/,\s+/g, ',').split(' ')[0].replace(/,(?=\S)/g, ', '),
  1460. backgroundImage: constructGradientValue(_templateObject$1 || (_templateObject$1 = _taggedTemplateLiteralLoose__default["default"](["linear-gradient(", "", ")"])), toDirection, colorStops.join(', ').replace(/,(?=\S)/g, ', '))
  1461. };
  1462. }
  1463. /**
  1464. * CSS to normalize abnormalities across browsers (normalize.css v8.0.1 | MIT License | github.com/necolas/normalize.css)
  1465. *
  1466. * @example
  1467. * // Styles as object usage
  1468. * const styles = {
  1469. * ...normalize(),
  1470. * }
  1471. *
  1472. * // styled-components usage
  1473. * const GlobalStyle = createGlobalStyle`${normalize()}`
  1474. *
  1475. * // CSS as JS Output
  1476. *
  1477. * html {
  1478. * lineHeight: 1.15,
  1479. * textSizeAdjust: 100%,
  1480. * } ...
  1481. */
  1482. function normalize() {
  1483. var _ref;
  1484. return [(_ref = {
  1485. html: {
  1486. lineHeight: '1.15',
  1487. textSizeAdjust: '100%'
  1488. },
  1489. body: {
  1490. margin: '0'
  1491. },
  1492. main: {
  1493. display: 'block'
  1494. },
  1495. h1: {
  1496. fontSize: '2em',
  1497. margin: '0.67em 0'
  1498. },
  1499. hr: {
  1500. boxSizing: 'content-box',
  1501. height: '0',
  1502. overflow: 'visible'
  1503. },
  1504. pre: {
  1505. fontFamily: 'monospace, monospace',
  1506. fontSize: '1em'
  1507. },
  1508. a: {
  1509. backgroundColor: 'transparent'
  1510. },
  1511. 'abbr[title]': {
  1512. borderBottom: 'none',
  1513. textDecoration: 'underline'
  1514. }
  1515. }, _ref["b,\n strong"] = {
  1516. fontWeight: 'bolder'
  1517. }, _ref["code,\n kbd,\n samp"] = {
  1518. fontFamily: 'monospace, monospace',
  1519. fontSize: '1em'
  1520. }, _ref.small = {
  1521. fontSize: '80%'
  1522. }, _ref["sub,\n sup"] = {
  1523. fontSize: '75%',
  1524. lineHeight: '0',
  1525. position: 'relative',
  1526. verticalAlign: 'baseline'
  1527. }, _ref.sub = {
  1528. bottom: '-0.25em'
  1529. }, _ref.sup = {
  1530. top: '-0.5em'
  1531. }, _ref.img = {
  1532. borderStyle: 'none'
  1533. }, _ref["button,\n input,\n optgroup,\n select,\n textarea"] = {
  1534. fontFamily: 'inherit',
  1535. fontSize: '100%',
  1536. lineHeight: '1.15',
  1537. margin: '0'
  1538. }, _ref["button,\n input"] = {
  1539. overflow: 'visible'
  1540. }, _ref["button,\n select"] = {
  1541. textTransform: 'none'
  1542. }, _ref["button,\n html [type=\"button\"],\n [type=\"reset\"],\n [type=\"submit\"]"] = {
  1543. WebkitAppearance: 'button'
  1544. }, _ref["button::-moz-focus-inner,\n [type=\"button\"]::-moz-focus-inner,\n [type=\"reset\"]::-moz-focus-inner,\n [type=\"submit\"]::-moz-focus-inner"] = {
  1545. borderStyle: 'none',
  1546. padding: '0'
  1547. }, _ref["button:-moz-focusring,\n [type=\"button\"]:-moz-focusring,\n [type=\"reset\"]:-moz-focusring,\n [type=\"submit\"]:-moz-focusring"] = {
  1548. outline: '1px dotted ButtonText'
  1549. }, _ref.fieldset = {
  1550. padding: '0.35em 0.625em 0.75em'
  1551. }, _ref.legend = {
  1552. boxSizing: 'border-box',
  1553. color: 'inherit',
  1554. display: 'table',
  1555. maxWidth: '100%',
  1556. padding: '0',
  1557. whiteSpace: 'normal'
  1558. }, _ref.progress = {
  1559. verticalAlign: 'baseline'
  1560. }, _ref.textarea = {
  1561. overflow: 'auto'
  1562. }, _ref["[type=\"checkbox\"],\n [type=\"radio\"]"] = {
  1563. boxSizing: 'border-box',
  1564. padding: '0'
  1565. }, _ref["[type=\"number\"]::-webkit-inner-spin-button,\n [type=\"number\"]::-webkit-outer-spin-button"] = {
  1566. height: 'auto'
  1567. }, _ref['[type="search"]'] = {
  1568. WebkitAppearance: 'textfield',
  1569. outlineOffset: '-2px'
  1570. }, _ref['[type="search"]::-webkit-search-decoration'] = {
  1571. WebkitAppearance: 'none'
  1572. }, _ref['::-webkit-file-upload-button'] = {
  1573. WebkitAppearance: 'button',
  1574. font: 'inherit'
  1575. }, _ref.details = {
  1576. display: 'block'
  1577. }, _ref.summary = {
  1578. display: 'list-item'
  1579. }, _ref.template = {
  1580. display: 'none'
  1581. }, _ref['[hidden]'] = {
  1582. display: 'none'
  1583. }, _ref), {
  1584. 'abbr[title]': {
  1585. textDecoration: 'underline dotted'
  1586. }
  1587. }];
  1588. }
  1589. var _templateObject;
  1590. /**
  1591. * CSS for declaring a radial gradient, including a fallback background-color. The fallback is either the first color-stop or an explicitly passed fallback color.
  1592. *
  1593. * @example
  1594. * // Styles as object usage
  1595. * const styles = {
  1596. * ...radialGradient({
  1597. * colorStops: ['#00FFFF 0%', 'rgba(0, 0, 255, 0) 50%', '#0000FF 95%'],
  1598. * extent: 'farthest-corner at 45px 45px',
  1599. * position: 'center',
  1600. * shape: 'ellipse',
  1601. * })
  1602. * }
  1603. *
  1604. * // styled-components usage
  1605. * const div = styled.div`
  1606. * ${radialGradient({
  1607. * colorStops: ['#00FFFF 0%', 'rgba(0, 0, 255, 0) 50%', '#0000FF 95%'],
  1608. * extent: 'farthest-corner at 45px 45px',
  1609. * position: 'center',
  1610. * shape: 'ellipse',
  1611. * })}
  1612. *`
  1613. *
  1614. * // CSS as JS Output
  1615. *
  1616. * div: {
  1617. * 'backgroundColor': '#00FFFF',
  1618. * 'backgroundImage': 'radial-gradient(center ellipse farthest-corner at 45px 45px, #00FFFF 0%, rgba(0, 0, 255, 0) 50%, #0000FF 95%)',
  1619. * }
  1620. */
  1621. function radialGradient(_ref) {
  1622. var colorStops = _ref.colorStops,
  1623. _ref$extent = _ref.extent,
  1624. extent = _ref$extent === void 0 ? '' : _ref$extent,
  1625. fallback = _ref.fallback,
  1626. _ref$position = _ref.position,
  1627. position = _ref$position === void 0 ? '' : _ref$position,
  1628. _ref$shape = _ref.shape,
  1629. shape = _ref$shape === void 0 ? '' : _ref$shape;
  1630. if (!colorStops || colorStops.length < 2) {
  1631. throw new PolishedError(57);
  1632. }
  1633. return {
  1634. backgroundColor: fallback || colorStops[0].split(' ')[0],
  1635. backgroundImage: constructGradientValue(_templateObject || (_templateObject = _taggedTemplateLiteralLoose__default["default"](["radial-gradient(", "", "", "", ")"])), position, shape, extent, colorStops.join(', '))
  1636. };
  1637. }
  1638. /**
  1639. * A helper to generate a retina background image and non-retina
  1640. * background image. The retina background image will output to a HiDPI media query. The mixin uses
  1641. * a _2x.png filename suffix by default.
  1642. *
  1643. * @example
  1644. * // Styles as object usage
  1645. * const styles = {
  1646. * ...retinaImage('my-img')
  1647. * }
  1648. *
  1649. * // styled-components usage
  1650. * const div = styled.div`
  1651. * ${retinaImage('my-img')}
  1652. * `
  1653. *
  1654. * // CSS as JS Output
  1655. * div {
  1656. * backgroundImage: 'url(my-img.png)',
  1657. * '@media only screen and (-webkit-min-device-pixel-ratio: 1.3),
  1658. * only screen and (min--moz-device-pixel-ratio: 1.3),
  1659. * only screen and (-o-min-device-pixel-ratio: 1.3/1),
  1660. * only screen and (min-resolution: 144dpi),
  1661. * only screen and (min-resolution: 1.5dppx)': {
  1662. * backgroundImage: 'url(my-img_2x.png)',
  1663. * }
  1664. * }
  1665. */
  1666. function retinaImage(filename, backgroundSize, extension, retinaFilename, retinaSuffix) {
  1667. var _ref;
  1668. if (extension === void 0) {
  1669. extension = 'png';
  1670. }
  1671. if (retinaSuffix === void 0) {
  1672. retinaSuffix = '_2x';
  1673. }
  1674. if (!filename) {
  1675. throw new PolishedError(58);
  1676. }
  1677. // Replace the dot at the beginning of the passed extension if one exists
  1678. var ext = extension.replace(/^\./, '');
  1679. var rFilename = retinaFilename ? retinaFilename + "." + ext : "" + filename + retinaSuffix + "." + ext;
  1680. return _ref = {
  1681. backgroundImage: "url(" + filename + "." + ext + ")"
  1682. }, _ref[hiDPI()] = _extends__default["default"]({
  1683. backgroundImage: "url(" + rFilename + ")"
  1684. }, backgroundSize ? {
  1685. backgroundSize: backgroundSize
  1686. } : {}), _ref;
  1687. }
  1688. /* eslint-disable key-spacing */
  1689. var functionsMap = {
  1690. easeInBack: 'cubic-bezier(0.600, -0.280, 0.735, 0.045)',
  1691. easeInCirc: 'cubic-bezier(0.600, 0.040, 0.980, 0.335)',
  1692. easeInCubic: 'cubic-bezier(0.550, 0.055, 0.675, 0.190)',
  1693. easeInExpo: 'cubic-bezier(0.950, 0.050, 0.795, 0.035)',
  1694. easeInQuad: 'cubic-bezier(0.550, 0.085, 0.680, 0.530)',
  1695. easeInQuart: 'cubic-bezier(0.895, 0.030, 0.685, 0.220)',
  1696. easeInQuint: 'cubic-bezier(0.755, 0.050, 0.855, 0.060)',
  1697. easeInSine: 'cubic-bezier(0.470, 0.000, 0.745, 0.715)',
  1698. easeOutBack: 'cubic-bezier(0.175, 0.885, 0.320, 1.275)',
  1699. easeOutCubic: 'cubic-bezier(0.215, 0.610, 0.355, 1.000)',
  1700. easeOutCirc: 'cubic-bezier(0.075, 0.820, 0.165, 1.000)',
  1701. easeOutExpo: 'cubic-bezier(0.190, 1.000, 0.220, 1.000)',
  1702. easeOutQuad: 'cubic-bezier(0.250, 0.460, 0.450, 0.940)',
  1703. easeOutQuart: 'cubic-bezier(0.165, 0.840, 0.440, 1.000)',
  1704. easeOutQuint: 'cubic-bezier(0.230, 1.000, 0.320, 1.000)',
  1705. easeOutSine: 'cubic-bezier(0.390, 0.575, 0.565, 1.000)',
  1706. easeInOutBack: 'cubic-bezier(0.680, -0.550, 0.265, 1.550)',
  1707. easeInOutCirc: 'cubic-bezier(0.785, 0.135, 0.150, 0.860)',
  1708. easeInOutCubic: 'cubic-bezier(0.645, 0.045, 0.355, 1.000)',
  1709. easeInOutExpo: 'cubic-bezier(1.000, 0.000, 0.000, 1.000)',
  1710. easeInOutQuad: 'cubic-bezier(0.455, 0.030, 0.515, 0.955)',
  1711. easeInOutQuart: 'cubic-bezier(0.770, 0.000, 0.175, 1.000)',
  1712. easeInOutQuint: 'cubic-bezier(0.860, 0.000, 0.070, 1.000)',
  1713. easeInOutSine: 'cubic-bezier(0.445, 0.050, 0.550, 0.950)'
  1714. };
  1715. /* eslint-enable key-spacing */
  1716. function getTimingFunction(functionName) {
  1717. return functionsMap[functionName];
  1718. }
  1719. /**
  1720. * String to represent common easing functions as demonstrated here: (github.com/jaukia/easie).
  1721. *
  1722. * @deprecated - This will be deprecated in v5 in favor of `easeIn`, `easeOut`, `easeInOut`.
  1723. *
  1724. * @example
  1725. * // Styles as object usage
  1726. * const styles = {
  1727. * 'transitionTimingFunction': timingFunctions('easeInQuad')
  1728. * }
  1729. *
  1730. * // styled-components usage
  1731. * const div = styled.div`
  1732. * transitionTimingFunction: ${timingFunctions('easeInQuad')};
  1733. * `
  1734. *
  1735. * // CSS as JS Output
  1736. *
  1737. * 'div': {
  1738. * 'transitionTimingFunction': 'cubic-bezier(0.550, 0.085, 0.680, 0.530)',
  1739. * }
  1740. */
  1741. function timingFunctions(timingFunction) {
  1742. return getTimingFunction(timingFunction);
  1743. }
  1744. var getBorderWidth = function getBorderWidth(pointingDirection, height, width) {
  1745. var fullWidth = "" + width[0] + (width[1] || '');
  1746. var halfWidth = "" + width[0] / 2 + (width[1] || '');
  1747. var fullHeight = "" + height[0] + (height[1] || '');
  1748. var halfHeight = "" + height[0] / 2 + (height[1] || '');
  1749. switch (pointingDirection) {
  1750. case 'top':
  1751. return "0 " + halfWidth + " " + fullHeight + " " + halfWidth;
  1752. case 'topLeft':
  1753. return fullWidth + " " + fullHeight + " 0 0";
  1754. case 'left':
  1755. return halfHeight + " " + fullWidth + " " + halfHeight + " 0";
  1756. case 'bottomLeft':
  1757. return fullWidth + " 0 0 " + fullHeight;
  1758. case 'bottom':
  1759. return fullHeight + " " + halfWidth + " 0 " + halfWidth;
  1760. case 'bottomRight':
  1761. return "0 0 " + fullWidth + " " + fullHeight;
  1762. case 'right':
  1763. return halfHeight + " 0 " + halfHeight + " " + fullWidth;
  1764. case 'topRight':
  1765. default:
  1766. return "0 " + fullWidth + " " + fullHeight + " 0";
  1767. }
  1768. };
  1769. var getBorderColor = function getBorderColor(pointingDirection, foregroundColor) {
  1770. switch (pointingDirection) {
  1771. case 'top':
  1772. case 'bottomRight':
  1773. return {
  1774. borderBottomColor: foregroundColor
  1775. };
  1776. case 'right':
  1777. case 'bottomLeft':
  1778. return {
  1779. borderLeftColor: foregroundColor
  1780. };
  1781. case 'bottom':
  1782. case 'topLeft':
  1783. return {
  1784. borderTopColor: foregroundColor
  1785. };
  1786. case 'left':
  1787. case 'topRight':
  1788. return {
  1789. borderRightColor: foregroundColor
  1790. };
  1791. default:
  1792. throw new PolishedError(59);
  1793. }
  1794. };
  1795. /**
  1796. * CSS to represent triangle with any pointing direction with an optional background color.
  1797. *
  1798. * @example
  1799. * // Styles as object usage
  1800. *
  1801. * const styles = {
  1802. * ...triangle({ pointingDirection: 'right', width: '100px', height: '100px', foregroundColor: 'red' })
  1803. * }
  1804. *
  1805. *
  1806. * // styled-components usage
  1807. * const div = styled.div`
  1808. * ${triangle({ pointingDirection: 'right', width: '100px', height: '100px', foregroundColor: 'red' })}
  1809. *
  1810. *
  1811. * // CSS as JS Output
  1812. *
  1813. * div: {
  1814. * 'borderColor': 'transparent transparent transparent red',
  1815. * 'borderStyle': 'solid',
  1816. * 'borderWidth': '50px 0 50px 100px',
  1817. * 'height': '0',
  1818. * 'width': '0',
  1819. * }
  1820. */
  1821. function triangle(_ref) {
  1822. var pointingDirection = _ref.pointingDirection,
  1823. height = _ref.height,
  1824. width = _ref.width,
  1825. foregroundColor = _ref.foregroundColor,
  1826. _ref$backgroundColor = _ref.backgroundColor,
  1827. backgroundColor = _ref$backgroundColor === void 0 ? 'transparent' : _ref$backgroundColor;
  1828. var widthAndUnit = getValueAndUnit(width);
  1829. var heightAndUnit = getValueAndUnit(height);
  1830. if (isNaN(heightAndUnit[0]) || isNaN(widthAndUnit[0])) {
  1831. throw new PolishedError(60);
  1832. }
  1833. return _extends__default["default"]({
  1834. width: '0',
  1835. height: '0',
  1836. borderColor: backgroundColor
  1837. }, getBorderColor(pointingDirection, foregroundColor), {
  1838. borderStyle: 'solid',
  1839. borderWidth: getBorderWidth(pointingDirection, heightAndUnit, widthAndUnit)
  1840. });
  1841. }
  1842. /**
  1843. * Provides an easy way to change the `wordWrap` property.
  1844. *
  1845. * @example
  1846. * // Styles as object usage
  1847. * const styles = {
  1848. * ...wordWrap('break-word')
  1849. * }
  1850. *
  1851. * // styled-components usage
  1852. * const div = styled.div`
  1853. * ${wordWrap('break-word')}
  1854. * `
  1855. *
  1856. * // CSS as JS Output
  1857. *
  1858. * const styles = {
  1859. * overflowWrap: 'break-word',
  1860. * wordWrap: 'break-word',
  1861. * wordBreak: 'break-all',
  1862. * }
  1863. */
  1864. function wordWrap(wrap) {
  1865. if (wrap === void 0) {
  1866. wrap = 'break-word';
  1867. }
  1868. var wordBreak = wrap === 'break-word' ? 'break-all' : wrap;
  1869. return {
  1870. overflowWrap: wrap,
  1871. wordWrap: wrap,
  1872. wordBreak: wordBreak
  1873. };
  1874. }
  1875. function colorToInt(color) {
  1876. return Math.round(color * 255);
  1877. }
  1878. function convertToInt(red, green, blue) {
  1879. return colorToInt(red) + "," + colorToInt(green) + "," + colorToInt(blue);
  1880. }
  1881. function hslToRgb(hue, saturation, lightness, convert) {
  1882. if (convert === void 0) {
  1883. convert = convertToInt;
  1884. }
  1885. if (saturation === 0) {
  1886. // achromatic
  1887. return convert(lightness, lightness, lightness);
  1888. }
  1889. // formulae from https://en.wikipedia.org/wiki/HSL_and_HSV
  1890. var huePrime = (hue % 360 + 360) % 360 / 60;
  1891. var chroma = (1 - Math.abs(2 * lightness - 1)) * saturation;
  1892. var secondComponent = chroma * (1 - Math.abs(huePrime % 2 - 1));
  1893. var red = 0;
  1894. var green = 0;
  1895. var blue = 0;
  1896. if (huePrime >= 0 && huePrime < 1) {
  1897. red = chroma;
  1898. green = secondComponent;
  1899. } else if (huePrime >= 1 && huePrime < 2) {
  1900. red = secondComponent;
  1901. green = chroma;
  1902. } else if (huePrime >= 2 && huePrime < 3) {
  1903. green = chroma;
  1904. blue = secondComponent;
  1905. } else if (huePrime >= 3 && huePrime < 4) {
  1906. green = secondComponent;
  1907. blue = chroma;
  1908. } else if (huePrime >= 4 && huePrime < 5) {
  1909. red = secondComponent;
  1910. blue = chroma;
  1911. } else if (huePrime >= 5 && huePrime < 6) {
  1912. red = chroma;
  1913. blue = secondComponent;
  1914. }
  1915. var lightnessModification = lightness - chroma / 2;
  1916. var finalRed = red + lightnessModification;
  1917. var finalGreen = green + lightnessModification;
  1918. var finalBlue = blue + lightnessModification;
  1919. return convert(finalRed, finalGreen, finalBlue);
  1920. }
  1921. var namedColorMap = {
  1922. aliceblue: 'f0f8ff',
  1923. antiquewhite: 'faebd7',
  1924. aqua: '00ffff',
  1925. aquamarine: '7fffd4',
  1926. azure: 'f0ffff',
  1927. beige: 'f5f5dc',
  1928. bisque: 'ffe4c4',
  1929. black: '000',
  1930. blanchedalmond: 'ffebcd',
  1931. blue: '0000ff',
  1932. blueviolet: '8a2be2',
  1933. brown: 'a52a2a',
  1934. burlywood: 'deb887',
  1935. cadetblue: '5f9ea0',
  1936. chartreuse: '7fff00',
  1937. chocolate: 'd2691e',
  1938. coral: 'ff7f50',
  1939. cornflowerblue: '6495ed',
  1940. cornsilk: 'fff8dc',
  1941. crimson: 'dc143c',
  1942. cyan: '00ffff',
  1943. darkblue: '00008b',
  1944. darkcyan: '008b8b',
  1945. darkgoldenrod: 'b8860b',
  1946. darkgray: 'a9a9a9',
  1947. darkgreen: '006400',
  1948. darkgrey: 'a9a9a9',
  1949. darkkhaki: 'bdb76b',
  1950. darkmagenta: '8b008b',
  1951. darkolivegreen: '556b2f',
  1952. darkorange: 'ff8c00',
  1953. darkorchid: '9932cc',
  1954. darkred: '8b0000',
  1955. darksalmon: 'e9967a',
  1956. darkseagreen: '8fbc8f',
  1957. darkslateblue: '483d8b',
  1958. darkslategray: '2f4f4f',
  1959. darkslategrey: '2f4f4f',
  1960. darkturquoise: '00ced1',
  1961. darkviolet: '9400d3',
  1962. deeppink: 'ff1493',
  1963. deepskyblue: '00bfff',
  1964. dimgray: '696969',
  1965. dimgrey: '696969',
  1966. dodgerblue: '1e90ff',
  1967. firebrick: 'b22222',
  1968. floralwhite: 'fffaf0',
  1969. forestgreen: '228b22',
  1970. fuchsia: 'ff00ff',
  1971. gainsboro: 'dcdcdc',
  1972. ghostwhite: 'f8f8ff',
  1973. gold: 'ffd700',
  1974. goldenrod: 'daa520',
  1975. gray: '808080',
  1976. green: '008000',
  1977. greenyellow: 'adff2f',
  1978. grey: '808080',
  1979. honeydew: 'f0fff0',
  1980. hotpink: 'ff69b4',
  1981. indianred: 'cd5c5c',
  1982. indigo: '4b0082',
  1983. ivory: 'fffff0',
  1984. khaki: 'f0e68c',
  1985. lavender: 'e6e6fa',
  1986. lavenderblush: 'fff0f5',
  1987. lawngreen: '7cfc00',
  1988. lemonchiffon: 'fffacd',
  1989. lightblue: 'add8e6',
  1990. lightcoral: 'f08080',
  1991. lightcyan: 'e0ffff',
  1992. lightgoldenrodyellow: 'fafad2',
  1993. lightgray: 'd3d3d3',
  1994. lightgreen: '90ee90',
  1995. lightgrey: 'd3d3d3',
  1996. lightpink: 'ffb6c1',
  1997. lightsalmon: 'ffa07a',
  1998. lightseagreen: '20b2aa',
  1999. lightskyblue: '87cefa',
  2000. lightslategray: '789',
  2001. lightslategrey: '789',
  2002. lightsteelblue: 'b0c4de',
  2003. lightyellow: 'ffffe0',
  2004. lime: '0f0',
  2005. limegreen: '32cd32',
  2006. linen: 'faf0e6',
  2007. magenta: 'f0f',
  2008. maroon: '800000',
  2009. mediumaquamarine: '66cdaa',
  2010. mediumblue: '0000cd',
  2011. mediumorchid: 'ba55d3',
  2012. mediumpurple: '9370db',
  2013. mediumseagreen: '3cb371',
  2014. mediumslateblue: '7b68ee',
  2015. mediumspringgreen: '00fa9a',
  2016. mediumturquoise: '48d1cc',
  2017. mediumvioletred: 'c71585',
  2018. midnightblue: '191970',
  2019. mintcream: 'f5fffa',
  2020. mistyrose: 'ffe4e1',
  2021. moccasin: 'ffe4b5',
  2022. navajowhite: 'ffdead',
  2023. navy: '000080',
  2024. oldlace: 'fdf5e6',
  2025. olive: '808000',
  2026. olivedrab: '6b8e23',
  2027. orange: 'ffa500',
  2028. orangered: 'ff4500',
  2029. orchid: 'da70d6',
  2030. palegoldenrod: 'eee8aa',
  2031. palegreen: '98fb98',
  2032. paleturquoise: 'afeeee',
  2033. palevioletred: 'db7093',
  2034. papayawhip: 'ffefd5',
  2035. peachpuff: 'ffdab9',
  2036. peru: 'cd853f',
  2037. pink: 'ffc0cb',
  2038. plum: 'dda0dd',
  2039. powderblue: 'b0e0e6',
  2040. purple: '800080',
  2041. rebeccapurple: '639',
  2042. red: 'f00',
  2043. rosybrown: 'bc8f8f',
  2044. royalblue: '4169e1',
  2045. saddlebrown: '8b4513',
  2046. salmon: 'fa8072',
  2047. sandybrown: 'f4a460',
  2048. seagreen: '2e8b57',
  2049. seashell: 'fff5ee',
  2050. sienna: 'a0522d',
  2051. silver: 'c0c0c0',
  2052. skyblue: '87ceeb',
  2053. slateblue: '6a5acd',
  2054. slategray: '708090',
  2055. slategrey: '708090',
  2056. snow: 'fffafa',
  2057. springgreen: '00ff7f',
  2058. steelblue: '4682b4',
  2059. tan: 'd2b48c',
  2060. teal: '008080',
  2061. thistle: 'd8bfd8',
  2062. tomato: 'ff6347',
  2063. turquoise: '40e0d0',
  2064. violet: 'ee82ee',
  2065. wheat: 'f5deb3',
  2066. white: 'fff',
  2067. whitesmoke: 'f5f5f5',
  2068. yellow: 'ff0',
  2069. yellowgreen: '9acd32'
  2070. };
  2071. /**
  2072. * Checks if a string is a CSS named color and returns its equivalent hex value, otherwise returns the original color.
  2073. * @private
  2074. */
  2075. function nameToHex(color) {
  2076. if (typeof color !== 'string') return color;
  2077. var normalizedColorName = color.toLowerCase();
  2078. return namedColorMap[normalizedColorName] ? "#" + namedColorMap[normalizedColorName] : color;
  2079. }
  2080. var hexRegex = /^#[a-fA-F0-9]{6}$/;
  2081. var hexRgbaRegex = /^#[a-fA-F0-9]{8}$/;
  2082. var reducedHexRegex = /^#[a-fA-F0-9]{3}$/;
  2083. var reducedRgbaHexRegex = /^#[a-fA-F0-9]{4}$/;
  2084. var rgbRegex = /^rgb\(\s*(\d{1,3})\s*(?:,)?\s*(\d{1,3})\s*(?:,)?\s*(\d{1,3})\s*\)$/i;
  2085. var rgbaRegex = /^rgb(?:a)?\(\s*(\d{1,3})\s*(?:,)?\s*(\d{1,3})\s*(?:,)?\s*(\d{1,3})\s*(?:,|\/)\s*([-+]?\d*[.]?\d+[%]?)\s*\)$/i;
  2086. var hslRegex = /^hsl\(\s*(\d{0,3}[.]?[0-9]+(?:deg)?)\s*(?:,)?\s*(\d{1,3}[.]?[0-9]?)%\s*(?:,)?\s*(\d{1,3}[.]?[0-9]?)%\s*\)$/i;
  2087. var hslaRegex = /^hsl(?:a)?\(\s*(\d{0,3}[.]?[0-9]+(?:deg)?)\s*(?:,)?\s*(\d{1,3}[.]?[0-9]?)%\s*(?:,)?\s*(\d{1,3}[.]?[0-9]?)%\s*(?:,|\/)\s*([-+]?\d*[.]?\d+[%]?)\s*\)$/i;
  2088. /**
  2089. * Returns an RgbColor or RgbaColor object. This utility function is only useful
  2090. * if want to extract a color component. With the color util `toColorString` you
  2091. * can convert a RgbColor or RgbaColor object back to a string.
  2092. *
  2093. * @example
  2094. * // Assigns `{ red: 255, green: 0, blue: 0 }` to color1
  2095. * const color1 = parseToRgb('rgb(255, 0, 0)');
  2096. * // Assigns `{ red: 92, green: 102, blue: 112, alpha: 0.75 }` to color2
  2097. * const color2 = parseToRgb('hsla(210, 10%, 40%, 0.75)');
  2098. */
  2099. function parseToRgb(color) {
  2100. if (typeof color !== 'string') {
  2101. throw new PolishedError(3);
  2102. }
  2103. var normalizedColor = nameToHex(color);
  2104. if (normalizedColor.match(hexRegex)) {
  2105. return {
  2106. red: parseInt("" + normalizedColor[1] + normalizedColor[2], 16),
  2107. green: parseInt("" + normalizedColor[3] + normalizedColor[4], 16),
  2108. blue: parseInt("" + normalizedColor[5] + normalizedColor[6], 16)
  2109. };
  2110. }
  2111. if (normalizedColor.match(hexRgbaRegex)) {
  2112. var alpha = parseFloat((parseInt("" + normalizedColor[7] + normalizedColor[8], 16) / 255).toFixed(2));
  2113. return {
  2114. red: parseInt("" + normalizedColor[1] + normalizedColor[2], 16),
  2115. green: parseInt("" + normalizedColor[3] + normalizedColor[4], 16),
  2116. blue: parseInt("" + normalizedColor[5] + normalizedColor[6], 16),
  2117. alpha: alpha
  2118. };
  2119. }
  2120. if (normalizedColor.match(reducedHexRegex)) {
  2121. return {
  2122. red: parseInt("" + normalizedColor[1] + normalizedColor[1], 16),
  2123. green: parseInt("" + normalizedColor[2] + normalizedColor[2], 16),
  2124. blue: parseInt("" + normalizedColor[3] + normalizedColor[3], 16)
  2125. };
  2126. }
  2127. if (normalizedColor.match(reducedRgbaHexRegex)) {
  2128. var _alpha = parseFloat((parseInt("" + normalizedColor[4] + normalizedColor[4], 16) / 255).toFixed(2));
  2129. return {
  2130. red: parseInt("" + normalizedColor[1] + normalizedColor[1], 16),
  2131. green: parseInt("" + normalizedColor[2] + normalizedColor[2], 16),
  2132. blue: parseInt("" + normalizedColor[3] + normalizedColor[3], 16),
  2133. alpha: _alpha
  2134. };
  2135. }
  2136. var rgbMatched = rgbRegex.exec(normalizedColor);
  2137. if (rgbMatched) {
  2138. return {
  2139. red: parseInt("" + rgbMatched[1], 10),
  2140. green: parseInt("" + rgbMatched[2], 10),
  2141. blue: parseInt("" + rgbMatched[3], 10)
  2142. };
  2143. }
  2144. var rgbaMatched = rgbaRegex.exec(normalizedColor.substring(0, 50));
  2145. if (rgbaMatched) {
  2146. return {
  2147. red: parseInt("" + rgbaMatched[1], 10),
  2148. green: parseInt("" + rgbaMatched[2], 10),
  2149. blue: parseInt("" + rgbaMatched[3], 10),
  2150. alpha: parseFloat("" + rgbaMatched[4]) > 1 ? parseFloat("" + rgbaMatched[4]) / 100 : parseFloat("" + rgbaMatched[4])
  2151. };
  2152. }
  2153. var hslMatched = hslRegex.exec(normalizedColor);
  2154. if (hslMatched) {
  2155. var hue = parseInt("" + hslMatched[1], 10);
  2156. var saturation = parseInt("" + hslMatched[2], 10) / 100;
  2157. var lightness = parseInt("" + hslMatched[3], 10) / 100;
  2158. var rgbColorString = "rgb(" + hslToRgb(hue, saturation, lightness) + ")";
  2159. var hslRgbMatched = rgbRegex.exec(rgbColorString);
  2160. if (!hslRgbMatched) {
  2161. throw new PolishedError(4, normalizedColor, rgbColorString);
  2162. }
  2163. return {
  2164. red: parseInt("" + hslRgbMatched[1], 10),
  2165. green: parseInt("" + hslRgbMatched[2], 10),
  2166. blue: parseInt("" + hslRgbMatched[3], 10)
  2167. };
  2168. }
  2169. var hslaMatched = hslaRegex.exec(normalizedColor.substring(0, 50));
  2170. if (hslaMatched) {
  2171. var _hue = parseInt("" + hslaMatched[1], 10);
  2172. var _saturation = parseInt("" + hslaMatched[2], 10) / 100;
  2173. var _lightness = parseInt("" + hslaMatched[3], 10) / 100;
  2174. var _rgbColorString = "rgb(" + hslToRgb(_hue, _saturation, _lightness) + ")";
  2175. var _hslRgbMatched = rgbRegex.exec(_rgbColorString);
  2176. if (!_hslRgbMatched) {
  2177. throw new PolishedError(4, normalizedColor, _rgbColorString);
  2178. }
  2179. return {
  2180. red: parseInt("" + _hslRgbMatched[1], 10),
  2181. green: parseInt("" + _hslRgbMatched[2], 10),
  2182. blue: parseInt("" + _hslRgbMatched[3], 10),
  2183. alpha: parseFloat("" + hslaMatched[4]) > 1 ? parseFloat("" + hslaMatched[4]) / 100 : parseFloat("" + hslaMatched[4])
  2184. };
  2185. }
  2186. throw new PolishedError(5);
  2187. }
  2188. function rgbToHsl(color) {
  2189. // make sure rgb are contained in a set of [0, 255]
  2190. var red = color.red / 255;
  2191. var green = color.green / 255;
  2192. var blue = color.blue / 255;
  2193. var max = Math.max(red, green, blue);
  2194. var min = Math.min(red, green, blue);
  2195. var lightness = (max + min) / 2;
  2196. if (max === min) {
  2197. // achromatic
  2198. if (color.alpha !== undefined) {
  2199. return {
  2200. hue: 0,
  2201. saturation: 0,
  2202. lightness: lightness,
  2203. alpha: color.alpha
  2204. };
  2205. } else {
  2206. return {
  2207. hue: 0,
  2208. saturation: 0,
  2209. lightness: lightness
  2210. };
  2211. }
  2212. }
  2213. var hue;
  2214. var delta = max - min;
  2215. var saturation = lightness > 0.5 ? delta / (2 - max - min) : delta / (max + min);
  2216. switch (max) {
  2217. case red:
  2218. hue = (green - blue) / delta + (green < blue ? 6 : 0);
  2219. break;
  2220. case green:
  2221. hue = (blue - red) / delta + 2;
  2222. break;
  2223. default:
  2224. // blue case
  2225. hue = (red - green) / delta + 4;
  2226. break;
  2227. }
  2228. hue *= 60;
  2229. if (color.alpha !== undefined) {
  2230. return {
  2231. hue: hue,
  2232. saturation: saturation,
  2233. lightness: lightness,
  2234. alpha: color.alpha
  2235. };
  2236. }
  2237. return {
  2238. hue: hue,
  2239. saturation: saturation,
  2240. lightness: lightness
  2241. };
  2242. }
  2243. /**
  2244. * Returns an HslColor or HslaColor object. This utility function is only useful
  2245. * if want to extract a color component. With the color util `toColorString` you
  2246. * can convert a HslColor or HslaColor object back to a string.
  2247. *
  2248. * @example
  2249. * // Assigns `{ hue: 0, saturation: 1, lightness: 0.5 }` to color1
  2250. * const color1 = parseToHsl('rgb(255, 0, 0)');
  2251. * // Assigns `{ hue: 128, saturation: 1, lightness: 0.5, alpha: 0.75 }` to color2
  2252. * const color2 = parseToHsl('hsla(128, 100%, 50%, 0.75)');
  2253. */
  2254. function parseToHsl(color) {
  2255. // Note: At a later stage we can optimize this function as right now a hsl
  2256. // color would be parsed converted to rgb values and converted back to hsl.
  2257. return rgbToHsl(parseToRgb(color));
  2258. }
  2259. /**
  2260. * Reduces hex values if possible e.g. #ff8866 to #f86
  2261. * @private
  2262. */
  2263. var reduceHexValue = function reduceHexValue(value) {
  2264. if (value.length === 7 && value[1] === value[2] && value[3] === value[4] && value[5] === value[6]) {
  2265. return "#" + value[1] + value[3] + value[5];
  2266. }
  2267. return value;
  2268. };
  2269. var reduceHexValue$1 = reduceHexValue;
  2270. function numberToHex(value) {
  2271. var hex = value.toString(16);
  2272. return hex.length === 1 ? "0" + hex : hex;
  2273. }
  2274. function colorToHex(color) {
  2275. return numberToHex(Math.round(color * 255));
  2276. }
  2277. function convertToHex(red, green, blue) {
  2278. return reduceHexValue$1("#" + colorToHex(red) + colorToHex(green) + colorToHex(blue));
  2279. }
  2280. function hslToHex(hue, saturation, lightness) {
  2281. return hslToRgb(hue, saturation, lightness, convertToHex);
  2282. }
  2283. /**
  2284. * Returns a string value for the color. The returned result is the smallest possible hex notation.
  2285. *
  2286. * @example
  2287. * // Styles as object usage
  2288. * const styles = {
  2289. * background: hsl(359, 0.75, 0.4),
  2290. * background: hsl({ hue: 360, saturation: 0.75, lightness: 0.4 }),
  2291. * }
  2292. *
  2293. * // styled-components usage
  2294. * const div = styled.div`
  2295. * background: ${hsl(359, 0.75, 0.4)};
  2296. * background: ${hsl({ hue: 360, saturation: 0.75, lightness: 0.4 })};
  2297. * `
  2298. *
  2299. * // CSS in JS Output
  2300. *
  2301. * element {
  2302. * background: "#b3191c";
  2303. * background: "#b3191c";
  2304. * }
  2305. */
  2306. function hsl(value, saturation, lightness) {
  2307. if (typeof value === 'number' && typeof saturation === 'number' && typeof lightness === 'number') {
  2308. return hslToHex(value, saturation, lightness);
  2309. } else if (typeof value === 'object' && saturation === undefined && lightness === undefined) {
  2310. return hslToHex(value.hue, value.saturation, value.lightness);
  2311. }
  2312. throw new PolishedError(1);
  2313. }
  2314. /**
  2315. * Returns a string value for the color. The returned result is the smallest possible rgba or hex notation.
  2316. *
  2317. * @example
  2318. * // Styles as object usage
  2319. * const styles = {
  2320. * background: hsla(359, 0.75, 0.4, 0.7),
  2321. * background: hsla({ hue: 360, saturation: 0.75, lightness: 0.4, alpha: 0,7 }),
  2322. * background: hsla(359, 0.75, 0.4, 1),
  2323. * }
  2324. *
  2325. * // styled-components usage
  2326. * const div = styled.div`
  2327. * background: ${hsla(359, 0.75, 0.4, 0.7)};
  2328. * background: ${hsla({ hue: 360, saturation: 0.75, lightness: 0.4, alpha: 0,7 })};
  2329. * background: ${hsla(359, 0.75, 0.4, 1)};
  2330. * `
  2331. *
  2332. * // CSS in JS Output
  2333. *
  2334. * element {
  2335. * background: "rgba(179,25,28,0.7)";
  2336. * background: "rgba(179,25,28,0.7)";
  2337. * background: "#b3191c";
  2338. * }
  2339. */
  2340. function hsla(value, saturation, lightness, alpha) {
  2341. if (typeof value === 'number' && typeof saturation === 'number' && typeof lightness === 'number' && typeof alpha === 'number') {
  2342. return alpha >= 1 ? hslToHex(value, saturation, lightness) : "rgba(" + hslToRgb(value, saturation, lightness) + "," + alpha + ")";
  2343. } else if (typeof value === 'object' && saturation === undefined && lightness === undefined && alpha === undefined) {
  2344. return value.alpha >= 1 ? hslToHex(value.hue, value.saturation, value.lightness) : "rgba(" + hslToRgb(value.hue, value.saturation, value.lightness) + "," + value.alpha + ")";
  2345. }
  2346. throw new PolishedError(2);
  2347. }
  2348. /**
  2349. * Returns a string value for the color. The returned result is the smallest possible hex notation.
  2350. *
  2351. * @example
  2352. * // Styles as object usage
  2353. * const styles = {
  2354. * background: rgb(255, 205, 100),
  2355. * background: rgb({ red: 255, green: 205, blue: 100 }),
  2356. * }
  2357. *
  2358. * // styled-components usage
  2359. * const div = styled.div`
  2360. * background: ${rgb(255, 205, 100)};
  2361. * background: ${rgb({ red: 255, green: 205, blue: 100 })};
  2362. * `
  2363. *
  2364. * // CSS in JS Output
  2365. *
  2366. * element {
  2367. * background: "#ffcd64";
  2368. * background: "#ffcd64";
  2369. * }
  2370. */
  2371. function rgb(value, green, blue) {
  2372. if (typeof value === 'number' && typeof green === 'number' && typeof blue === 'number') {
  2373. return reduceHexValue$1("#" + numberToHex(value) + numberToHex(green) + numberToHex(blue));
  2374. } else if (typeof value === 'object' && green === undefined && blue === undefined) {
  2375. return reduceHexValue$1("#" + numberToHex(value.red) + numberToHex(value.green) + numberToHex(value.blue));
  2376. }
  2377. throw new PolishedError(6);
  2378. }
  2379. /**
  2380. * Returns a string value for the color. The returned result is the smallest possible rgba or hex notation.
  2381. *
  2382. * Can also be used to fade a color by passing a hex value or named CSS color along with an alpha value.
  2383. *
  2384. * @example
  2385. * // Styles as object usage
  2386. * const styles = {
  2387. * background: rgba(255, 205, 100, 0.7),
  2388. * background: rgba({ red: 255, green: 205, blue: 100, alpha: 0.7 }),
  2389. * background: rgba(255, 205, 100, 1),
  2390. * background: rgba('#ffffff', 0.4),
  2391. * background: rgba('black', 0.7),
  2392. * }
  2393. *
  2394. * // styled-components usage
  2395. * const div = styled.div`
  2396. * background: ${rgba(255, 205, 100, 0.7)};
  2397. * background: ${rgba({ red: 255, green: 205, blue: 100, alpha: 0.7 })};
  2398. * background: ${rgba(255, 205, 100, 1)};
  2399. * background: ${rgba('#ffffff', 0.4)};
  2400. * background: ${rgba('black', 0.7)};
  2401. * `
  2402. *
  2403. * // CSS in JS Output
  2404. *
  2405. * element {
  2406. * background: "rgba(255,205,100,0.7)";
  2407. * background: "rgba(255,205,100,0.7)";
  2408. * background: "#ffcd64";
  2409. * background: "rgba(255,255,255,0.4)";
  2410. * background: "rgba(0,0,0,0.7)";
  2411. * }
  2412. */
  2413. function rgba(firstValue, secondValue, thirdValue, fourthValue) {
  2414. if (typeof firstValue === 'string' && typeof secondValue === 'number') {
  2415. var rgbValue = parseToRgb(firstValue);
  2416. return "rgba(" + rgbValue.red + "," + rgbValue.green + "," + rgbValue.blue + "," + secondValue + ")";
  2417. } else if (typeof firstValue === 'number' && typeof secondValue === 'number' && typeof thirdValue === 'number' && typeof fourthValue === 'number') {
  2418. return fourthValue >= 1 ? rgb(firstValue, secondValue, thirdValue) : "rgba(" + firstValue + "," + secondValue + "," + thirdValue + "," + fourthValue + ")";
  2419. } else if (typeof firstValue === 'object' && secondValue === undefined && thirdValue === undefined && fourthValue === undefined) {
  2420. return firstValue.alpha >= 1 ? rgb(firstValue.red, firstValue.green, firstValue.blue) : "rgba(" + firstValue.red + "," + firstValue.green + "," + firstValue.blue + "," + firstValue.alpha + ")";
  2421. }
  2422. throw new PolishedError(7);
  2423. }
  2424. var isRgb = function isRgb(color) {
  2425. return typeof color.red === 'number' && typeof color.green === 'number' && typeof color.blue === 'number' && (typeof color.alpha !== 'number' || typeof color.alpha === 'undefined');
  2426. };
  2427. var isRgba = function isRgba(color) {
  2428. return typeof color.red === 'number' && typeof color.green === 'number' && typeof color.blue === 'number' && typeof color.alpha === 'number';
  2429. };
  2430. var isHsl = function isHsl(color) {
  2431. return typeof color.hue === 'number' && typeof color.saturation === 'number' && typeof color.lightness === 'number' && (typeof color.alpha !== 'number' || typeof color.alpha === 'undefined');
  2432. };
  2433. var isHsla = function isHsla(color) {
  2434. return typeof color.hue === 'number' && typeof color.saturation === 'number' && typeof color.lightness === 'number' && typeof color.alpha === 'number';
  2435. };
  2436. /**
  2437. * Converts a RgbColor, RgbaColor, HslColor or HslaColor object to a color string.
  2438. * This util is useful in case you only know on runtime which color object is
  2439. * used. Otherwise we recommend to rely on `rgb`, `rgba`, `hsl` or `hsla`.
  2440. *
  2441. * @example
  2442. * // Styles as object usage
  2443. * const styles = {
  2444. * background: toColorString({ red: 255, green: 205, blue: 100 }),
  2445. * background: toColorString({ red: 255, green: 205, blue: 100, alpha: 0.72 }),
  2446. * background: toColorString({ hue: 240, saturation: 1, lightness: 0.5 }),
  2447. * background: toColorString({ hue: 360, saturation: 0.75, lightness: 0.4, alpha: 0.72 }),
  2448. * }
  2449. *
  2450. * // styled-components usage
  2451. * const div = styled.div`
  2452. * background: ${toColorString({ red: 255, green: 205, blue: 100 })};
  2453. * background: ${toColorString({ red: 255, green: 205, blue: 100, alpha: 0.72 })};
  2454. * background: ${toColorString({ hue: 240, saturation: 1, lightness: 0.5 })};
  2455. * background: ${toColorString({ hue: 360, saturation: 0.75, lightness: 0.4, alpha: 0.72 })};
  2456. * `
  2457. *
  2458. * // CSS in JS Output
  2459. * element {
  2460. * background: "#ffcd64";
  2461. * background: "rgba(255,205,100,0.72)";
  2462. * background: "#00f";
  2463. * background: "rgba(179,25,25,0.72)";
  2464. * }
  2465. */
  2466. function toColorString(color) {
  2467. if (typeof color !== 'object') throw new PolishedError(8);
  2468. if (isRgba(color)) return rgba(color);
  2469. if (isRgb(color)) return rgb(color);
  2470. if (isHsla(color)) return hsla(color);
  2471. if (isHsl(color)) return hsl(color);
  2472. throw new PolishedError(8);
  2473. }
  2474. // Type definitions taken from https://github.com/gcanti/flow-static-land/blob/master/src/Fun.js
  2475. // eslint-disable-next-line no-unused-vars
  2476. // eslint-disable-next-line no-unused-vars
  2477. // eslint-disable-next-line no-redeclare
  2478. function curried(f, length, acc) {
  2479. return function fn() {
  2480. // eslint-disable-next-line prefer-rest-params
  2481. var combined = acc.concat(Array.prototype.slice.call(arguments));
  2482. return combined.length >= length ? f.apply(this, combined) : curried(f, length, combined);
  2483. };
  2484. }
  2485. // eslint-disable-next-line no-redeclare
  2486. function curry(f) {
  2487. // eslint-disable-line no-redeclare
  2488. return curried(f, f.length, []);
  2489. }
  2490. /**
  2491. * Changes the hue of the color. Hue is a number between 0 to 360. The first
  2492. * argument for adjustHue is the amount of degrees the color is rotated around
  2493. * the color wheel, always producing a positive hue value.
  2494. *
  2495. * @example
  2496. * // Styles as object usage
  2497. * const styles = {
  2498. * background: adjustHue(180, '#448'),
  2499. * background: adjustHue('180', 'rgba(101,100,205,0.7)'),
  2500. * }
  2501. *
  2502. * // styled-components usage
  2503. * const div = styled.div`
  2504. * background: ${adjustHue(180, '#448')};
  2505. * background: ${adjustHue('180', 'rgba(101,100,205,0.7)')};
  2506. * `
  2507. *
  2508. * // CSS in JS Output
  2509. * element {
  2510. * background: "#888844";
  2511. * background: "rgba(136,136,68,0.7)";
  2512. * }
  2513. */
  2514. function adjustHue(degree, color) {
  2515. if (color === 'transparent') return color;
  2516. var hslColor = parseToHsl(color);
  2517. return toColorString(_extends__default["default"]({}, hslColor, {
  2518. hue: hslColor.hue + parseFloat(degree)
  2519. }));
  2520. }
  2521. // prettier-ignore
  2522. var curriedAdjustHue = curry /* ::<number | string, string, string> */(adjustHue);
  2523. var curriedAdjustHue$1 = curriedAdjustHue;
  2524. /**
  2525. * Returns the complement of the provided color. This is identical to adjustHue(180, <color>).
  2526. *
  2527. * @example
  2528. * // Styles as object usage
  2529. * const styles = {
  2530. * background: complement('#448'),
  2531. * background: complement('rgba(204,205,100,0.7)'),
  2532. * }
  2533. *
  2534. * // styled-components usage
  2535. * const div = styled.div`
  2536. * background: ${complement('#448')};
  2537. * background: ${complement('rgba(204,205,100,0.7)')};
  2538. * `
  2539. *
  2540. * // CSS in JS Output
  2541. * element {
  2542. * background: "#884";
  2543. * background: "rgba(153,153,153,0.7)";
  2544. * }
  2545. */
  2546. function complement(color) {
  2547. if (color === 'transparent') return color;
  2548. var hslColor = parseToHsl(color);
  2549. return toColorString(_extends__default["default"]({}, hslColor, {
  2550. hue: (hslColor.hue + 180) % 360
  2551. }));
  2552. }
  2553. function guard(lowerBoundary, upperBoundary, value) {
  2554. return Math.max(lowerBoundary, Math.min(upperBoundary, value));
  2555. }
  2556. /**
  2557. * Returns a string value for the darkened color.
  2558. *
  2559. * @example
  2560. * // Styles as object usage
  2561. * const styles = {
  2562. * background: darken(0.2, '#FFCD64'),
  2563. * background: darken('0.2', 'rgba(255,205,100,0.7)'),
  2564. * }
  2565. *
  2566. * // styled-components usage
  2567. * const div = styled.div`
  2568. * background: ${darken(0.2, '#FFCD64')};
  2569. * background: ${darken('0.2', 'rgba(255,205,100,0.7)')};
  2570. * `
  2571. *
  2572. * // CSS in JS Output
  2573. *
  2574. * element {
  2575. * background: "#ffbd31";
  2576. * background: "rgba(255,189,49,0.7)";
  2577. * }
  2578. */
  2579. function darken(amount, color) {
  2580. if (color === 'transparent') return color;
  2581. var hslColor = parseToHsl(color);
  2582. return toColorString(_extends__default["default"]({}, hslColor, {
  2583. lightness: guard(0, 1, hslColor.lightness - parseFloat(amount))
  2584. }));
  2585. }
  2586. // prettier-ignore
  2587. var curriedDarken = curry /* ::<number | string, string, string> */(darken);
  2588. var curriedDarken$1 = curriedDarken;
  2589. /**
  2590. * Decreases the intensity of a color. Its range is between 0 to 1. The first
  2591. * argument of the desaturate function is the amount by how much the color
  2592. * intensity should be decreased.
  2593. *
  2594. * @example
  2595. * // Styles as object usage
  2596. * const styles = {
  2597. * background: desaturate(0.2, '#CCCD64'),
  2598. * background: desaturate('0.2', 'rgba(204,205,100,0.7)'),
  2599. * }
  2600. *
  2601. * // styled-components usage
  2602. * const div = styled.div`
  2603. * background: ${desaturate(0.2, '#CCCD64')};
  2604. * background: ${desaturate('0.2', 'rgba(204,205,100,0.7)')};
  2605. * `
  2606. *
  2607. * // CSS in JS Output
  2608. * element {
  2609. * background: "#b8b979";
  2610. * background: "rgba(184,185,121,0.7)";
  2611. * }
  2612. */
  2613. function desaturate(amount, color) {
  2614. if (color === 'transparent') return color;
  2615. var hslColor = parseToHsl(color);
  2616. return toColorString(_extends__default["default"]({}, hslColor, {
  2617. saturation: guard(0, 1, hslColor.saturation - parseFloat(amount))
  2618. }));
  2619. }
  2620. // prettier-ignore
  2621. var curriedDesaturate = curry /* ::<number | string, string, string> */(desaturate);
  2622. var curriedDesaturate$1 = curriedDesaturate;
  2623. /**
  2624. * Returns a number (float) representing the luminance of a color.
  2625. *
  2626. * @example
  2627. * // Styles as object usage
  2628. * const styles = {
  2629. * background: getLuminance('#CCCD64') >= getLuminance('#0000ff') ? '#CCCD64' : '#0000ff',
  2630. * background: getLuminance('rgba(58, 133, 255, 1)') >= getLuminance('rgba(255, 57, 149, 1)') ?
  2631. * 'rgba(58, 133, 255, 1)' :
  2632. * 'rgba(255, 57, 149, 1)',
  2633. * }
  2634. *
  2635. * // styled-components usage
  2636. * const div = styled.div`
  2637. * background: ${getLuminance('#CCCD64') >= getLuminance('#0000ff') ? '#CCCD64' : '#0000ff'};
  2638. * background: ${getLuminance('rgba(58, 133, 255, 1)') >= getLuminance('rgba(255, 57, 149, 1)') ?
  2639. * 'rgba(58, 133, 255, 1)' :
  2640. * 'rgba(255, 57, 149, 1)'};
  2641. *
  2642. * // CSS in JS Output
  2643. *
  2644. * div {
  2645. * background: "#CCCD64";
  2646. * background: "rgba(58, 133, 255, 1)";
  2647. * }
  2648. */
  2649. function getLuminance(color) {
  2650. if (color === 'transparent') return 0;
  2651. var rgbColor = parseToRgb(color);
  2652. var _Object$keys$map = Object.keys(rgbColor).map(function (key) {
  2653. var channel = rgbColor[key] / 255;
  2654. return channel <= 0.03928 ? channel / 12.92 : Math.pow((channel + 0.055) / 1.055, 2.4);
  2655. }),
  2656. r = _Object$keys$map[0],
  2657. g = _Object$keys$map[1],
  2658. b = _Object$keys$map[2];
  2659. return parseFloat((0.2126 * r + 0.7152 * g + 0.0722 * b).toFixed(3));
  2660. }
  2661. /**
  2662. * Returns the contrast ratio between two colors based on
  2663. * [W3's recommended equation for calculating contrast](http://www.w3.org/TR/WCAG20/#contrast-ratiodef).
  2664. *
  2665. * @example
  2666. * const contrastRatio = getContrast('#444', '#fff');
  2667. */
  2668. function getContrast(color1, color2) {
  2669. var luminance1 = getLuminance(color1);
  2670. var luminance2 = getLuminance(color2);
  2671. return parseFloat((luminance1 > luminance2 ? (luminance1 + 0.05) / (luminance2 + 0.05) : (luminance2 + 0.05) / (luminance1 + 0.05)).toFixed(2));
  2672. }
  2673. /**
  2674. * Converts the color to a grayscale, by reducing its saturation to 0.
  2675. *
  2676. * @example
  2677. * // Styles as object usage
  2678. * const styles = {
  2679. * background: grayscale('#CCCD64'),
  2680. * background: grayscale('rgba(204,205,100,0.7)'),
  2681. * }
  2682. *
  2683. * // styled-components usage
  2684. * const div = styled.div`
  2685. * background: ${grayscale('#CCCD64')};
  2686. * background: ${grayscale('rgba(204,205,100,0.7)')};
  2687. * `
  2688. *
  2689. * // CSS in JS Output
  2690. * element {
  2691. * background: "#999";
  2692. * background: "rgba(153,153,153,0.7)";
  2693. * }
  2694. */
  2695. function grayscale(color) {
  2696. if (color === 'transparent') return color;
  2697. return toColorString(_extends__default["default"]({}, parseToHsl(color), {
  2698. saturation: 0
  2699. }));
  2700. }
  2701. /**
  2702. * Converts a HslColor or HslaColor object to a color string.
  2703. * This util is useful in case you only know on runtime which color object is
  2704. * used. Otherwise we recommend to rely on `hsl` or `hsla`.
  2705. *
  2706. * @example
  2707. * // Styles as object usage
  2708. * const styles = {
  2709. * background: hslToColorString({ hue: 240, saturation: 1, lightness: 0.5 }),
  2710. * background: hslToColorString({ hue: 360, saturation: 0.75, lightness: 0.4, alpha: 0.72 }),
  2711. * }
  2712. *
  2713. * // styled-components usage
  2714. * const div = styled.div`
  2715. * background: ${hslToColorString({ hue: 240, saturation: 1, lightness: 0.5 })};
  2716. * background: ${hslToColorString({ hue: 360, saturation: 0.75, lightness: 0.4, alpha: 0.72 })};
  2717. * `
  2718. *
  2719. * // CSS in JS Output
  2720. * element {
  2721. * background: "#00f";
  2722. * background: "rgba(179,25,25,0.72)";
  2723. * }
  2724. */
  2725. function hslToColorString(color) {
  2726. if (typeof color === 'object' && typeof color.hue === 'number' && typeof color.saturation === 'number' && typeof color.lightness === 'number') {
  2727. if (color.alpha && typeof color.alpha === 'number') {
  2728. return hsla({
  2729. hue: color.hue,
  2730. saturation: color.saturation,
  2731. lightness: color.lightness,
  2732. alpha: color.alpha
  2733. });
  2734. }
  2735. return hsl({
  2736. hue: color.hue,
  2737. saturation: color.saturation,
  2738. lightness: color.lightness
  2739. });
  2740. }
  2741. throw new PolishedError(45);
  2742. }
  2743. /**
  2744. * Inverts the red, green and blue values of a color.
  2745. *
  2746. * @example
  2747. * // Styles as object usage
  2748. * const styles = {
  2749. * background: invert('#CCCD64'),
  2750. * background: invert('rgba(101,100,205,0.7)'),
  2751. * }
  2752. *
  2753. * // styled-components usage
  2754. * const div = styled.div`
  2755. * background: ${invert('#CCCD64')};
  2756. * background: ${invert('rgba(101,100,205,0.7)')};
  2757. * `
  2758. *
  2759. * // CSS in JS Output
  2760. *
  2761. * element {
  2762. * background: "#33329b";
  2763. * background: "rgba(154,155,50,0.7)";
  2764. * }
  2765. */
  2766. function invert(color) {
  2767. if (color === 'transparent') return color;
  2768. // parse color string to rgb
  2769. var value = parseToRgb(color);
  2770. return toColorString(_extends__default["default"]({}, value, {
  2771. red: 255 - value.red,
  2772. green: 255 - value.green,
  2773. blue: 255 - value.blue
  2774. }));
  2775. }
  2776. /**
  2777. * Returns a string value for the lightened color.
  2778. *
  2779. * @example
  2780. * // Styles as object usage
  2781. * const styles = {
  2782. * background: lighten(0.2, '#CCCD64'),
  2783. * background: lighten('0.2', 'rgba(204,205,100,0.7)'),
  2784. * }
  2785. *
  2786. * // styled-components usage
  2787. * const div = styled.div`
  2788. * background: ${lighten(0.2, '#FFCD64')};
  2789. * background: ${lighten('0.2', 'rgba(204,205,100,0.7)')};
  2790. * `
  2791. *
  2792. * // CSS in JS Output
  2793. *
  2794. * element {
  2795. * background: "#e5e6b1";
  2796. * background: "rgba(229,230,177,0.7)";
  2797. * }
  2798. */
  2799. function lighten(amount, color) {
  2800. if (color === 'transparent') return color;
  2801. var hslColor = parseToHsl(color);
  2802. return toColorString(_extends__default["default"]({}, hslColor, {
  2803. lightness: guard(0, 1, hslColor.lightness + parseFloat(amount))
  2804. }));
  2805. }
  2806. // prettier-ignore
  2807. var curriedLighten = curry /* ::<number | string, string, string> */(lighten);
  2808. var curriedLighten$1 = curriedLighten;
  2809. /**
  2810. * Determines which contrast guidelines have been met for two colors.
  2811. * Based on the [contrast calculations recommended by W3](https://www.w3.org/WAI/WCAG21/Understanding/contrast-enhanced.html).
  2812. *
  2813. * @example
  2814. * const scores = meetsContrastGuidelines('#444', '#fff');
  2815. */
  2816. function meetsContrastGuidelines(color1, color2) {
  2817. var contrastRatio = getContrast(color1, color2);
  2818. return {
  2819. AA: contrastRatio >= 4.5,
  2820. AALarge: contrastRatio >= 3,
  2821. AAA: contrastRatio >= 7,
  2822. AAALarge: contrastRatio >= 4.5
  2823. };
  2824. }
  2825. /**
  2826. * Mixes the two provided colors together by calculating the average of each of the RGB components weighted to the first color by the provided weight.
  2827. *
  2828. * @example
  2829. * // Styles as object usage
  2830. * const styles = {
  2831. * background: mix(0.5, '#f00', '#00f')
  2832. * background: mix(0.25, '#f00', '#00f')
  2833. * background: mix('0.5', 'rgba(255, 0, 0, 0.5)', '#00f')
  2834. * }
  2835. *
  2836. * // styled-components usage
  2837. * const div = styled.div`
  2838. * background: ${mix(0.5, '#f00', '#00f')};
  2839. * background: ${mix(0.25, '#f00', '#00f')};
  2840. * background: ${mix('0.5', 'rgba(255, 0, 0, 0.5)', '#00f')};
  2841. * `
  2842. *
  2843. * // CSS in JS Output
  2844. *
  2845. * element {
  2846. * background: "#7f007f";
  2847. * background: "#3f00bf";
  2848. * background: "rgba(63, 0, 191, 0.75)";
  2849. * }
  2850. */
  2851. function mix(weight, color, otherColor) {
  2852. if (color === 'transparent') return otherColor;
  2853. if (otherColor === 'transparent') return color;
  2854. if (weight === 0) return otherColor;
  2855. var parsedColor1 = parseToRgb(color);
  2856. var color1 = _extends__default["default"]({}, parsedColor1, {
  2857. alpha: typeof parsedColor1.alpha === 'number' ? parsedColor1.alpha : 1
  2858. });
  2859. var parsedColor2 = parseToRgb(otherColor);
  2860. var color2 = _extends__default["default"]({}, parsedColor2, {
  2861. alpha: typeof parsedColor2.alpha === 'number' ? parsedColor2.alpha : 1
  2862. });
  2863. // The formula is copied from the original Sass implementation:
  2864. // http://sass-lang.com/documentation/Sass/Script/Functions.html#mix-instance_method
  2865. var alphaDelta = color1.alpha - color2.alpha;
  2866. var x = parseFloat(weight) * 2 - 1;
  2867. var y = x * alphaDelta === -1 ? x : x + alphaDelta;
  2868. var z = 1 + x * alphaDelta;
  2869. var weight1 = (y / z + 1) / 2.0;
  2870. var weight2 = 1 - weight1;
  2871. var mixedColor = {
  2872. red: Math.floor(color1.red * weight1 + color2.red * weight2),
  2873. green: Math.floor(color1.green * weight1 + color2.green * weight2),
  2874. blue: Math.floor(color1.blue * weight1 + color2.blue * weight2),
  2875. alpha: color1.alpha * parseFloat(weight) + color2.alpha * (1 - parseFloat(weight))
  2876. };
  2877. return rgba(mixedColor);
  2878. }
  2879. // prettier-ignore
  2880. var curriedMix = curry /* ::<number | string, string, string, string> */(mix);
  2881. var mix$1 = curriedMix;
  2882. /**
  2883. * Increases the opacity of a color. Its range for the amount is between 0 to 1.
  2884. *
  2885. *
  2886. * @example
  2887. * // Styles as object usage
  2888. * const styles = {
  2889. * background: opacify(0.1, 'rgba(255, 255, 255, 0.9)');
  2890. * background: opacify(0.2, 'hsla(0, 0%, 100%, 0.5)'),
  2891. * background: opacify('0.5', 'rgba(255, 0, 0, 0.2)'),
  2892. * }
  2893. *
  2894. * // styled-components usage
  2895. * const div = styled.div`
  2896. * background: ${opacify(0.1, 'rgba(255, 255, 255, 0.9)')};
  2897. * background: ${opacify(0.2, 'hsla(0, 0%, 100%, 0.5)')},
  2898. * background: ${opacify('0.5', 'rgba(255, 0, 0, 0.2)')},
  2899. * `
  2900. *
  2901. * // CSS in JS Output
  2902. *
  2903. * element {
  2904. * background: "#fff";
  2905. * background: "rgba(255,255,255,0.7)";
  2906. * background: "rgba(255,0,0,0.7)";
  2907. * }
  2908. */
  2909. function opacify(amount, color) {
  2910. if (color === 'transparent') return color;
  2911. var parsedColor = parseToRgb(color);
  2912. var alpha = typeof parsedColor.alpha === 'number' ? parsedColor.alpha : 1;
  2913. var colorWithAlpha = _extends__default["default"]({}, parsedColor, {
  2914. alpha: guard(0, 1, (alpha * 100 + parseFloat(amount) * 100) / 100)
  2915. });
  2916. return rgba(colorWithAlpha);
  2917. }
  2918. // prettier-ignore
  2919. var curriedOpacify = curry /* ::<number | string, string, string> */(opacify);
  2920. var curriedOpacify$1 = curriedOpacify;
  2921. var defaultReturnIfLightColor = '#000';
  2922. var defaultReturnIfDarkColor = '#fff';
  2923. /**
  2924. * Returns black or white (or optional passed colors) for best
  2925. * contrast depending on the luminosity of the given color.
  2926. * When passing custom return colors, strict mode ensures that the
  2927. * return color always meets or exceeds WCAG level AA or greater. If this test
  2928. * fails, the default return color (black or white) is returned in place of the
  2929. * custom return color. You can optionally turn off strict mode.
  2930. *
  2931. * Follows [W3C specs for readability](https://www.w3.org/TR/WCAG20-TECHS/G18.html).
  2932. *
  2933. * @example
  2934. * // Styles as object usage
  2935. * const styles = {
  2936. * color: readableColor('#000'),
  2937. * color: readableColor('black', '#001', '#ff8'),
  2938. * color: readableColor('white', '#001', '#ff8'),
  2939. * color: readableColor('red', '#333', '#ddd', true)
  2940. * }
  2941. *
  2942. * // styled-components usage
  2943. * const div = styled.div`
  2944. * color: ${readableColor('#000')};
  2945. * color: ${readableColor('black', '#001', '#ff8')};
  2946. * color: ${readableColor('white', '#001', '#ff8')};
  2947. * color: ${readableColor('red', '#333', '#ddd', true)};
  2948. * `
  2949. *
  2950. * // CSS in JS Output
  2951. * element {
  2952. * color: "#fff";
  2953. * color: "#ff8";
  2954. * color: "#001";
  2955. * color: "#000";
  2956. * }
  2957. */
  2958. function readableColor(color, returnIfLightColor, returnIfDarkColor, strict) {
  2959. if (returnIfLightColor === void 0) {
  2960. returnIfLightColor = defaultReturnIfLightColor;
  2961. }
  2962. if (returnIfDarkColor === void 0) {
  2963. returnIfDarkColor = defaultReturnIfDarkColor;
  2964. }
  2965. if (strict === void 0) {
  2966. strict = true;
  2967. }
  2968. var isColorLight = getLuminance(color) > 0.179;
  2969. var preferredReturnColor = isColorLight ? returnIfLightColor : returnIfDarkColor;
  2970. if (!strict || getContrast(color, preferredReturnColor) >= 4.5) {
  2971. return preferredReturnColor;
  2972. }
  2973. return isColorLight ? defaultReturnIfLightColor : defaultReturnIfDarkColor;
  2974. }
  2975. /**
  2976. * Converts a RgbColor or RgbaColor object to a color string.
  2977. * This util is useful in case you only know on runtime which color object is
  2978. * used. Otherwise we recommend to rely on `rgb` or `rgba`.
  2979. *
  2980. * @example
  2981. * // Styles as object usage
  2982. * const styles = {
  2983. * background: rgbToColorString({ red: 255, green: 205, blue: 100 }),
  2984. * background: rgbToColorString({ red: 255, green: 205, blue: 100, alpha: 0.72 }),
  2985. * }
  2986. *
  2987. * // styled-components usage
  2988. * const div = styled.div`
  2989. * background: ${rgbToColorString({ red: 255, green: 205, blue: 100 })};
  2990. * background: ${rgbToColorString({ red: 255, green: 205, blue: 100, alpha: 0.72 })};
  2991. * `
  2992. *
  2993. * // CSS in JS Output
  2994. * element {
  2995. * background: "#ffcd64";
  2996. * background: "rgba(255,205,100,0.72)";
  2997. * }
  2998. */
  2999. function rgbToColorString(color) {
  3000. if (typeof color === 'object' && typeof color.red === 'number' && typeof color.green === 'number' && typeof color.blue === 'number') {
  3001. if (typeof color.alpha === 'number') {
  3002. return rgba({
  3003. red: color.red,
  3004. green: color.green,
  3005. blue: color.blue,
  3006. alpha: color.alpha
  3007. });
  3008. }
  3009. return rgb({
  3010. red: color.red,
  3011. green: color.green,
  3012. blue: color.blue
  3013. });
  3014. }
  3015. throw new PolishedError(46);
  3016. }
  3017. /**
  3018. * Increases the intensity of a color. Its range is between 0 to 1. The first
  3019. * argument of the saturate function is the amount by how much the color
  3020. * intensity should be increased.
  3021. *
  3022. * @example
  3023. * // Styles as object usage
  3024. * const styles = {
  3025. * background: saturate(0.2, '#CCCD64'),
  3026. * background: saturate('0.2', 'rgba(204,205,100,0.7)'),
  3027. * }
  3028. *
  3029. * // styled-components usage
  3030. * const div = styled.div`
  3031. * background: ${saturate(0.2, '#FFCD64')};
  3032. * background: ${saturate('0.2', 'rgba(204,205,100,0.7)')};
  3033. * `
  3034. *
  3035. * // CSS in JS Output
  3036. *
  3037. * element {
  3038. * background: "#e0e250";
  3039. * background: "rgba(224,226,80,0.7)";
  3040. * }
  3041. */
  3042. function saturate(amount, color) {
  3043. if (color === 'transparent') return color;
  3044. var hslColor = parseToHsl(color);
  3045. return toColorString(_extends__default["default"]({}, hslColor, {
  3046. saturation: guard(0, 1, hslColor.saturation + parseFloat(amount))
  3047. }));
  3048. }
  3049. // prettier-ignore
  3050. var curriedSaturate = curry /* ::<number | string, string, string> */(saturate);
  3051. var curriedSaturate$1 = curriedSaturate;
  3052. /**
  3053. * Sets the hue of a color to the provided value. The hue range can be
  3054. * from 0 and 359.
  3055. *
  3056. * @example
  3057. * // Styles as object usage
  3058. * const styles = {
  3059. * background: setHue(42, '#CCCD64'),
  3060. * background: setHue('244', 'rgba(204,205,100,0.7)'),
  3061. * }
  3062. *
  3063. * // styled-components usage
  3064. * const div = styled.div`
  3065. * background: ${setHue(42, '#CCCD64')};
  3066. * background: ${setHue('244', 'rgba(204,205,100,0.7)')};
  3067. * `
  3068. *
  3069. * // CSS in JS Output
  3070. * element {
  3071. * background: "#cdae64";
  3072. * background: "rgba(107,100,205,0.7)";
  3073. * }
  3074. */
  3075. function setHue(hue, color) {
  3076. if (color === 'transparent') return color;
  3077. return toColorString(_extends__default["default"]({}, parseToHsl(color), {
  3078. hue: parseFloat(hue)
  3079. }));
  3080. }
  3081. // prettier-ignore
  3082. var curriedSetHue = curry /* ::<number | string, string, string> */(setHue);
  3083. var curriedSetHue$1 = curriedSetHue;
  3084. /**
  3085. * Sets the lightness of a color to the provided value. The lightness range can be
  3086. * from 0 and 1.
  3087. *
  3088. * @example
  3089. * // Styles as object usage
  3090. * const styles = {
  3091. * background: setLightness(0.2, '#CCCD64'),
  3092. * background: setLightness('0.75', 'rgba(204,205,100,0.7)'),
  3093. * }
  3094. *
  3095. * // styled-components usage
  3096. * const div = styled.div`
  3097. * background: ${setLightness(0.2, '#CCCD64')};
  3098. * background: ${setLightness('0.75', 'rgba(204,205,100,0.7)')};
  3099. * `
  3100. *
  3101. * // CSS in JS Output
  3102. * element {
  3103. * background: "#4d4d19";
  3104. * background: "rgba(223,224,159,0.7)";
  3105. * }
  3106. */
  3107. function setLightness(lightness, color) {
  3108. if (color === 'transparent') return color;
  3109. return toColorString(_extends__default["default"]({}, parseToHsl(color), {
  3110. lightness: parseFloat(lightness)
  3111. }));
  3112. }
  3113. // prettier-ignore
  3114. var curriedSetLightness = curry /* ::<number | string, string, string> */(setLightness);
  3115. var curriedSetLightness$1 = curriedSetLightness;
  3116. /**
  3117. * Sets the saturation of a color to the provided value. The saturation range can be
  3118. * from 0 and 1.
  3119. *
  3120. * @example
  3121. * // Styles as object usage
  3122. * const styles = {
  3123. * background: setSaturation(0.2, '#CCCD64'),
  3124. * background: setSaturation('0.75', 'rgba(204,205,100,0.7)'),
  3125. * }
  3126. *
  3127. * // styled-components usage
  3128. * const div = styled.div`
  3129. * background: ${setSaturation(0.2, '#CCCD64')};
  3130. * background: ${setSaturation('0.75', 'rgba(204,205,100,0.7)')};
  3131. * `
  3132. *
  3133. * // CSS in JS Output
  3134. * element {
  3135. * background: "#adad84";
  3136. * background: "rgba(228,229,76,0.7)";
  3137. * }
  3138. */
  3139. function setSaturation(saturation, color) {
  3140. if (color === 'transparent') return color;
  3141. return toColorString(_extends__default["default"]({}, parseToHsl(color), {
  3142. saturation: parseFloat(saturation)
  3143. }));
  3144. }
  3145. // prettier-ignore
  3146. var curriedSetSaturation = curry /* ::<number | string, string, string> */(setSaturation);
  3147. var curriedSetSaturation$1 = curriedSetSaturation;
  3148. /**
  3149. * Shades a color by mixing it with black. `shade` can produce
  3150. * hue shifts, where as `darken` manipulates the luminance channel and therefore
  3151. * doesn't produce hue shifts.
  3152. *
  3153. * @example
  3154. * // Styles as object usage
  3155. * const styles = {
  3156. * background: shade(0.25, '#00f')
  3157. * }
  3158. *
  3159. * // styled-components usage
  3160. * const div = styled.div`
  3161. * background: ${shade(0.25, '#00f')};
  3162. * `
  3163. *
  3164. * // CSS in JS Output
  3165. *
  3166. * element {
  3167. * background: "#00003f";
  3168. * }
  3169. */
  3170. function shade(percentage, color) {
  3171. if (color === 'transparent') return color;
  3172. return mix$1(parseFloat(percentage), 'rgb(0, 0, 0)', color);
  3173. }
  3174. // prettier-ignore
  3175. var curriedShade = curry /* ::<number | string, string, string> */(shade);
  3176. var curriedShade$1 = curriedShade;
  3177. /**
  3178. * Tints a color by mixing it with white. `tint` can produce
  3179. * hue shifts, where as `lighten` manipulates the luminance channel and therefore
  3180. * doesn't produce hue shifts.
  3181. *
  3182. * @example
  3183. * // Styles as object usage
  3184. * const styles = {
  3185. * background: tint(0.25, '#00f')
  3186. * }
  3187. *
  3188. * // styled-components usage
  3189. * const div = styled.div`
  3190. * background: ${tint(0.25, '#00f')};
  3191. * `
  3192. *
  3193. * // CSS in JS Output
  3194. *
  3195. * element {
  3196. * background: "#bfbfff";
  3197. * }
  3198. */
  3199. function tint(percentage, color) {
  3200. if (color === 'transparent') return color;
  3201. return mix$1(parseFloat(percentage), 'rgb(255, 255, 255)', color);
  3202. }
  3203. // prettier-ignore
  3204. var curriedTint = curry /* ::<number | string, string, string> */(tint);
  3205. var curriedTint$1 = curriedTint;
  3206. /**
  3207. * Decreases the opacity of a color. Its range for the amount is between 0 to 1.
  3208. *
  3209. *
  3210. * @example
  3211. * // Styles as object usage
  3212. * const styles = {
  3213. * background: transparentize(0.1, '#fff'),
  3214. * background: transparentize(0.2, 'hsl(0, 0%, 100%)'),
  3215. * background: transparentize('0.5', 'rgba(255, 0, 0, 0.8)'),
  3216. * }
  3217. *
  3218. * // styled-components usage
  3219. * const div = styled.div`
  3220. * background: ${transparentize(0.1, '#fff')};
  3221. * background: ${transparentize(0.2, 'hsl(0, 0%, 100%)')};
  3222. * background: ${transparentize('0.5', 'rgba(255, 0, 0, 0.8)')};
  3223. * `
  3224. *
  3225. * // CSS in JS Output
  3226. *
  3227. * element {
  3228. * background: "rgba(255,255,255,0.9)";
  3229. * background: "rgba(255,255,255,0.8)";
  3230. * background: "rgba(255,0,0,0.3)";
  3231. * }
  3232. */
  3233. function transparentize(amount, color) {
  3234. if (color === 'transparent') return color;
  3235. var parsedColor = parseToRgb(color);
  3236. var alpha = typeof parsedColor.alpha === 'number' ? parsedColor.alpha : 1;
  3237. var colorWithAlpha = _extends__default["default"]({}, parsedColor, {
  3238. alpha: guard(0, 1, +(alpha * 100 - parseFloat(amount) * 100).toFixed(2) / 100)
  3239. });
  3240. return rgba(colorWithAlpha);
  3241. }
  3242. // prettier-ignore
  3243. var curriedTransparentize = curry /* ::<number | string, string, string> */(transparentize);
  3244. var curriedTransparentize$1 = curriedTransparentize;
  3245. /**
  3246. * Shorthand for easily setting the animation property. Allows either multiple arrays with animations
  3247. * or a single animation spread over the arguments.
  3248. * @example
  3249. * // Styles as object usage
  3250. * const styles = {
  3251. * ...animation(['rotate', '1s', 'ease-in-out'], ['colorchange', '2s'])
  3252. * }
  3253. *
  3254. * // styled-components usage
  3255. * const div = styled.div`
  3256. * ${animation(['rotate', '1s', 'ease-in-out'], ['colorchange', '2s'])}
  3257. * `
  3258. *
  3259. * // CSS as JS Output
  3260. *
  3261. * div {
  3262. * 'animation': 'rotate 1s ease-in-out, colorchange 2s'
  3263. * }
  3264. * @example
  3265. * // Styles as object usage
  3266. * const styles = {
  3267. * ...animation('rotate', '1s', 'ease-in-out')
  3268. * }
  3269. *
  3270. * // styled-components usage
  3271. * const div = styled.div`
  3272. * ${animation('rotate', '1s', 'ease-in-out')}
  3273. * `
  3274. *
  3275. * // CSS as JS Output
  3276. *
  3277. * div {
  3278. * 'animation': 'rotate 1s ease-in-out'
  3279. * }
  3280. */
  3281. function animation() {
  3282. for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
  3283. args[_key] = arguments[_key];
  3284. }
  3285. // Allow single or multiple animations passed
  3286. var multiMode = Array.isArray(args[0]);
  3287. if (!multiMode && args.length > 8) {
  3288. throw new PolishedError(64);
  3289. }
  3290. var code = args.map(function (arg) {
  3291. if (multiMode && !Array.isArray(arg) || !multiMode && Array.isArray(arg)) {
  3292. throw new PolishedError(65);
  3293. }
  3294. if (Array.isArray(arg) && arg.length > 8) {
  3295. throw new PolishedError(66);
  3296. }
  3297. return Array.isArray(arg) ? arg.join(' ') : arg;
  3298. }).join(', ');
  3299. return {
  3300. animation: code
  3301. };
  3302. }
  3303. /**
  3304. * Shorthand that accepts any number of backgroundImage values as parameters for creating a single background statement.
  3305. * @example
  3306. * // Styles as object usage
  3307. * const styles = {
  3308. * ...backgroundImages('url("/image/background.jpg")', 'linear-gradient(red, green)')
  3309. * }
  3310. *
  3311. * // styled-components usage
  3312. * const div = styled.div`
  3313. * ${backgroundImages('url("/image/background.jpg")', 'linear-gradient(red, green)')}
  3314. * `
  3315. *
  3316. * // CSS as JS Output
  3317. *
  3318. * div {
  3319. * 'backgroundImage': 'url("/image/background.jpg"), linear-gradient(red, green)'
  3320. * }
  3321. */
  3322. function backgroundImages() {
  3323. for (var _len = arguments.length, properties = new Array(_len), _key = 0; _key < _len; _key++) {
  3324. properties[_key] = arguments[_key];
  3325. }
  3326. return {
  3327. backgroundImage: properties.join(', ')
  3328. };
  3329. }
  3330. /**
  3331. * Shorthand that accepts any number of background values as parameters for creating a single background statement.
  3332. * @example
  3333. * // Styles as object usage
  3334. * const styles = {
  3335. * ...backgrounds('url("/image/background.jpg")', 'linear-gradient(red, green)', 'center no-repeat')
  3336. * }
  3337. *
  3338. * // styled-components usage
  3339. * const div = styled.div`
  3340. * ${backgrounds('url("/image/background.jpg")', 'linear-gradient(red, green)', 'center no-repeat')}
  3341. * `
  3342. *
  3343. * // CSS as JS Output
  3344. *
  3345. * div {
  3346. * 'background': 'url("/image/background.jpg"), linear-gradient(red, green), center no-repeat'
  3347. * }
  3348. */
  3349. function backgrounds() {
  3350. for (var _len = arguments.length, properties = new Array(_len), _key = 0; _key < _len; _key++) {
  3351. properties[_key] = arguments[_key];
  3352. }
  3353. return {
  3354. background: properties.join(', ')
  3355. };
  3356. }
  3357. var sideMap = ['top', 'right', 'bottom', 'left'];
  3358. /**
  3359. * Shorthand for the border property that splits out individual properties for use with tools like Fela and Styletron. A side keyword can optionally be passed to target only one side's border properties.
  3360. *
  3361. * @example
  3362. * // Styles as object usage
  3363. * const styles = {
  3364. * ...border('1px', 'solid', 'red')
  3365. * }
  3366. *
  3367. * // styled-components usage
  3368. * const div = styled.div`
  3369. * ${border('1px', 'solid', 'red')}
  3370. * `
  3371. *
  3372. * // CSS as JS Output
  3373. *
  3374. * div {
  3375. * 'borderColor': 'red',
  3376. * 'borderStyle': 'solid',
  3377. * 'borderWidth': `1px`,
  3378. * }
  3379. *
  3380. * // Styles as object usage
  3381. * const styles = {
  3382. * ...border('top', '1px', 'solid', 'red')
  3383. * }
  3384. *
  3385. * // styled-components usage
  3386. * const div = styled.div`
  3387. * ${border('top', '1px', 'solid', 'red')}
  3388. * `
  3389. *
  3390. * // CSS as JS Output
  3391. *
  3392. * div {
  3393. * 'borderTopColor': 'red',
  3394. * 'borderTopStyle': 'solid',
  3395. * 'borderTopWidth': `1px`,
  3396. * }
  3397. */
  3398. function border(sideKeyword) {
  3399. for (var _len = arguments.length, values = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
  3400. values[_key - 1] = arguments[_key];
  3401. }
  3402. if (typeof sideKeyword === 'string' && sideMap.indexOf(sideKeyword) >= 0) {
  3403. var _ref;
  3404. return _ref = {}, _ref["border" + capitalizeString(sideKeyword) + "Width"] = values[0], _ref["border" + capitalizeString(sideKeyword) + "Style"] = values[1], _ref["border" + capitalizeString(sideKeyword) + "Color"] = values[2], _ref;
  3405. } else {
  3406. values.unshift(sideKeyword);
  3407. return {
  3408. borderWidth: values[0],
  3409. borderStyle: values[1],
  3410. borderColor: values[2]
  3411. };
  3412. }
  3413. }
  3414. /**
  3415. * Shorthand that accepts up to four values, including null to skip a value, and maps them to their respective directions.
  3416. * @example
  3417. * // Styles as object usage
  3418. * const styles = {
  3419. * ...borderColor('red', 'green', 'blue', 'yellow')
  3420. * }
  3421. *
  3422. * // styled-components usage
  3423. * const div = styled.div`
  3424. * ${borderColor('red', 'green', 'blue', 'yellow')}
  3425. * `
  3426. *
  3427. * // CSS as JS Output
  3428. *
  3429. * div {
  3430. * 'borderTopColor': 'red',
  3431. * 'borderRightColor': 'green',
  3432. * 'borderBottomColor': 'blue',
  3433. * 'borderLeftColor': 'yellow'
  3434. * }
  3435. */
  3436. function borderColor() {
  3437. for (var _len = arguments.length, values = new Array(_len), _key = 0; _key < _len; _key++) {
  3438. values[_key] = arguments[_key];
  3439. }
  3440. return directionalProperty.apply(void 0, ['borderColor'].concat(values));
  3441. }
  3442. /**
  3443. * Shorthand that accepts a value for side and a value for radius and applies the radius value to both corners of the side.
  3444. * @example
  3445. * // Styles as object usage
  3446. * const styles = {
  3447. * ...borderRadius('top', '5px')
  3448. * }
  3449. *
  3450. * // styled-components usage
  3451. * const div = styled.div`
  3452. * ${borderRadius('top', '5px')}
  3453. * `
  3454. *
  3455. * // CSS as JS Output
  3456. *
  3457. * div {
  3458. * 'borderTopRightRadius': '5px',
  3459. * 'borderTopLeftRadius': '5px',
  3460. * }
  3461. */
  3462. function borderRadius(side, radius) {
  3463. var uppercaseSide = capitalizeString(side);
  3464. if (!radius && radius !== 0) {
  3465. throw new PolishedError(62);
  3466. }
  3467. if (uppercaseSide === 'Top' || uppercaseSide === 'Bottom') {
  3468. var _ref;
  3469. return _ref = {}, _ref["border" + uppercaseSide + "RightRadius"] = radius, _ref["border" + uppercaseSide + "LeftRadius"] = radius, _ref;
  3470. }
  3471. if (uppercaseSide === 'Left' || uppercaseSide === 'Right') {
  3472. var _ref2;
  3473. return _ref2 = {}, _ref2["borderTop" + uppercaseSide + "Radius"] = radius, _ref2["borderBottom" + uppercaseSide + "Radius"] = radius, _ref2;
  3474. }
  3475. throw new PolishedError(63);
  3476. }
  3477. /**
  3478. * Shorthand that accepts up to four values, including null to skip a value, and maps them to their respective directions.
  3479. * @example
  3480. * // Styles as object usage
  3481. * const styles = {
  3482. * ...borderStyle('solid', 'dashed', 'dotted', 'double')
  3483. * }
  3484. *
  3485. * // styled-components usage
  3486. * const div = styled.div`
  3487. * ${borderStyle('solid', 'dashed', 'dotted', 'double')}
  3488. * `
  3489. *
  3490. * // CSS as JS Output
  3491. *
  3492. * div {
  3493. * 'borderTopStyle': 'solid',
  3494. * 'borderRightStyle': 'dashed',
  3495. * 'borderBottomStyle': 'dotted',
  3496. * 'borderLeftStyle': 'double'
  3497. * }
  3498. */
  3499. function borderStyle() {
  3500. for (var _len = arguments.length, values = new Array(_len), _key = 0; _key < _len; _key++) {
  3501. values[_key] = arguments[_key];
  3502. }
  3503. return directionalProperty.apply(void 0, ['borderStyle'].concat(values));
  3504. }
  3505. /**
  3506. * Shorthand that accepts up to four values, including null to skip a value, and maps them to their respective directions.
  3507. * @example
  3508. * // Styles as object usage
  3509. * const styles = {
  3510. * ...borderWidth('12px', '24px', '36px', '48px')
  3511. * }
  3512. *
  3513. * // styled-components usage
  3514. * const div = styled.div`
  3515. * ${borderWidth('12px', '24px', '36px', '48px')}
  3516. * `
  3517. *
  3518. * // CSS as JS Output
  3519. *
  3520. * div {
  3521. * 'borderTopWidth': '12px',
  3522. * 'borderRightWidth': '24px',
  3523. * 'borderBottomWidth': '36px',
  3524. * 'borderLeftWidth': '48px'
  3525. * }
  3526. */
  3527. function borderWidth() {
  3528. for (var _len = arguments.length, values = new Array(_len), _key = 0; _key < _len; _key++) {
  3529. values[_key] = arguments[_key];
  3530. }
  3531. return directionalProperty.apply(void 0, ['borderWidth'].concat(values));
  3532. }
  3533. function generateSelectors(template, state) {
  3534. var stateSuffix = state ? ":" + state : '';
  3535. return template(stateSuffix);
  3536. }
  3537. /**
  3538. * Function helper that adds an array of states to a template of selectors. Used in textInputs and buttons.
  3539. * @private
  3540. */
  3541. function statefulSelectors(states, template, stateMap) {
  3542. if (!template) throw new PolishedError(67);
  3543. if (states.length === 0) return generateSelectors(template, null);
  3544. var selectors = [];
  3545. for (var i = 0; i < states.length; i += 1) {
  3546. if (stateMap && stateMap.indexOf(states[i]) < 0) {
  3547. throw new PolishedError(68);
  3548. }
  3549. selectors.push(generateSelectors(template, states[i]));
  3550. }
  3551. selectors = selectors.join(',');
  3552. return selectors;
  3553. }
  3554. var stateMap$1 = [undefined, null, 'active', 'focus', 'hover'];
  3555. function template$1(state) {
  3556. return "button" + state + ",\n input[type=\"button\"]" + state + ",\n input[type=\"reset\"]" + state + ",\n input[type=\"submit\"]" + state;
  3557. }
  3558. /**
  3559. * Populates selectors that target all buttons. You can pass optional states to append to the selectors.
  3560. * @example
  3561. * // Styles as object usage
  3562. * const styles = {
  3563. * [buttons('active')]: {
  3564. * 'border': 'none'
  3565. * }
  3566. * }
  3567. *
  3568. * // styled-components usage
  3569. * const div = styled.div`
  3570. * > ${buttons('active')} {
  3571. * border: none;
  3572. * }
  3573. * `
  3574. *
  3575. * // CSS in JS Output
  3576. *
  3577. * 'button:active,
  3578. * 'input[type="button"]:active,
  3579. * 'input[type=\"reset\"]:active,
  3580. * 'input[type=\"submit\"]:active: {
  3581. * 'border': 'none'
  3582. * }
  3583. */
  3584. function buttons() {
  3585. for (var _len = arguments.length, states = new Array(_len), _key = 0; _key < _len; _key++) {
  3586. states[_key] = arguments[_key];
  3587. }
  3588. return statefulSelectors(states, template$1, stateMap$1);
  3589. }
  3590. /**
  3591. * Shorthand that accepts up to four values, including null to skip a value, and maps them to their respective directions.
  3592. * @example
  3593. * // Styles as object usage
  3594. * const styles = {
  3595. * ...margin('12px', '24px', '36px', '48px')
  3596. * }
  3597. *
  3598. * // styled-components usage
  3599. * const div = styled.div`
  3600. * ${margin('12px', '24px', '36px', '48px')}
  3601. * `
  3602. *
  3603. * // CSS as JS Output
  3604. *
  3605. * div {
  3606. * 'marginTop': '12px',
  3607. * 'marginRight': '24px',
  3608. * 'marginBottom': '36px',
  3609. * 'marginLeft': '48px'
  3610. * }
  3611. */
  3612. function margin() {
  3613. for (var _len = arguments.length, values = new Array(_len), _key = 0; _key < _len; _key++) {
  3614. values[_key] = arguments[_key];
  3615. }
  3616. return directionalProperty.apply(void 0, ['margin'].concat(values));
  3617. }
  3618. /**
  3619. * Shorthand that accepts up to four values, including null to skip a value, and maps them to their respective directions.
  3620. * @example
  3621. * // Styles as object usage
  3622. * const styles = {
  3623. * ...padding('12px', '24px', '36px', '48px')
  3624. * }
  3625. *
  3626. * // styled-components usage
  3627. * const div = styled.div`
  3628. * ${padding('12px', '24px', '36px', '48px')}
  3629. * `
  3630. *
  3631. * // CSS as JS Output
  3632. *
  3633. * div {
  3634. * 'paddingTop': '12px',
  3635. * 'paddingRight': '24px',
  3636. * 'paddingBottom': '36px',
  3637. * 'paddingLeft': '48px'
  3638. * }
  3639. */
  3640. function padding() {
  3641. for (var _len = arguments.length, values = new Array(_len), _key = 0; _key < _len; _key++) {
  3642. values[_key] = arguments[_key];
  3643. }
  3644. return directionalProperty.apply(void 0, ['padding'].concat(values));
  3645. }
  3646. var positionMap = ['absolute', 'fixed', 'relative', 'static', 'sticky'];
  3647. /**
  3648. * Shorthand accepts up to five values, including null to skip a value, and maps them to their respective directions. The first value can optionally be a position keyword.
  3649. * @example
  3650. * // Styles as object usage
  3651. * const styles = {
  3652. * ...position('12px', '24px', '36px', '48px')
  3653. * }
  3654. *
  3655. * // styled-components usage
  3656. * const div = styled.div`
  3657. * ${position('12px', '24px', '36px', '48px')}
  3658. * `
  3659. *
  3660. * // CSS as JS Output
  3661. *
  3662. * div {
  3663. * 'top': '12px',
  3664. * 'right': '24px',
  3665. * 'bottom': '36px',
  3666. * 'left': '48px'
  3667. * }
  3668. *
  3669. * // Styles as object usage
  3670. * const styles = {
  3671. * ...position('absolute', '12px', '24px', '36px', '48px')
  3672. * }
  3673. *
  3674. * // styled-components usage
  3675. * const div = styled.div`
  3676. * ${position('absolute', '12px', '24px', '36px', '48px')}
  3677. * `
  3678. *
  3679. * // CSS as JS Output
  3680. *
  3681. * div {
  3682. * 'position': 'absolute',
  3683. * 'top': '12px',
  3684. * 'right': '24px',
  3685. * 'bottom': '36px',
  3686. * 'left': '48px'
  3687. * }
  3688. */
  3689. function position(firstValue) {
  3690. for (var _len = arguments.length, values = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
  3691. values[_key - 1] = arguments[_key];
  3692. }
  3693. if (positionMap.indexOf(firstValue) >= 0 && firstValue) {
  3694. return _extends__default["default"]({}, directionalProperty.apply(void 0, [''].concat(values)), {
  3695. position: firstValue
  3696. });
  3697. } else {
  3698. return directionalProperty.apply(void 0, ['', firstValue].concat(values));
  3699. }
  3700. }
  3701. /**
  3702. * Shorthand to set the height and width properties in a single statement.
  3703. * @example
  3704. * // Styles as object usage
  3705. * const styles = {
  3706. * ...size('300px', '250px')
  3707. * }
  3708. *
  3709. * // styled-components usage
  3710. * const div = styled.div`
  3711. * ${size('300px', '250px')}
  3712. * `
  3713. *
  3714. * // CSS as JS Output
  3715. *
  3716. * div {
  3717. * 'height': '300px',
  3718. * 'width': '250px',
  3719. * }
  3720. */
  3721. function size(height, width) {
  3722. if (width === void 0) {
  3723. width = height;
  3724. }
  3725. return {
  3726. height: height,
  3727. width: width
  3728. };
  3729. }
  3730. var stateMap = [undefined, null, 'active', 'focus', 'hover'];
  3731. function template(state) {
  3732. return "input[type=\"color\"]" + state + ",\n input[type=\"date\"]" + state + ",\n input[type=\"datetime\"]" + state + ",\n input[type=\"datetime-local\"]" + state + ",\n input[type=\"email\"]" + state + ",\n input[type=\"month\"]" + state + ",\n input[type=\"number\"]" + state + ",\n input[type=\"password\"]" + state + ",\n input[type=\"search\"]" + state + ",\n input[type=\"tel\"]" + state + ",\n input[type=\"text\"]" + state + ",\n input[type=\"time\"]" + state + ",\n input[type=\"url\"]" + state + ",\n input[type=\"week\"]" + state + ",\n input:not([type])" + state + ",\n textarea" + state;
  3733. }
  3734. /**
  3735. * Populates selectors that target all text inputs. You can pass optional states to append to the selectors.
  3736. * @example
  3737. * // Styles as object usage
  3738. * const styles = {
  3739. * [textInputs('active')]: {
  3740. * 'border': 'none'
  3741. * }
  3742. * }
  3743. *
  3744. * // styled-components usage
  3745. * const div = styled.div`
  3746. * > ${textInputs('active')} {
  3747. * border: none;
  3748. * }
  3749. * `
  3750. *
  3751. * // CSS in JS Output
  3752. *
  3753. * 'input[type="color"]:active,
  3754. * input[type="date"]:active,
  3755. * input[type="datetime"]:active,
  3756. * input[type="datetime-local"]:active,
  3757. * input[type="email"]:active,
  3758. * input[type="month"]:active,
  3759. * input[type="number"]:active,
  3760. * input[type="password"]:active,
  3761. * input[type="search"]:active,
  3762. * input[type="tel"]:active,
  3763. * input[type="text"]:active,
  3764. * input[type="time"]:active,
  3765. * input[type="url"]:active,
  3766. * input[type="week"]:active,
  3767. * input:not([type]):active,
  3768. * textarea:active': {
  3769. * 'border': 'none'
  3770. * }
  3771. */
  3772. function textInputs() {
  3773. for (var _len = arguments.length, states = new Array(_len), _key = 0; _key < _len; _key++) {
  3774. states[_key] = arguments[_key];
  3775. }
  3776. return statefulSelectors(states, template, stateMap);
  3777. }
  3778. /**
  3779. * Accepts any number of transition values as parameters for creating a single transition statement. You may also pass an array of properties as the first parameter that you would like to apply the same transition values to (second parameter).
  3780. * @example
  3781. * // Styles as object usage
  3782. * const styles = {
  3783. * ...transitions('opacity 1.0s ease-in 0s', 'width 2.0s ease-in 2s'),
  3784. * ...transitions(['color', 'background-color'], '2.0s ease-in 2s')
  3785. * }
  3786. *
  3787. * // styled-components usage
  3788. * const div = styled.div`
  3789. * ${transitions('opacity 1.0s ease-in 0s', 'width 2.0s ease-in 2s')};
  3790. * ${transitions(['color', 'background-color'], '2.0s ease-in 2s'),};
  3791. * `
  3792. *
  3793. * // CSS as JS Output
  3794. *
  3795. * div {
  3796. * 'transition': 'opacity 1.0s ease-in 0s, width 2.0s ease-in 2s'
  3797. * 'transition': 'color 2.0s ease-in 2s, background-color 2.0s ease-in 2s',
  3798. * }
  3799. */
  3800. function transitions() {
  3801. for (var _len = arguments.length, properties = new Array(_len), _key = 0; _key < _len; _key++) {
  3802. properties[_key] = arguments[_key];
  3803. }
  3804. if (Array.isArray(properties[0]) && properties.length === 2) {
  3805. var value = properties[1];
  3806. if (typeof value !== 'string') {
  3807. throw new PolishedError(61);
  3808. }
  3809. var transitionsString = properties[0].map(function (property) {
  3810. return property + " " + value;
  3811. }).join(', ');
  3812. return {
  3813. transition: transitionsString
  3814. };
  3815. } else {
  3816. return {
  3817. transition: properties.join(', ')
  3818. };
  3819. }
  3820. }
  3821. exports.adjustHue = curriedAdjustHue$1;
  3822. exports.animation = animation;
  3823. exports.backgroundImages = backgroundImages;
  3824. exports.backgrounds = backgrounds;
  3825. exports.between = between;
  3826. exports.border = border;
  3827. exports.borderColor = borderColor;
  3828. exports.borderRadius = borderRadius;
  3829. exports.borderStyle = borderStyle;
  3830. exports.borderWidth = borderWidth;
  3831. exports.buttons = buttons;
  3832. exports.clearFix = clearFix;
  3833. exports.complement = complement;
  3834. exports.cover = cover;
  3835. exports.cssVar = cssVar;
  3836. exports.darken = curriedDarken$1;
  3837. exports.desaturate = curriedDesaturate$1;
  3838. exports.directionalProperty = directionalProperty;
  3839. exports.easeIn = easeIn;
  3840. exports.easeInOut = easeInOut;
  3841. exports.easeOut = easeOut;
  3842. exports.ellipsis = ellipsis;
  3843. exports.em = em$1;
  3844. exports.fluidRange = fluidRange;
  3845. exports.fontFace = fontFace;
  3846. exports.getContrast = getContrast;
  3847. exports.getLuminance = getLuminance;
  3848. exports.getValueAndUnit = getValueAndUnit;
  3849. exports.grayscale = grayscale;
  3850. exports.hiDPI = hiDPI;
  3851. exports.hideText = hideText;
  3852. exports.hideVisually = hideVisually;
  3853. exports.hsl = hsl;
  3854. exports.hslToColorString = hslToColorString;
  3855. exports.hsla = hsla;
  3856. exports.important = important;
  3857. exports.invert = invert;
  3858. exports.lighten = curriedLighten$1;
  3859. exports.linearGradient = linearGradient;
  3860. exports.margin = margin;
  3861. exports.math = math;
  3862. exports.meetsContrastGuidelines = meetsContrastGuidelines;
  3863. exports.mix = mix$1;
  3864. exports.modularScale = modularScale;
  3865. exports.normalize = normalize;
  3866. exports.opacify = curriedOpacify$1;
  3867. exports.padding = padding;
  3868. exports.parseToHsl = parseToHsl;
  3869. exports.parseToRgb = parseToRgb;
  3870. exports.position = position;
  3871. exports.radialGradient = radialGradient;
  3872. exports.readableColor = readableColor;
  3873. exports.rem = rem$1;
  3874. exports.remToPx = remToPx;
  3875. exports.retinaImage = retinaImage;
  3876. exports.rgb = rgb;
  3877. exports.rgbToColorString = rgbToColorString;
  3878. exports.rgba = rgba;
  3879. exports.saturate = curriedSaturate$1;
  3880. exports.setHue = curriedSetHue$1;
  3881. exports.setLightness = curriedSetLightness$1;
  3882. exports.setSaturation = curriedSetSaturation$1;
  3883. exports.shade = curriedShade$1;
  3884. exports.size = size;
  3885. exports.stripUnit = stripUnit;
  3886. exports.textInputs = textInputs;
  3887. exports.timingFunctions = timingFunctions;
  3888. exports.tint = curriedTint$1;
  3889. exports.toColorString = toColorString;
  3890. exports.transitions = transitions;
  3891. exports.transparentize = curriedTransparentize$1;
  3892. exports.triangle = triangle;
  3893. exports.wordWrap = wordWrap;