UNPKG

3.59 kBSource Map (JSON)View Raw
1{"version":3,"sources":["../src/MediaQueries.ts"],"names":["MediaQueries","Breakpoints","validKeys","Interactions","breakpoints","interactions","_breakpoints","toRuleSets","_interactions","join","mediaQueryProps","onlyMatch","interaction","breakpointProps","shouldRenderMediaQuery","onlyMatchBreakpoints","sortedBreakpoints","dynamicResponsiveMediaQueries"],"mappings":";;;;;;;AAAA;;AACA;;AACA;;;;;;;;;;;;;;;;;;;;;;;;AAGA;;;;;IAKaA,Y;;;;;gCACQ;AACjB,gCAAWC,yBAAYC,SAAZ,EAAX,4BAAuCC,2BAAaD,SAAb,EAAvC;AACD;;;AAKD,wBACEE,WADF,EAEEC,YAFF,EAGE;AAAA;;AAAA;;AAAA;;AAAA;;AAAA,qCASe,YAAM;AACrB,aAAO,CACL;AACA,+CAFK,4BAGF,KAAI,CAACC,YAAL,CAAkBC,UAAlB,EAHE,sBAIF,KAAI,CAACC,aAAL,CAAmBD,UAAnB,EAJE,GAKLE,IALK,CAKA,IALA,CAAP;AAMD,KAhBC;;AACA,SAAKH,YAAL,GAAoB,IAAIL,wBAAJ,CAAgBG,WAAhB,CAApB;AACA,SAAKI,aAAL,GAAqB,IAAIL,0BAAJ,CAAiBE,YAAY,IAAI,EAAjC,CAArB;AACD;;;;2CA8BCK,e,EACAC,S,EACS;AAAA,UACDC,WADC,GACmCF,eADnC,CACDE,WADC;AAAA,UACeC,eADf,4BACmCH,eADnC;;AAET,UAAIE,WAAJ,EAAiB;AACf,eAAO,KAAKJ,aAAL,CAAmBM,sBAAnB,CAA0CF,WAA1C,EAAuDD,SAAvD,CAAP;AACD,OAJQ,CAKT;;;AACA,UAAMI,oBAAoB,GAAG,yBAC3BJ,SAD2B,EAE3B,KAAKL,YAAL,CAAkBU,iBAFS,CAA7B;AAIA,aAAO,KAAKV,YAAL,CAAkBQ,sBAAlB,CACLD,eADK,EAELE,oBAFK,CAAP;AAID;;;wBA5CwB;AACvB,aAAO,KAAKT,YAAZ;AACD;;;wBAW4B;AAC3B,gCACK,KAAKA,YAAL,CAAkBU,iBADvB,4BAEK,KAAKR,aAAL,CAAmBH,YAFxB;AAID;;;wBAE0C;AACzC,+BACK,KAAKC,YAAL,CAAkBW,6BADvB,EAEK,KAAKT,aAAL,CAAmBS,6BAFxB;AAID","sourcesContent":["import { Breakpoints } from \"./Breakpoints\"\nimport { Interactions } from \"./Interactions\"\nimport { intersection } from \"./Utils\"\nimport { MediaBreakpointProps } from \"./Media\"\n\n/**\n * Encapsulates all interaction data (and breakpoint data in the superclass)\n * needed by the Media component. The data is generated on initialization so no\n * further runtime work is necessary.\n */\nexport class MediaQueries<B extends string> {\n static validKeys() {\n return [...Breakpoints.validKeys(), ...Interactions.validKeys()]\n }\n\n private _breakpoints: Breakpoints<B>\n private _interactions: Interactions\n\n constructor(\n breakpoints: { [key: string]: number },\n interactions: { [name: string]: string }\n ) {\n this._breakpoints = new Breakpoints(breakpoints)\n this._interactions = new Interactions(interactions || {})\n }\n\n public get breakpoints() {\n return this._breakpoints\n }\n\n public toStyle = () => {\n return [\n // Don’t add any size to the layout\n \".fresnel-container{margin:0;padding:0;}\",\n ...this._breakpoints.toRuleSets(),\n ...this._interactions.toRuleSets(),\n ].join(\"\\n\")\n }\n\n public get mediaQueryTypes() {\n return [\n ...this._breakpoints.sortedBreakpoints,\n ...this._interactions.interactions,\n ]\n }\n\n public get dynamicResponsiveMediaQueries() {\n return {\n ...this._breakpoints.dynamicResponsiveMediaQueries,\n ...this._interactions.dynamicResponsiveMediaQueries,\n }\n }\n\n public shouldRenderMediaQuery(\n mediaQueryProps: { interaction?: string } & MediaBreakpointProps,\n onlyMatch: string[]\n ): boolean {\n const { interaction, ...breakpointProps } = mediaQueryProps\n if (interaction) {\n return this._interactions.shouldRenderMediaQuery(interaction, onlyMatch)\n }\n // Remove any interaction possibilities from the list.\n const onlyMatchBreakpoints = intersection(\n onlyMatch,\n this._breakpoints.sortedBreakpoints\n )\n return this._breakpoints.shouldRenderMediaQuery(\n breakpointProps,\n onlyMatchBreakpoints\n )\n }\n}\n"],"file":"MediaQueries.js"}
\No newline at end of file