polished.js 131 KB

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