UNPKG

2.9 kBSource Map (JSON)View Raw
1{"version":3,"sources":["index.js"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;AAIA,IAAI,oBAAoB,YAAA;IACpB,mBAAmB,YAAA;IACnB,gBAAgB,YAAA;;;;;;;;AAAC,AAQrB,gBAAgB,GAAG,UAAC,SAAS,EAAK;AAC9B,WAAO,WAAW,IAAI,SAAS,IAAI,0BAAa,SAAS,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC;CAC/E;;;;;;;;;;AAAC,AAUF,mBAAmB,GAAG,UAAC,SAAS,EAAE,aAAa,EAAE,OAAO,EAAK;AACzD,QAAI,cAAc,YAAA,CAAC;;AAEnB,QAAI,gBAAgB,CAAC,SAAS,CAAC,EAAE;AAC7B,sBAAc,GAAG,gCAAiB,SAAS,EAAE,aAAa,EAAE,OAAO,CAAC,CAAC;KACxE,MAAM;AACH,sBAAc,GAAG,qCAAsB,SAAS,EAAE,aAAa,EAAE,OAAO,CAAC,CAAC;KAC7E;;AAED,QAAI,SAAS,CAAC,WAAW,EAAE;AACvB,sBAAc,CAAC,WAAW,GAAG,SAAS,CAAC,WAAW,CAAC;KACtD,MAAM;AACH,sBAAc,CAAC,WAAW,GAAG,SAAS,CAAC,IAAI,CAAC;KAC/C;;AAED,WAAO,cAAc,CAAC;CACzB;;;;;;;;;AAAC,AASF,oBAAoB,GAAG,UAAC,aAAa,EAAE,OAAO,EAAK;AAC/C,WAAO,UAAC,SAAS,EAAK;AAClB,eAAO,mBAAmB,CAAC,SAAS,EAAE,aAAa,EAAE,OAAO,CAAC,CAAC;KACjE,CAAC;CACL,CAAC;;kBAEa,YAAa;AACxB,QAAI,2EAAqB,EAAE;AACvB,eAAO,mBAAmB,sJAA2B,CAAC;KACzD,MAAM;AACH,eAAO,oBAAoB,oGAAkB,CAAC;KACjD;CACJ","file":"index.js","sourcesContent":["import _ from 'lodash';\nimport extendReactClass from './extendReactClass';\nimport wrapStatelessFunction from './wrapStatelessFunction';\n\nlet decoratorConstructor,\n functionConstructor,\n isReactComponent;\n\n/**\n * Determines if the given object has the signature of a class that inherits React.Component.\n *\n * @param {*} Component\n * @returns {boolean}\n */\nisReactComponent = (Component) => {\n return 'prototype' in Component && _.isFunction(Component.prototype.render);\n};\n\n/**\n * When used as a function.\n *\n * @param {Function} Component\n * @param {Object} defaultStyles CSS Modules class map.\n * @param {Object} options {@link https://github.com/gajus/react-css-modules#options}\n * @returns {Function}\n */\nfunctionConstructor = (Component, defaultStyles, options) => {\n let decoratedClass;\n\n if (isReactComponent(Component)) {\n decoratedClass = extendReactClass(Component, defaultStyles, options);\n } else {\n decoratedClass = wrapStatelessFunction(Component, defaultStyles, options);\n }\n\n if (Component.displayName) {\n decoratedClass.displayName = Component.displayName;\n } else {\n decoratedClass.displayName = Component.name;\n }\n\n return decoratedClass;\n};\n\n/**\n * When used as a ES7 decorator.\n *\n * @param {Object} defaultStyles CSS Modules class map.\n * @param {Object} options {@link https://github.com/gajus/react-css-modules#options}\n * @returns {Function}\n */\ndecoratorConstructor = (defaultStyles, options) => {\n return (Component) => {\n return functionConstructor(Component, defaultStyles, options);\n };\n};\n\nexport default (...args) => {\n if (_.isFunction(args[0])) {\n return functionConstructor(args[0], args[1], args[2]);\n } else {\n return decoratorConstructor(args[0], args[1]);\n }\n};\n"],"sourceRoot":"/source/"}
\No newline at end of file