@casl/react
Advanced tools
Comparing version 2.1.0 to 2.1.1
@@ -5,2 +5,9 @@ # Change Log | ||
## [2.1.1](https://github.com/stalniy/casl/compare/@casl/react@2.1.0...@casl/react@2.1.1) (2020-06-09) | ||
### Bug Fixes | ||
* **docs:** ensure README and docs for all packages are in sync ([8df3684](https://github.com/stalniy/casl/commit/8df3684b139de0af60c9c37f284a5028ffbf2224)), closes [#338](https://github.com/stalniy/casl/issues/338) | ||
# [2.1.0](https://github.com/stalniy/casl/compare/@casl/react@2.0.2...@casl/react@2.1.0) (2020-04-18) | ||
@@ -7,0 +14,0 @@ |
@@ -1,2 +0,2 @@ | ||
import t,{Fragment as n,createElement as i,Children as s,PureComponent as e}from"react";const r=()=>{},o=n?t=>t?t.length>1?i(n,null,...t):s.only(t):null:s.only;class u extends e{constructor(...t){super(...t),this.t=!1,this.i=null,this.s=r}componentWillUnmount(){this.s()}o(t){t!==this.i&&(this.s(),this.i=null,t&&(this.i=t,this.s=t.on("updated",()=>this.forceUpdate())))}get allowed(){return this.t}u(){const t=this.props,n=t.of||t.a||t.an||t.this||t.on,i=t.not?"cannot":"can";return t.ability[i](t.I||t.do,n,t.field)}render(){return this.o(this.props.ability),this.t=this.u(),this.props.passThrough||this.t?this.l():null}l(){const{children:t,ability:n}=this.props,i="function"==typeof t?t(this.t,n):t;return o(i)}}function l(t){var n,i;return i=n=class extends u{},n.defaultProps={ability:t},i}function c(t){return n=>i(t,null,t=>i(u,{ability:t,...n}))}function h(n){if("production"!==process.env.NODE_ENV&&"function"!=typeof t.useContext)throw new Error("You must use React >= 16.8 in order to use useAbility()");const i=t.useContext(n),[s,e]=t.useState();return t.useEffect(()=>i.on("updated",t=>{t.rules!==s&&e(t.rules)}),[]),i}export{u as Can,l as createCanBoundTo,c as createContextualCan,h as useAbility}; | ||
import t,{Fragment as n,createElement as i,Children as s,PureComponent as e}from"react";const r=()=>{},o=n?t=>t?t.length>1?i(n,null,...t):s.only(t):null:s.only;class u extends e{constructor(...t){super(...t),this.t=!1,this.i=null,this.s=r}componentWillUnmount(){this.s()}o(t){t!==this.i&&(this.s(),this.i=null,t&&(this.i=t,this.s=t.on("updated",()=>this.forceUpdate())))}get allowed(){return this.t}u(){const t=this.props,n=t.of||t.a||t.an||t.this||t.on,i=t.not?"cannot":"can";return t.ability[i](t.I||t.do,n,t.field)}render(){return this.o(this.props.ability),this.t=this.u(),this.props.passThrough||this.t?this.l():null}l(){const{children:t,ability:n}=this.props,i="function"==typeof t?t(this.t,n):t;return o(i)}}function c(t){var n,i;return i=n=class extends u{},n.defaultProps={ability:t},i}function l(t){return n=>i(t,null,t=>i(u,Object.assign({ability:t},n)))}function h(n){if("production"!==process.env.NODE_ENV&&"function"!=typeof t.useContext)throw new Error("You must use React >= 16.8 in order to use useAbility()");const i=t.useContext(n),[s,e]=t.useState();return t.useEffect(()=>i.on("updated",t=>{t.rules!==s&&e(t.rules)}),[]),i}export{u as Can,c as createCanBoundTo,l as createContextualCan,h as useAbility}; | ||
//# sourceMappingURL=index.js.map |
{ | ||
"name": "@casl/react", | ||
"version": "2.1.0", | ||
"version": "2.1.1", | ||
"description": "React component for CASL which makes it easy to add permissions in any React application", | ||
@@ -18,7 +18,7 @@ "main": "dist/umd/index.js", | ||
"prebuild": "npm run build.types", | ||
"build": "rollup -c ../../tools/rollup.config.js -n casl.react -g react:React,prop-types:React.PropTypes,@casl/ability:casl", | ||
"build": "rollup -c ../../rollup.config.js -n casl.react -g react:React,prop-types:React.PropTypes,@casl/ability:casl", | ||
"build.types": "rm -rf dist/types/* && tsc", | ||
"lint": "eslint --ext .ts,.js src/ spec/", | ||
"test": "NODE_ENV=test jest --config ../../tools/jest.config.js", | ||
"prerelease": "npm test && NODE_ENV=production npm run build", | ||
"prerelease": "npm run lint && npm test && NODE_ENV=production npm run build", | ||
"release": "semantic-release -e ../../tools/semantic-release" | ||
@@ -46,7 +46,30 @@ }, | ||
"devDependencies": { | ||
"@babel/core": "^7.8.4", | ||
"@babel/plugin-proposal-class-properties": "^7.8.3", | ||
"@babel/plugin-proposal-object-rest-spread": "^7.10.0", | ||
"@babel/plugin-transform-typescript": "^7.10.0", | ||
"@babel/preset-env": "^7.8.4", | ||
"@casl/ability": "^4.0.0", | ||
"@rollup/plugin-babel": "^5.0.2", | ||
"@rollup/plugin-node-resolve": "^8.0.0", | ||
"@semantic-release/changelog": "^3.0.0", | ||
"@semantic-release/git": "^7.0.0", | ||
"@testing-library/react-hooks": "^3.2.1", | ||
"@types/node": "^14.0.5", | ||
"@types/react": "^16.9.19", | ||
"@typescript-eslint/eslint-plugin": "2.24.0", | ||
"babel-jest": "^26.0.0", | ||
"chai": "^4.1.0", | ||
"chai-spies": "^1.0.0", | ||
"eslint": "^7.1.0", | ||
"eslint-config-airbnb-base": "^14.1.0", | ||
"eslint-config-airbnb-typescript": "^7.2.1", | ||
"eslint-plugin-import": "^2.20.2", | ||
"jest": "^26.0.0", | ||
"react": "^16.3.0", | ||
"react-test-renderer": "^16.3.0" | ||
"react-test-renderer": "^16.3.0", | ||
"rollup": "^2.10.9", | ||
"rollup-plugin-terser": "^6.1.0", | ||
"semantic-release": "15.9.17", | ||
"typescript": "~3.8.0" | ||
}, | ||
@@ -53,0 +76,0 @@ "files": [ |
@@ -1,3 +0,7 @@ | ||
# CASL React [![@casl/react NPM version](https://badge.fury.io/js/%40casl%2Freact.svg)](https://badge.fury.io/js/%40casl%2Freact) [![](https://img.shields.io/npm/dm/%40casl%2Freact.svg)](https://www.npmjs.com/package/%40casl%2Freact) [![CASL Documentation](https://img.shields.io/badge/documentation-available-brightgreen.svg)](https://stalniy.github.io/casl/) [![CASL Join the chat](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/stalniy-casl/casl) | ||
# CASL React | ||
[![@casl/react NPM version](https://badge.fury.io/js/%40casl%2Freact.svg)](https://badge.fury.io/js/%40casl%2Freact) | ||
[![](https://img.shields.io/npm/dm/%40casl%2Freact.svg)](https://www.npmjs.com/package/%40casl%2Freact) | ||
[![CASL Join the chat](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/stalniy-casl/casl) | ||
This package allows to integrate `@casl/ability` with [React] application. It provides `Can` component that allow to hide or show UI elements based on user ability to see them. | ||
@@ -111,3 +115,3 @@ | ||
> See [CASL guide](../../guide/intro) to learn how to define `Ability` instance. | ||
> See [CASL guide](https://stalniy.github.io/casl/v4/en/guide/intro) to learn how to define `Ability` instance. | ||
@@ -300,3 +304,3 @@ and use our `Can` component: | ||
> See [Define rules](../../guide/define-rules) to get more information of how to define `Ability` | ||
> See [Define rules](https://stalniy.github.io/casl/v4/en/guide/define-rules) to get more information of how to define `Ability` | ||
@@ -309,3 +313,3 @@ ## Want to help? | ||
> See [Support CASL](../../support-casljs) for details | ||
> See [Support CASL](https://stalniy.github.io/casl/v4/en/support-casljs) for details | ||
@@ -312,0 +316,0 @@ ## License |
Sorry, the diff of this file is not supported yet
49994
320
28