UNPKG

2.14 kBSource Map (JSON)View Raw
1{"version":3,"file":"concatStyleSetsWithProps.js","sourceRoot":"../src/","sources":["concatStyleSetsWithProps.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AAKpD;;;;GAIG;AACH,MAAM,UAAU,wBAAwB,CACtC,UAAuB;IACvB,mBAA4E;SAA5E,UAA4E,EAA5E,qBAA4E,EAA5E,IAA4E;QAA5E,kCAA4E;;IAE5E,IAAM,MAAM,GAA6B,EAAE,CAAC;IAC5C,KAAqB,UAAS,EAAT,uBAAS,EAAT,uBAAS,EAAT,IAAS,EAAE;QAA3B,IAAM,MAAM,kBAAA;QACf,IAAI,MAAM,EAAE;YACV,MAAM,CAAC,IAAI,CAAC,OAAO,MAAM,KAAK,UAAU,CAAC,CAAC,CAAC,MAAM,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC;SACzE;KACF;IACD,IAAI,MAAM,CAAC,MAAM,KAAK,CAAC,EAAE;QACvB,OAAO,MAAM,CAAC,CAAC,CAA2B,CAAC;KAC5C;SAAM,IAAI,MAAM,CAAC,MAAM,EAAE;QACxB,mEAAmE;QACnE,2DAA2D;QAC3D,yGAAyG;QACzG,yBAAyB;QACzB,OAAO,eAAe,eAAK,MAAc,CAAQ,CAAC;KACnD;IAED,OAAO,EAAE,CAAC;AACZ,CAAC","sourcesContent":["import { concatStyleSets } from './concatStyleSets';\nimport { IStyleSet } from './IStyleSet';\nimport { IStyleFunctionOrObject } from './IStyleFunction';\nimport { DeepPartial } from './DeepPartial';\n\n/**\n * Concatenates style sets into one, but resolves functional sets using the given props.\n * @param styleProps - Props used to resolve functional sets.\n * @param allStyles - Style sets, which can be functions or objects.\n */\nexport function concatStyleSetsWithProps<TStyleProps, TStyleSet extends IStyleSet<TStyleSet>>(\n styleProps: TStyleProps,\n ...allStyles: (IStyleFunctionOrObject<TStyleProps, TStyleSet> | undefined)[]\n): DeepPartial<TStyleSet> {\n const result: DeepPartial<TStyleSet>[] = [];\n for (const styles of allStyles) {\n if (styles) {\n result.push(typeof styles === 'function' ? styles(styleProps) : styles);\n }\n }\n if (result.length === 1) {\n return result[0] as DeepPartial<TStyleSet>;\n } else if (result.length) {\n // cliffkoh: I cannot figure out how to avoid the cast to any here.\n // It is something to do with the use of Omit in IStyleSet.\n // It might not be necessary once Omit becomes part of lib.d.ts (when we remove our own Omit and rely on\n // the official version).\n return concatStyleSets(...(result as any)) as any;\n }\n\n return {};\n}\n"]}
\No newline at end of file