polished.esm.js 121 KB

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