bloc-react
Advanced tools
Comparing version 0.1.16 to 0.1.17
@@ -1,2 +0,2 @@ | ||
import { ReactElement } from 'react'; | ||
import React, { ReactElement } from 'react'; | ||
@@ -161,4 +161,5 @@ declare type ValueType<T extends BlocBase<any>> = T extends BlocBase<infer U> ? U : never; | ||
}): ReactElement; | ||
withBlocProvider: <P extends {}>(bloc: BlocBase<any> | ((id: string) => BlocBase<any>)) => (Component: React.ComponentType<P>) => React.FC<P>; | ||
} | ||
export { Bloc, BlocObserver, BlocReact, Cubit }; |
@@ -436,2 +436,20 @@ import React, { useMemo, useContext, useState, useCallback, useEffect } from 'react'; | ||
}; | ||
this.withBlocProvider = (bloc) => (Component) => { | ||
const displayName = Component.displayName || Component.name || "Component"; | ||
const Provider = (props) => { | ||
return /* @__PURE__ */ React.createElement(this.BlocProvider, { | ||
bloc | ||
}, props.children); | ||
}; | ||
Provider.displayName = `withBlocProvider`; | ||
const Wrapper = (props) => { | ||
return /* @__PURE__ */ React.createElement(Provider, { | ||
bloc | ||
}, /* @__PURE__ */ React.createElement(Component, { | ||
...props | ||
})); | ||
}; | ||
Wrapper.displayName = `withBlocProvider(${displayName})`; | ||
return Wrapper; | ||
}; | ||
this._blocsGlobal = blocs; | ||
@@ -438,0 +456,0 @@ this.BlocProvider = this.BlocProvider.bind(this); |
@@ -444,2 +444,20 @@ 'use strict'; | ||
}; | ||
this.withBlocProvider = (bloc) => (Component) => { | ||
const displayName = Component.displayName || Component.name || "Component"; | ||
const Provider = (props) => { | ||
return /* @__PURE__ */ React__default['default'].createElement(this.BlocProvider, { | ||
bloc | ||
}, props.children); | ||
}; | ||
Provider.displayName = `withBlocProvider`; | ||
const Wrapper = (props) => { | ||
return /* @__PURE__ */ React__default['default'].createElement(Provider, { | ||
bloc | ||
}, /* @__PURE__ */ React__default['default'].createElement(Component, { | ||
...props | ||
})); | ||
}; | ||
Wrapper.displayName = `withBlocProvider(${displayName})`; | ||
return Wrapper; | ||
}; | ||
this._blocsGlobal = blocs; | ||
@@ -446,0 +464,0 @@ this.BlocProvider = this.BlocProvider.bind(this); |
{ | ||
"name": "bloc-react", | ||
"version": "0.1.16", | ||
"version": "0.1.17", | ||
"license": "MIT", | ||
@@ -27,4 +27,4 @@ "main": "dist/bloc-react.js", | ||
"devDependencies": { | ||
"@babel/core": "^7.14.5", | ||
"@babel/preset-env": "^7.14.5", | ||
"@babel/core": "^7.14.6", | ||
"@babel/preset-env": "^7.14.7", | ||
"@babel/preset-react": "^7.14.5", | ||
@@ -37,3 +37,3 @@ "@babel/preset-typescript": "^7.14.5", | ||
"@rollup/plugin-node-resolve": "^13.0.0", | ||
"@testing-library/react": "^11.2.7", | ||
"@testing-library/react": "^12.0.0", | ||
"@testing-library/react-hooks": "^7.0.0", | ||
@@ -45,12 +45,12 @@ "@types/chrome": "^0.0.145", | ||
"@types/react": "^17.0.11", | ||
"@types/react-dom": "^17.0.7", | ||
"@types/react-dom": "^17.0.8", | ||
"@types/react-router-dom": "^5.1.7", | ||
"@typescript-eslint/eslint-plugin": "^4.26.1", | ||
"@typescript-eslint/parser": "^4.26.1", | ||
"@vitejs/plugin-react-refresh": "^1.3.3", | ||
"@typescript-eslint/eslint-plugin": "^4.28.1", | ||
"@typescript-eslint/parser": "^4.28.1", | ||
"@vitejs/plugin-react-refresh": "^1.3.4", | ||
"@wojtekmaj/enzyme-adapter-react-17": "^0.6.2", | ||
"codecov": "^3.8.2", | ||
"enzyme": "^3.11.0", | ||
"esbuild": "^0.12.8", | ||
"eslint": "^7.28.0", | ||
"esbuild": "^0.12.12", | ||
"eslint": "^7.29.0", | ||
"eslint-config-prettier": "^8.3.0", | ||
@@ -67,7 +67,7 @@ "eslint-config-standard": "^16.0.3", | ||
"jest-mock-console": "^1.1.0", | ||
"prettier": "^2.3.1", | ||
"prettier": "^2.3.2", | ||
"react": "^17.0.2", | ||
"react-dom": "^17.0.2", | ||
"react-router-dom": "^5.2.0", | ||
"rollup": "^2.51.2", | ||
"rollup": "^2.52.4", | ||
"rollup-plugin-babel": "^4.4.0", | ||
@@ -81,4 +81,4 @@ "rollup-plugin-commonjs": "^10.1.0", | ||
"ts-jest": "^26.5.6", | ||
"typescript": "^4.3.2", | ||
"vite": "^2.3.7" | ||
"typescript": "^4.3.4", | ||
"vite": "^2.3.8" | ||
}, | ||
@@ -85,0 +85,0 @@ "jest": { |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
109628
1130