polished.js 132 KB

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