diff --git a/.babelrc b/.babelrc
index 7f0c374..567e658 100644
--- a/.babelrc
+++ b/.babelrc
@@ -1,7 +1,20 @@
{
- "presets": ["@babel/preset-react", "@babel/preset-env"],
- "plugins": [
- ["@babel/plugin-proposal-decorators", { "legacy": true }],
- "@babel/plugin-proposal-class-properties"
- ]
+ "presets": [
+ "@babel/preset-react",
+ [
+ "@babel/preset-env",
+ {
+ "useBuiltIns": "usage",
+ "corejs": "3.0.0",
+ "targets": {
+ "esmodules": true,
+ "ie": "11"
+ }
+ }
+ ]
+ ],
+ "plugins": [
+ ["@babel/plugin-proposal-decorators", { "legacy": true }],
+ "@babel/plugin-proposal-class-properties"
+ ]
}
diff --git a/.releaserc b/.releaserc
index b79db26..e6bc82c 100644
--- a/.releaserc
+++ b/.releaserc
@@ -1,6 +1,12 @@
{
"branch": "master",
"tagFormat": "${version}",
+ "analyzeCommits": {
+ "preset": "eslint",
+ "releaseRules": [
+ {"tag": "Upgrade", "release": "patch"}
+ ]
+ },
"verifyConditions": [
{
"path": "@semantic-release/changelog",
@@ -24,13 +30,5 @@
"commitsSort": ["subject", "scope"],
}
},
- "publish": ["@semantic-release/github", "@semantic-release/npm"],
- "plugins": [
- ["@semantic-release/commit-analyzer", {
- "preset": "eslint",
- "releaseRules": [
- {"tag": "Upgrade", "release": "patch"}
- ],
- }],
- ]
+ "publish": ["@semantic-release/github", "@semantic-release/npm"]
}
diff --git a/CHANGELOG.md b/CHANGELOG.md
index b577470..10c34d5 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,3 +1,71 @@
+## [4.3.3](https://github.com/FriendsOfReactJS/react-css-themr/compare/4.3.2...4.3.3) (2021-04-08)
+
+
+### Build
+
+* Release 4.3.1 [skip ci] ([fb5a9c0](https://github.com/FriendsOfReactJS/react-css-themr/commit/fb5a9c0014bb2d513efcb779d30ff7e2360c7e33))
+
+### Upgrade
+
+* Bump ini from 1.3.5 to 1.3.7 ([fdf15fc](https://github.com/FriendsOfReactJS/react-css-themr/commit/fdf15fc14359bf1af9300af9201bba574e87be6a))
+* Bump npm-user-validate from 1.0.0 to 1.0.1 ([e9293b7](https://github.com/FriendsOfReactJS/react-css-themr/commit/e9293b7a8808af9579f03823d7fe768078301c49))
+* Bump semantic-release from 17.1.1 to 17.2.3 ([71744de](https://github.com/FriendsOfReactJS/react-css-themr/commit/71744debdf842edabbc63385c875732ab40e98d7))
+* Bump y18n from 3.2.1 to 3.2.2 ([150df2a](https://github.com/FriendsOfReactJS/react-css-themr/commit/150df2a439b1632ce229a815e60387b4926c7a43))
+
+## [4.3.1](https://github.com/FriendsOfReactJS/react-css-themr/compare/4.3.0...4.3.1) (2020-07-22)
+
+
+### Build
+
+* Release 4.3.1 [skip ci] ([49ac3cd](https://github.com/FriendsOfReactJS/react-css-themr/commit/49ac3cd0e724381b840419e39dffdf32e417e6f1))
+
+### Fix
+
+* Name the default export for themr typings ([ddb4303](https://github.com/FriendsOfReactJS/react-css-themr/commit/ddb4303c7b76288d29eac097f68dfe7076d5f360)), closes [#74](https://github.com/FriendsOfReactJS/react-css-themr/issues/74)
+* Resolve linting issues ([4dbc02c](https://github.com/FriendsOfReactJS/react-css-themr/commit/4dbc02cb746138e58fbf3ed35f39aa25b9b6eb60))
+* Resolve typings for themr decorator ([1e20574](https://github.com/FriendsOfReactJS/react-css-themr/commit/1e2057483c3ddd550f055872b7499686766bc959)), closes [#74](https://github.com/FriendsOfReactJS/react-css-themr/issues/74)
+
+## [4.3.1](https://github.com/FriendsOfReactJS/react-css-themr/compare/4.3.0...4.3.1) (2020-07-22)
+
+
+### Fix
+
+* Name the default export for themr typings ([ddb4303](https://github.com/FriendsOfReactJS/react-css-themr/commit/ddb4303c7b76288d29eac097f68dfe7076d5f360)), closes [#74](https://github.com/FriendsOfReactJS/react-css-themr/issues/74)
+
+# [4.3.0](https://github.com/FriendsOfReactJS/react-css-themr/compare/4.2.1...4.3.0) (2020-07-22)
+
+
+### New
+
+* Add typescript as dev dependency and update types ([6fcd571](https://github.com/FriendsOfReactJS/react-css-themr/commit/6fcd571cc5211c4b91486b538c0ba494a1497af8)), closes [#74](https://github.com/FriendsOfReactJS/react-css-themr/issues/74)
+
+## [4.2.1](https://github.com/FriendsOfReactJS/react-css-themr/compare/4.2.0...4.2.1) (2020-07-22)
+
+
+### Upgrade
+
+* Update lodash and other packages for security reasons ([8d8e2ee](https://github.com/FriendsOfReactJS/react-css-themr/commit/8d8e2eed552a2a0647c4f3a96513560d1409afa9))
+* Updates commitizen related packages ([db26a79](https://github.com/FriendsOfReactJS/react-css-themr/commit/db26a79cbd09044f236d9541a80206801c81646d))
+* Upgrade semantic release dependencies ([cdc59bd](https://github.com/FriendsOfReactJS/react-css-themr/commit/cdc59bd74cd96e79cee6e6b5f48ba06190305b1f))
+
+# [4.1.0](https://github.com/FriendsOfReactJS/react-css-themr/compare/4.0.0...4.1.0) (2020-02-01)
+
+### Features
+
+* New: Support ref objects ([2e108210c754839bed5b7da7990955ba386eac19](https://github.com/FriendsOfReactJS/react-css-themr/commit/2e108210c754839bed5b7da7990955ba386eac19))
+* New: Move innerRef to the themr component ([c611918c068127a9a6f87b24dfb2c12fddbba56a](https://github.com/FriendsOfReactJS/react-css-themr/commit/c611918c068127a9a6f87b24dfb2c12fddbba56a))
+
+### Build
+
+* Fix: Pass nextProps into calcTheme. Current implementation uses current ... ([d04335e974a48a95a4cdc91be7ad9637e9f5bfec](https://github.com/FriendsOfReactJS/react-css-themr/commit/d04335e974a48a95a4cdc91be7ad9637e9f5bfec))
+
+
+### Docs
+
+* Docs: Replace twitter badge with dependency state ([e1846fdc26c72e434e93c2887c96ab46f05eeb8b](https://github.com/FriendsOfReactJS/react-css-themr/commit/e1846fdc26c72e434e93c2887c96ab46f05eeb8b))
+
+
+
# [4.0.0](https://github.com/FriendsOfReactJS/react-css-themr/compare/3.5.6...4.0.0) (2019-13-10)
### BREAKING
diff --git a/README.md b/README.md
index 6c0efff..bc0931c 100644
--- a/README.md
+++ b/README.md
@@ -8,18 +8,13 @@
-
-
-
-
-
-
+
diff --git a/index.d.ts b/index.d.ts
deleted file mode 100644
index ee355ae..0000000
--- a/index.d.ts
+++ /dev/null
@@ -1,40 +0,0 @@
-import * as React from "react";
-
-declare module "@friendsofreactjs/react-css-themr" {
- type TReactCSSThemrTheme = {
- [key: string]: string | TReactCSSThemrTheme
- }
- type TMapThemrProps
= (ownProps: P, theme: TReactCSSThemrTheme) => P & { theme: TReactCSSThemrTheme }
-
- export function themeable(...themes: Array): TReactCSSThemrTheme;
-
- export interface IThemrOptions {
- /** @default "deeply" */
- composeTheme?: "deeply" | "softly" | false,
- //currently there's no way to lift decorated component's generic type argument (P) to upper decorator
- //that's why just {}
- mapThemrProps?: TMapThemrProps<{}>
- }
-
- export interface ThemeProviderProps {
- innerRef?: Function,
- theme: TReactCSSThemrTheme
- }
-
- export class ThemeProvider extends React.Component {
- }
-
- interface ThemedComponent extends React.Component
{
- }
-
- interface ThemedComponentClass
extends React.ComponentClass
{
- new(props?: P, context?: any): ThemedComponent
;
- }
-
- export function themr(
- identifier: string | number | symbol,
- defaultTheme?: {},
- options?: IThemrOptions
- ):
(component: (new(props: P, context?: any) => React.Component
) | React.SFC
) =>
- ThemedComponentClass
}, S>;
-}
diff --git a/lib/components/ThemeProvider.js b/lib/components/ThemeProvider.js
index 0df650a..12beca8 100644
--- a/lib/components/ThemeProvider.js
+++ b/lib/components/ThemeProvider.js
@@ -33,9 +33,7 @@ function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || func
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
-var ThemeProvider =
-/*#__PURE__*/
-function (_Component) {
+var ThemeProvider = /*#__PURE__*/function (_Component) {
_inherits(ThemeProvider, _Component);
function ThemeProvider() {
diff --git a/lib/components/themr.js b/lib/components/themr.js
index 78d04c5..466e818 100644
--- a/lib/components/themr.js
+++ b/lib/components/themr.js
@@ -95,9 +95,7 @@ var _default = function _default(componentName, localTheme) {
* @property {{wrappedInstance: *}} refs
*/
- var Themed =
- /*#__PURE__*/
- function (_Component) {
+ var Themed = /*#__PURE__*/function (_Component) {
_inherits(Themed, _Component);
function Themed() {
@@ -196,7 +194,7 @@ var _default = function _default(componentName, localTheme) {
_defineProperty(Themed, "propTypes", _objectSpread({}, ThemedComponent.propTypes, {
composeTheme: _propTypes["default"].oneOf([COMPOSE_DEEPLY, COMPOSE_SOFTLY, DONT_COMPOSE]),
- innerRef: _propTypes["default"].func,
+ innerRef: _propTypes["default"].oneOfType([_propTypes["default"].func, _propTypes["default"].object]),
theme: _propTypes["default"].object,
themeNamespace: _propTypes["default"].string,
mapThemrProps: _propTypes["default"].func
diff --git a/package.json b/package.json
index d8a5507..a1b5bd4 100644
--- a/package.json
+++ b/package.json
@@ -2,7 +2,7 @@
"name": "@friendsofreactjs/react-css-themr",
"description": "Friends of ReactJS: React CSS Themr",
"homepage": "https://github.com/FriendsOfReactJS/react-css-themr#readme",
- "version": "4.0.0",
+ "version": "4.3.3",
"main": "./lib",
"author": "Javi Velasco (http://javivelasco.com/)",
"repository": {
@@ -35,13 +35,13 @@
"@babel/plugin-proposal-decorators": "^7.6.0",
"@babel/preset-env": "^7.6.3",
"@babel/preset-react": "^7.6.3",
- "@semantic-release/changelog": "^3.0.4",
- "@semantic-release/git": "^7.0.16",
- "@semantic-release/release-notes-generator": "^7.3.0",
+ "@semantic-release/changelog": "^5.0.1",
+ "@semantic-release/git": "^9.0.0",
+ "@semantic-release/release-notes-generator": "^9.0.1",
"@types/react": "^16.9.5",
"babel-eslint": "^10.0.3",
- "commitizen": "^4.0.3",
- "conventional-changelog-eslint": "^3.0.4",
+ "commitizen": "^4.1.2",
+ "conventional-changelog-eslint": "^3.0.8",
"cz-adapter-eslint": "^0.3.0",
"eslint": "^6.5.1",
"eslint-config-prettier": "^6.4.0",
@@ -54,12 +54,13 @@
"react": "^16.10.2",
"react-dom": "^16.10.2",
"rimraf": "^3.0.0",
- "semantic-release": "^15.13.24",
+ "semantic-release": "^17.1.1",
"sinon": "^7.5.0",
- "travis-deploy-once": "^5.0.11"
+ "travis-deploy-once": "^5.0.11",
+ "typescript": "^3.9.7"
},
"files": [
- "index.d.ts",
+ "types",
"lib",
"src"
],
@@ -78,7 +79,7 @@
"peerDependencies": {
"react": "^15.0.0-0 || ^16.0.0"
},
- "typings": "./index.d.ts",
+ "types": "./types/index.d.ts",
"directories": {
"lib": "lib",
"test": "test"
@@ -92,26 +93,6 @@
"path": "./node_modules/cz-adapter-eslint"
}
},
- "greenkeeper": {
- "commitMessages": {
- "initialBadge": "Docs: add Greenkeeper badge",
- "initialDependencies": "Upgrade: update dependencies",
- "initialBranches": "Update: whitelist greenkeeper branches",
- "dependencyUpdate": "Fix: update ${dependency} to version ${version}",
- "devDependencyUpdate": "Upgrade: update ${dependency} to version ${version}",
- "dependencyPin": "Update: pin ${dependency} to ${oldVersionResolved}",
- "devDependencyPin": "Update: pin ${dependency} to ${oldVersionResolved}",
- "closes": "\n\nCloses #${number}"
- },
- "prTitles": {
- "initialPR": "Update dependencies to enable Greenkeeper!!!",
- "initialPrBadge": "Add badge to enable Greenkeeper!!!!",
- "initialPrBadgeOnly": "Add Greenkeeper badge!!!",
- "initialSubgroupPR": "Update dependencies for ${group}!!!",
- "basicPR": "Update ${dependency} to the latest!!!",
- "groupPR": "Update ${dependency} in group ${group} to the latest!!!!"
- }
- },
"publishConfig": {
"access": "public"
}
diff --git a/src/components/themr.js b/src/components/themr.js
index c76c6f9..ed20d52 100644
--- a/src/components/themr.js
+++ b/src/components/themr.js
@@ -33,7 +33,7 @@ const THEMR_CONFIG =
* @param {{}} [options] - Themr options
* @returns {function(ThemedComponent:Function):Function} - ThemedComponent
*/
-export default (componentName, localTheme, options = {}) => ThemedComponent => {
+const themr = (componentName, localTheme, options = {}) => ThemedComponent => {
const {
composeTheme: optionComposeTheme,
mapThemrProps: optionMapThemrProps
@@ -70,7 +70,7 @@ export default (componentName, localTheme, options = {}) => ThemedComponent => {
COMPOSE_SOFTLY,
DONT_COMPOSE
]),
- innerRef: PropTypes.func,
+ innerRef: PropTypes.oneOfType([PropTypes.func, PropTypes.object]),
theme: PropTypes.object,
themeNamespace: PropTypes.string,
mapThemrProps: PropTypes.func
@@ -177,6 +177,7 @@ export default (componentName, localTheme, options = {}) => ThemedComponent => {
return hoistNonReactStatics(Themed, ThemedComponent)
}
+export default themr
/**
* Merges passed themes by concatenating string keys and processing nested themes
diff --git a/test/components/themr.spec.js b/test/components/themr.spec.js
index d8be201..20d4555 100644
--- a/test/components/themr.spec.js
+++ b/test/components/themr.spec.js
@@ -337,9 +337,10 @@ describe('Themr decorator function', () => {
}
const theme = {}
const DecoratedContainer = hoc(Container)
- const ThemedDecoratedContainer = themr('Container', theme)(
- DecoratedContainer
- )
+ const ThemedDecoratedContainer = themr(
+ 'Container',
+ theme
+ )(DecoratedContainer)
const tree = TestUtils.renderIntoDocument(
)
diff --git a/tsconfig.json b/tsconfig.json
new file mode 100644
index 0000000..271d62a
--- /dev/null
+++ b/tsconfig.json
@@ -0,0 +1,9 @@
+{
+ "include": ["src/**/*"],
+ "compilerOptions": {
+ "allowJs": true,
+ "declaration": true,
+ "emitDeclarationOnly": true,
+ "outDir": "lib",
+ },
+}
diff --git a/types/components/ThemeProvider.d.ts b/types/components/ThemeProvider.d.ts
new file mode 100644
index 0000000..fb33779
--- /dev/null
+++ b/types/components/ThemeProvider.d.ts
@@ -0,0 +1,23 @@
+export default class ThemeProvider extends Component {
+ static propTypes: {
+ children: PropTypes.Validator;
+ theme: PropTypes.Validator