UNPKG

1.66 kBSource Map (JSON)View Raw
1{"version":3,"file":"warnMutuallyExclusive.js","sourceRoot":"../src/","sources":["warn/warnMutuallyExclusive.ts"],"names":[],"mappings":"AAAA,OAAO,EAAgB,IAAI,EAAE,MAAM,QAAQ,CAAC;AAC5C;;;;;;;GAOG;AACH,MAAM,UAAU,qBAAqB,CAAI,aAAqB,EAAE,KAAQ,EAAE,YAA6B;IACrG,IAAI,OAAO,CAAC,GAAG,CAAC,QAAQ,KAAK,YAAY,EAAE;QACzC,KAAK,IAAM,QAAQ,IAAI,YAAY,EAAE;YACnC,IAAI,KAAK,IAAI,KAAK,CAAC,QAAQ,CAAC,KAAK,SAAS,EAAE;gBAC1C,IAAI,uBAAuB,GAAG,YAAY,CAAC,QAAQ,CAAC,CAAC;gBACrD,IAAI,uBAAuB,IAAI,KAAK,CAAC,uBAAkC,CAAC,KAAK,SAAS,EAAE;oBACtF,IAAI,CACC,aAAa,mBAAc,QAAQ,sCAAiC,YAAY,CAAC,QAAQ,CAAC,QAAK;wBAChG,uBAAuB,CAC1B,CAAC;iBACH;aACF;SACF;KACF;AACH,CAAC","sourcesContent":["import { ISettingsMap, warn } from './warn';\n/**\n * Warns when two props which are mutually exclusive are both being used.\n *\n * @public\n * @param componentName - The name of the component being used.\n * @param props - The props passed into the component.\n * @param exclusiveMap - A map where the key is a parameter, and the value is the other parameter.\n */\nexport function warnMutuallyExclusive<P>(componentName: string, props: P, exclusiveMap: ISettingsMap<P>): void {\n if (process.env.NODE_ENV !== 'production') {\n for (const propName in exclusiveMap) {\n if (props && props[propName] !== undefined) {\n let propInExclusiveMapValue = exclusiveMap[propName];\n if (propInExclusiveMapValue && props[propInExclusiveMapValue as keyof P] !== undefined) {\n warn(\n `${componentName} property '${propName}' is mutually exclusive with '${exclusiveMap[propName]}'. ` +\n `Use one or the other.`,\n );\n }\n }\n }\n }\n}\n"]}
\No newline at end of file