@casl/react 2.3.0 → 3.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/es5m/index.js +1 -1
- package/dist/es5m/index.js.map +1 -1
- package/dist/es6m/index.mjs +1 -1
- package/dist/es6m/index.mjs.map +1 -1
- package/dist/types/Can.d.ts +4 -2
- package/dist/types/factory.d.ts +2 -2
- package/dist/umd/index.js +1 -1
- package/dist/umd/index.js.map +1 -1
- package/package.json +7 -6
- package/CHANGELOG.md +0 -285
package/dist/es5m/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import t,{
|
|
1
|
+
import t,{PureComponent as n,createElement as r}from"react";function i(t,n){for(var r=0;r<n.length;r++){var i=n[r];i.enumerable=i.enumerable||false;i.configurable=true;if("value"in i)i.writable=true;Object.defineProperty(t,i.key,i)}}function u(t,n,r){if(n)i(t.prototype,n);if(r)i(t,r);return t}function e(){e=Object.assign||function(t){for(var n=1;n<arguments.length;n++){var r=arguments[n];for(var i in r)if(Object.prototype.hasOwnProperty.call(r,i))t[i]=r[i]}return t};return e.apply(this,arguments)}function o(t,n){t.prototype=Object.create(n.prototype);t.prototype.constructor=t;f(t,n)}function f(t,n){f=Object.setPrototypeOf||function t(n,r){n.__proto__=r;return n};return f(t,n)}var c=function t(){};var s=function(t){o(n,t);function n(){var n;for(var r=arguments.length,i=new Array(r),u=0;u<r;u++)i[u]=arguments[u];n=t.call.apply(t,[this].concat(i))||this;n.t=false;n.i=null;n.u=c;return n}var r=n.prototype;r.componentWillUnmount=function t(){this.u()};r.o=function _connectToAbility(t){var n=this;if(t===this.i)return;this.u();this.i=null;if(t){this.i=t;this.u=t.on("updated",(function(){return n.forceUpdate()}))}};r.h=function t(){var n=this.props;var r=n.of||n.a||n.an||n.this||n.on;var i=n.not?"cannot":"can";return n.ability[i](n.I||n.do,r,n.field)};r.render=function t(){this.o(this.props.ability);this.t=this.h();return this.props.passThrough||this.t?this.v():null};r.v=function t(){var n=this.props,r=n.children,i=n.ability;var u="function"===typeof r?r(this.t,i):r;return u};u(n,[{key:"allowed",get:function t(){return this.t}}]);return n}(n);function a(t){var n,r;return r=n=function(t){o(n,t);function n(){return t.apply(this,arguments)||this}return n}(s),n.defaultProps={ability:t},r}function h(t){return function(n){return r(t,{children:function t(i){return r(s,e({ability:i},n))}})}}function useAbility(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()");var r=t.useContext(n);var i=t.useState(),u=i[0],e=i[1];t.useEffect((function(){return r.on("updated",(function(t){if(t.rules!==u)e(t.rules)}))}),[]);return r}export{s as Can,a as createCanBoundTo,h as createContextualCan,useAbility};
|
|
2
2
|
//# sourceMappingURL=index.js.map
|
package/dist/es5m/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":["../../src/Can.ts","../../src/factory.ts","../../src/hooks/useAbility.ts"],"sourcesContent":["import {
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../../src/Can.ts","../../src/factory.ts","../../src/hooks/useAbility.ts"],"sourcesContent":["import { PureComponent, ReactNode } from 'react';\nimport {\n Unsubscribe,\n AbilityTuple,\n SubjectType,\n AnyAbility,\n Generics,\n Abilities,\n IfString,\n} from '@casl/ability';\n\nconst noop = () => {};\n\ntype AbilityCanProps<\n T extends Abilities,\n Else = IfString<T, { do: T } | { I: T }>\n> = T extends AbilityTuple\n ? { do: T[0], on: T[1], field?: string } |\n { I: T[0], a: Extract<T[1], SubjectType>, field?: string } |\n { I: T[0], an: Extract<T[1], SubjectType>, field?: string } |\n { I: T[0], this: Exclude<T[1], SubjectType>, field?: string }\n : Else;\n\ninterface ExtraProps {\n not?: boolean\n passThrough?: boolean\n}\n\ninterface CanExtraProps<T extends AnyAbility> extends ExtraProps {\n ability: T\n children: ReactNode | ((isAllowed: boolean, ability: T) => ReactNode)\n}\n\ninterface BoundCanExtraProps<T extends AnyAbility> extends ExtraProps {\n ability?: T\n children: ReactNode | ((isAllowed: boolean, ability: T) => ReactNode)\n}\n\nexport type CanProps<T extends AnyAbility> =\n AbilityCanProps<Generics<T>['abilities']> & CanExtraProps<T>;\nexport type BoundCanProps<T extends AnyAbility> =\n AbilityCanProps<Generics<T>['abilities']> & BoundCanExtraProps<T>;\n\nexport class Can<\n T extends AnyAbility,\n IsBound extends boolean = false\n> extends PureComponent<IsBound extends true ? BoundCanProps<T> : CanProps<T>> {\n private _isAllowed: boolean = false;\n private _ability: T | null = null;\n private _unsubscribeFromAbility: Unsubscribe = noop;\n\n componentWillUnmount() {\n this._unsubscribeFromAbility();\n }\n\n private _connectToAbility(ability?: T) {\n if (ability === this._ability) {\n return;\n }\n\n this._unsubscribeFromAbility();\n this._ability = null;\n\n if (ability) {\n this._ability = ability;\n this._unsubscribeFromAbility = ability.on('updated', () => this.forceUpdate());\n }\n }\n\n get allowed() {\n return this._isAllowed;\n }\n\n private _canRender(): boolean {\n const props: any = this.props;\n const subject = props.of || props.a || props.an || props.this || props.on;\n const can = props.not ? 'cannot' : 'can';\n\n return props.ability[can](props.I || props.do, subject, props.field);\n }\n\n render() {\n this._connectToAbility(this.props.ability);\n this._isAllowed = this._canRender();\n return this.props.passThrough || this._isAllowed ? this._renderChildren() : null;\n }\n\n private _renderChildren() {\n const { children, ability } = this.props;\n const elements = typeof children === 'function'\n ? children(this._isAllowed, ability as any)\n : children;\n\n return elements as ReactNode;\n }\n}\n","import { createElement as h, ComponentClass, Consumer, FunctionComponent } from 'react';\nimport { AnyAbility } from '@casl/ability';\nimport { Can, BoundCanProps } from './Can';\n\ninterface BoundCanClass<T extends AnyAbility> extends ComponentClass<BoundCanProps<T>> {\n new (props: BoundCanProps<T>, context?: any): Can<T, true>\n}\n\nexport function createCanBoundTo<T extends AnyAbility>(ability: T): BoundCanClass<T> {\n return class extends Can<T, true> {\n static defaultProps = { ability } as BoundCanClass<T>['defaultProps'];\n };\n}\n\nexport function createContextualCan<T extends AnyAbility>(\n Getter: Consumer<T>\n): FunctionComponent<BoundCanProps<T>> {\n return (props: BoundCanProps<T>) => h(Getter, {\n children: (ability: T) => h(Can, {\n ability,\n ...props,\n } as any)\n });\n}\n","import React from 'react';\nimport { AnyAbility } from '@casl/ability';\n\nexport function useAbility<T extends AnyAbility>(context: React.Context<T>): T {\n if (process.env.NODE_ENV !== 'production' && typeof React.useContext !== 'function') {\n /* istanbul ignore next */\n throw new Error('You must use React >= 16.8 in order to use useAbility()');\n }\n\n const ability = React.useContext<T>(context);\n const [rules, setRules] = React.useState<T['rules']>();\n\n React.useEffect(() => ability.on('updated', (event) => {\n if (event.rules !== rules) {\n setRules(event.rules);\n }\n }), []);\n\n return ability;\n}\n"],"names":["noop","Can","_isAllowed","_ability","_unsubscribeFromAbility","componentWillUnmount","_connectToAbility","ability","this","on","_this2","forceUpdate","_canRender","props","subject","of","a","an","can","not","I","do","field","render","passThrough","_renderChildren","children","elements","PureComponent","createCanBoundTo","defaultProps","createContextualCan","Getter","h","useAbility","context","process","env","NODE_ENV","React","useContext","Error","useState","rules","setRules","useEffect","event"],"mappings":"6qBAWA,IAAMA,EAAO,SAAPA,UAgCOC,2JAIHC,EAAsB,QACtBC,EAAqB,OACrBC,EAAuCJ,+BAE/CK,qBAAA,kBACOD,OAGCE,EAAR,2BAA0BC,iBACpBA,IAAYC,KAAKL,cAIhBC,SACAD,EAAW,QAEZI,EAAS,MACNJ,EAAWI,OACXH,EAA0BG,EAAQE,GAAG,WAAW,kBAAMC,EAAKC,qBAQ5DC,EAAR,iBACQC,EAAaL,KAAKK,UAClBC,EAAUD,EAAME,IAAMF,EAAMG,GAAKH,EAAMI,IAAMJ,EAAML,MAAQK,EAAMJ,OACjES,EAAML,EAAMM,IAAM,SAAW,aAE5BN,EAAMN,QAAQW,GAAKL,EAAMO,GAAKP,EAAMQ,GAAIP,EAASD,EAAMS,UAGhEC,OAAA,kBACOjB,EAAkBE,KAAKK,MAAMN,cAC7BL,EAAaM,KAAKI,WAChBJ,KAAKK,MAAMW,aAAehB,KAAKN,EAAaM,KAAKiB,IAAoB,QAGtEA,EAAR,mBACgCjB,KAAKK,MAA3Ba,IAAAA,SAAUnB,IAAAA,YACZoB,EAA+B,oBAAbD,EACpBA,EAASlB,KAAKN,EAAYK,GAC1BmB,SAEGC,2BAxBT,oBACSnB,KAAKN,gBAxBN0B,GCtCH,SAASC,EAAuCtB,qGAChCN,KACZ6B,aAAe,CAAEvB,QAAAA,KAIrB,SAASwB,EACdC,UAEO,SAACnB,UAA4BoB,EAAED,EAAQ,CAC5CN,SAAU,WAACnB,UAAe0B,EAAEhC,KAC1BM,QAAAA,GACGM,QCjBF,SAASqB,WAAiCC,MAClB,eAAzBC,QAAQC,IAAIC,UAAyD,oBAArBC,EAAMC,iBAElD,IAAIC,MAAM,+DAGZlC,EAAUgC,EAAMC,WAAcL,SACVI,EAAMG,WAAzBC,OAAOC,OAEdL,EAAMM,WAAU,kBAAMtC,EAAQE,GAAG,WAAW,SAACqC,MACvCA,EAAMH,QAAUA,EAClBC,EAASE,EAAMH,YAEf,WAEGpC"}
|
package/dist/es6m/index.mjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import t,{
|
|
1
|
+
import t,{PureComponent as i,createElement as n}from"react";const s=()=>{};class e extends i{constructor(...t){super(...t);this.t=false;this.i=null;this.o=s}componentWillUnmount(){this.o()}u(t){if(t===this.i)return;this.o();this.i=null;if(t){this.i=t;this.o=t.on("updated",(()=>this.forceUpdate()))}}get allowed(){return this.t}h(){const t=this.props;const i=t.of||t.a||t.an||t.this||t.on;const n=t.not?"cannot":"can";return t.ability[n](t.I||t.do,i,t.field)}render(){this.u(this.props.ability);this.t=this.h();return this.props.passThrough||this.t?this.l():null}l(){const{children:t,ability:i}=this.props;const n="function"===typeof t?t(this.t,i):t;return n}}function r(t){var i,n;return n=i=class extends e{},i.defaultProps={ability:t},n}function o(t){return i=>n(t,{children:t=>n(e,Object.assign({ability:t},i))})}function useAbility(i){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 n=t.useContext(i);const[s,e]=t.useState();t.useEffect((()=>n.on("updated",(t=>{if(t.rules!==s)e(t.rules)}))),[]);return n}export{e as Can,r as createCanBoundTo,o as createContextualCan,useAbility};
|
|
2
2
|
//# sourceMappingURL=index.mjs.map
|
package/dist/es6m/index.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.mjs","sources":["../../src/Can.ts","../../src/factory.ts","../../src/hooks/useAbility.ts"],"sourcesContent":["import {
|
|
1
|
+
{"version":3,"file":"index.mjs","sources":["../../src/Can.ts","../../src/factory.ts","../../src/hooks/useAbility.ts"],"sourcesContent":["import { PureComponent, ReactNode } from 'react';\nimport {\n Unsubscribe,\n AbilityTuple,\n SubjectType,\n AnyAbility,\n Generics,\n Abilities,\n IfString,\n} from '@casl/ability';\n\nconst noop = () => {};\n\ntype AbilityCanProps<\n T extends Abilities,\n Else = IfString<T, { do: T } | { I: T }>\n> = T extends AbilityTuple\n ? { do: T[0], on: T[1], field?: string } |\n { I: T[0], a: Extract<T[1], SubjectType>, field?: string } |\n { I: T[0], an: Extract<T[1], SubjectType>, field?: string } |\n { I: T[0], this: Exclude<T[1], SubjectType>, field?: string }\n : Else;\n\ninterface ExtraProps {\n not?: boolean\n passThrough?: boolean\n}\n\ninterface CanExtraProps<T extends AnyAbility> extends ExtraProps {\n ability: T\n children: ReactNode | ((isAllowed: boolean, ability: T) => ReactNode)\n}\n\ninterface BoundCanExtraProps<T extends AnyAbility> extends ExtraProps {\n ability?: T\n children: ReactNode | ((isAllowed: boolean, ability: T) => ReactNode)\n}\n\nexport type CanProps<T extends AnyAbility> =\n AbilityCanProps<Generics<T>['abilities']> & CanExtraProps<T>;\nexport type BoundCanProps<T extends AnyAbility> =\n AbilityCanProps<Generics<T>['abilities']> & BoundCanExtraProps<T>;\n\nexport class Can<\n T extends AnyAbility,\n IsBound extends boolean = false\n> extends PureComponent<IsBound extends true ? BoundCanProps<T> : CanProps<T>> {\n private _isAllowed: boolean = false;\n private _ability: T | null = null;\n private _unsubscribeFromAbility: Unsubscribe = noop;\n\n componentWillUnmount() {\n this._unsubscribeFromAbility();\n }\n\n private _connectToAbility(ability?: T) {\n if (ability === this._ability) {\n return;\n }\n\n this._unsubscribeFromAbility();\n this._ability = null;\n\n if (ability) {\n this._ability = ability;\n this._unsubscribeFromAbility = ability.on('updated', () => this.forceUpdate());\n }\n }\n\n get allowed() {\n return this._isAllowed;\n }\n\n private _canRender(): boolean {\n const props: any = this.props;\n const subject = props.of || props.a || props.an || props.this || props.on;\n const can = props.not ? 'cannot' : 'can';\n\n return props.ability[can](props.I || props.do, subject, props.field);\n }\n\n render() {\n this._connectToAbility(this.props.ability);\n this._isAllowed = this._canRender();\n return this.props.passThrough || this._isAllowed ? this._renderChildren() : null;\n }\n\n private _renderChildren() {\n const { children, ability } = this.props;\n const elements = typeof children === 'function'\n ? children(this._isAllowed, ability as any)\n : children;\n\n return elements as ReactNode;\n }\n}\n","import { createElement as h, ComponentClass, Consumer, FunctionComponent } from 'react';\nimport { AnyAbility } from '@casl/ability';\nimport { Can, BoundCanProps } from './Can';\n\ninterface BoundCanClass<T extends AnyAbility> extends ComponentClass<BoundCanProps<T>> {\n new (props: BoundCanProps<T>, context?: any): Can<T, true>\n}\n\nexport function createCanBoundTo<T extends AnyAbility>(ability: T): BoundCanClass<T> {\n return class extends Can<T, true> {\n static defaultProps = { ability } as BoundCanClass<T>['defaultProps'];\n };\n}\n\nexport function createContextualCan<T extends AnyAbility>(\n Getter: Consumer<T>\n): FunctionComponent<BoundCanProps<T>> {\n return (props: BoundCanProps<T>) => h(Getter, {\n children: (ability: T) => h(Can, {\n ability,\n ...props,\n } as any)\n });\n}\n","import React from 'react';\nimport { AnyAbility } from '@casl/ability';\n\nexport function useAbility<T extends AnyAbility>(context: React.Context<T>): T {\n if (process.env.NODE_ENV !== 'production' && typeof React.useContext !== 'function') {\n /* istanbul ignore next */\n throw new Error('You must use React >= 16.8 in order to use useAbility()');\n }\n\n const ability = React.useContext<T>(context);\n const [rules, setRules] = React.useState<T['rules']>();\n\n React.useEffect(() => ability.on('updated', (event) => {\n if (event.rules !== rules) {\n setRules(event.rules);\n }\n }), []);\n\n return ability;\n}\n"],"names":["noop","Can","PureComponent","_isAllowed","_ability","_unsubscribeFromAbility","componentWillUnmount","_connectToAbility","ability","this","on","forceUpdate","_canRender","props","subject","of","a","an","can","not","I","do","field","render","passThrough","_renderChildren","children","elements","createCanBoundTo","defaultProps","createContextualCan","Getter","h","useAbility","context","process","env","NODE_ENV","React","useContext","Error","rules","setRules","useState","useEffect","event"],"mappings":"4DAWA,MAAMA,EAAO,OAgCN,MAAMC,UAGHC,qCACAC,EAAsB,WACtBC,EAAqB,UACrBC,EAAuCL,EAE/CM,4BACOD,IAGCE,EAAkBC,MACpBA,IAAYC,KAAKL,cAIhBC,SACAD,EAAW,QAEZI,EAAS,MACNJ,EAAWI,OACXH,EAA0BG,EAAQE,GAAG,WAAW,IAAMD,KAAKE,sCAK3DF,KAAKN,EAGNS,UACAC,EAAaJ,KAAKI,YAClBC,EAAUD,EAAME,IAAMF,EAAMG,GAAKH,EAAMI,IAAMJ,EAAMJ,MAAQI,EAAMH,SACjEQ,EAAML,EAAMM,IAAM,SAAW,aAE5BN,EAAML,QAAQU,GAAKL,EAAMO,GAAKP,EAAMQ,GAAIP,EAASD,EAAMS,OAGhEC,cACOhB,EAAkBE,KAAKI,MAAML,cAC7BL,EAAaM,KAAKG,WAChBH,KAAKI,MAAMW,aAAef,KAAKN,EAAaM,KAAKgB,IAAoB,KAGtEA,UACAC,SAAEA,EAAFlB,QAAYA,GAAYC,KAAKI,YAC7Bc,EAA+B,oBAAbD,EACpBA,EAASjB,KAAKN,EAAYK,GAC1BkB,SAEGC,GCrFJ,SAASC,EAAuCpB,sBAC9C,cAAcP,MACZ4B,aAAe,CAAErB,QAAAA,KAIrB,SAASsB,EACdC,UAEQlB,GAA4BmB,EAAED,EAAQ,CAC5CL,SAAWlB,GAAewB,EAAE/B,iBAC1BO,QAAAA,GACGK,MCjBF,SAASoB,WAAiCC,MAClB,eAAzBC,QAAQC,IAAIC,UAAyD,oBAArBC,EAAMC,iBAElD,IAAIC,MAAM,iEAGZhC,EAAU8B,EAAMC,WAAcL,SAC7BO,EAAOC,GAAYJ,EAAMK,WAEhCL,EAAMM,WAAU,IAAMpC,EAAQE,GAAG,WAAYmC,OACvCA,EAAMJ,QAAUA,EAClBC,EAASG,EAAMJ,WAEf,WAEGjC"}
|
package/dist/types/Can.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { PureComponent } from 'react';
|
|
1
|
+
import { PureComponent, ReactNode } from 'react';
|
|
2
2
|
import { AbilityTuple, SubjectType, AnyAbility, Generics, Abilities, IfString } from '@casl/ability';
|
|
3
3
|
declare type AbilityCanProps<T extends Abilities, Else = IfString<T, {
|
|
4
4
|
do: T;
|
|
@@ -27,9 +27,11 @@ interface ExtraProps {
|
|
|
27
27
|
}
|
|
28
28
|
interface CanExtraProps<T extends AnyAbility> extends ExtraProps {
|
|
29
29
|
ability: T;
|
|
30
|
+
children: ReactNode | ((isAllowed: boolean, ability: T) => ReactNode);
|
|
30
31
|
}
|
|
31
32
|
interface BoundCanExtraProps<T extends AnyAbility> extends ExtraProps {
|
|
32
33
|
ability?: T;
|
|
34
|
+
children: ReactNode | ((isAllowed: boolean, ability: T) => ReactNode);
|
|
33
35
|
}
|
|
34
36
|
export declare type CanProps<T extends AnyAbility> = AbilityCanProps<Generics<T>['abilities']> & CanExtraProps<T>;
|
|
35
37
|
export declare type BoundCanProps<T extends AnyAbility> = AbilityCanProps<Generics<T>['abilities']> & BoundCanExtraProps<T>;
|
|
@@ -41,7 +43,7 @@ export declare class Can<T extends AnyAbility, IsBound extends boolean = false>
|
|
|
41
43
|
private _connectToAbility;
|
|
42
44
|
get allowed(): boolean;
|
|
43
45
|
private _canRender;
|
|
44
|
-
render(): any;
|
|
46
|
+
render(): number | boolean | import("react").ReactElement<any, string | ((props: any) => import("react").ReactElement<any, any> | null) | (new (props: any) => import("react").Component<any, any, any>)> | import("react").ReactFragment | null | undefined;
|
|
45
47
|
private _renderChildren;
|
|
46
48
|
}
|
|
47
49
|
export {};
|
package/dist/types/factory.d.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { ComponentClass, Consumer,
|
|
1
|
+
import { ComponentClass, Consumer, FunctionComponent } from 'react';
|
|
2
2
|
import { AnyAbility } from '@casl/ability';
|
|
3
3
|
import { Can, BoundCanProps } from './Can';
|
|
4
4
|
interface BoundCanClass<T extends AnyAbility> extends ComponentClass<BoundCanProps<T>> {
|
|
5
5
|
new (props: BoundCanProps<T>, context?: any): Can<T, true>;
|
|
6
6
|
}
|
|
7
7
|
export declare function createCanBoundTo<T extends AnyAbility>(ability: T): BoundCanClass<T>;
|
|
8
|
-
export declare function createContextualCan<T extends AnyAbility>(Getter: Consumer<T>):
|
|
8
|
+
export declare function createContextualCan<T extends AnyAbility>(Getter: Consumer<T>): FunctionComponent<BoundCanProps<T>>;
|
|
9
9
|
export {};
|
package/dist/umd/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
(function(t,n){"object"===typeof exports&&"undefined"!==typeof module?n(exports,require("react")):"function"===typeof define&&define.amd?define(["exports","react"],n):(t="undefined"!==typeof globalThis?globalThis:t||self,n((t.casl=t.casl||{},t.casl.react={}),t.React))})(this,(function(t,n){"use strict";function
|
|
1
|
+
(function(t,n){"object"===typeof exports&&"undefined"!==typeof module?n(exports,require("react")):"function"===typeof define&&define.amd?define(["exports","react"],n):(t="undefined"!==typeof globalThis?globalThis:t||self,n((t.casl=t.casl||{},t.casl.react={}),t.React))})(this,(function(t,n){"use strict";function i(t){return t&&"object"===typeof t&&"default"in t?t:{default:t}}var r=i(n);function e(t,n){for(var i=0;i<n.length;i++){var r=n[i];r.enumerable=r.enumerable||false;r.configurable=true;if("value"in r)r.writable=true;Object.defineProperty(t,r.key,r)}}function u(t,n,i){if(n)e(t.prototype,n);if(i)e(t,i);return t}function o(){o=Object.assign||function(t){for(var n=1;n<arguments.length;n++){var i=arguments[n];for(var r in i)if(Object.prototype.hasOwnProperty.call(i,r))t[r]=i[r]}return t};return o.apply(this,arguments)}function f(t,n){t.prototype=Object.create(n.prototype);t.prototype.constructor=t;c(t,n)}function c(t,n){c=Object.setPrototypeOf||function t(n,i){n.__proto__=i;return n};return c(t,n)}var s=function t(){};var a=function(t){f(n,t);function n(){var n;for(var i=arguments.length,r=new Array(i),e=0;e<i;e++)r[e]=arguments[e];n=t.call.apply(t,[this].concat(r))||this;n.t=false;n.i=null;n.u=s;return n}var i=n.prototype;i.componentWillUnmount=function t(){this.u()};i.o=function _connectToAbility(t){var n=this;if(t===this.i)return;this.u();this.i=null;if(t){this.i=t;this.u=t.on("updated",(function(){return n.forceUpdate()}))}};i.h=function t(){var n=this.props;var i=n.of||n.a||n.an||n.this||n.on;var r=n.not?"cannot":"can";return n.ability[r](n.I||n.do,i,n.field)};i.render=function t(){this.o(this.props.ability);this.t=this.h();return this.props.passThrough||this.t?this.l():null};i.l=function t(){var n=this.props,i=n.children,r=n.ability;var e="function"===typeof i?i(this.t,r):i;return e};u(n,[{key:"allowed",get:function t(){return this.t}}]);return n}(n.PureComponent);function h(t){var n,i;return i=n=function(t){f(n,t);function n(){return t.apply(this,arguments)||this}return n}(a),n.defaultProps={ability:t},i}function l(t){return function(i){return n.createElement(t,{children:function t(r){return n.createElement(a,o({ability:r},i))}})}}function useAbility(t){if("production"!==process.env.NODE_ENV&&"function"!==typeof r["default"].useContext)throw new Error("You must use React >= 16.8 in order to use useAbility()");var n=r["default"].useContext(t);var i=r["default"].useState(),e=i[0],u=i[1];r["default"].useEffect((function(){return n.on("updated",(function(t){if(t.rules!==e)u(t.rules)}))}),[]);return n}t.Can=a;t.createCanBoundTo=h;t.createContextualCan=l;t.useAbility=useAbility;Object.defineProperty(t,"__esModule",{value:true})}));
|
|
2
2
|
//# sourceMappingURL=index.js.map
|
package/dist/umd/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":["../../src/Can.ts","../../src/factory.ts","../../src/hooks/useAbility.ts"],"sourcesContent":["import {
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../../src/Can.ts","../../src/factory.ts","../../src/hooks/useAbility.ts"],"sourcesContent":["import { PureComponent, ReactNode } from 'react';\nimport {\n Unsubscribe,\n AbilityTuple,\n SubjectType,\n AnyAbility,\n Generics,\n Abilities,\n IfString,\n} from '@casl/ability';\n\nconst noop = () => {};\n\ntype AbilityCanProps<\n T extends Abilities,\n Else = IfString<T, { do: T } | { I: T }>\n> = T extends AbilityTuple\n ? { do: T[0], on: T[1], field?: string } |\n { I: T[0], a: Extract<T[1], SubjectType>, field?: string } |\n { I: T[0], an: Extract<T[1], SubjectType>, field?: string } |\n { I: T[0], this: Exclude<T[1], SubjectType>, field?: string }\n : Else;\n\ninterface ExtraProps {\n not?: boolean\n passThrough?: boolean\n}\n\ninterface CanExtraProps<T extends AnyAbility> extends ExtraProps {\n ability: T\n children: ReactNode | ((isAllowed: boolean, ability: T) => ReactNode)\n}\n\ninterface BoundCanExtraProps<T extends AnyAbility> extends ExtraProps {\n ability?: T\n children: ReactNode | ((isAllowed: boolean, ability: T) => ReactNode)\n}\n\nexport type CanProps<T extends AnyAbility> =\n AbilityCanProps<Generics<T>['abilities']> & CanExtraProps<T>;\nexport type BoundCanProps<T extends AnyAbility> =\n AbilityCanProps<Generics<T>['abilities']> & BoundCanExtraProps<T>;\n\nexport class Can<\n T extends AnyAbility,\n IsBound extends boolean = false\n> extends PureComponent<IsBound extends true ? BoundCanProps<T> : CanProps<T>> {\n private _isAllowed: boolean = false;\n private _ability: T | null = null;\n private _unsubscribeFromAbility: Unsubscribe = noop;\n\n componentWillUnmount() {\n this._unsubscribeFromAbility();\n }\n\n private _connectToAbility(ability?: T) {\n if (ability === this._ability) {\n return;\n }\n\n this._unsubscribeFromAbility();\n this._ability = null;\n\n if (ability) {\n this._ability = ability;\n this._unsubscribeFromAbility = ability.on('updated', () => this.forceUpdate());\n }\n }\n\n get allowed() {\n return this._isAllowed;\n }\n\n private _canRender(): boolean {\n const props: any = this.props;\n const subject = props.of || props.a || props.an || props.this || props.on;\n const can = props.not ? 'cannot' : 'can';\n\n return props.ability[can](props.I || props.do, subject, props.field);\n }\n\n render() {\n this._connectToAbility(this.props.ability);\n this._isAllowed = this._canRender();\n return this.props.passThrough || this._isAllowed ? this._renderChildren() : null;\n }\n\n private _renderChildren() {\n const { children, ability } = this.props;\n const elements = typeof children === 'function'\n ? children(this._isAllowed, ability as any)\n : children;\n\n return elements as ReactNode;\n }\n}\n","import { createElement as h, ComponentClass, Consumer, FunctionComponent } from 'react';\nimport { AnyAbility } from '@casl/ability';\nimport { Can, BoundCanProps } from './Can';\n\ninterface BoundCanClass<T extends AnyAbility> extends ComponentClass<BoundCanProps<T>> {\n new (props: BoundCanProps<T>, context?: any): Can<T, true>\n}\n\nexport function createCanBoundTo<T extends AnyAbility>(ability: T): BoundCanClass<T> {\n return class extends Can<T, true> {\n static defaultProps = { ability } as BoundCanClass<T>['defaultProps'];\n };\n}\n\nexport function createContextualCan<T extends AnyAbility>(\n Getter: Consumer<T>\n): FunctionComponent<BoundCanProps<T>> {\n return (props: BoundCanProps<T>) => h(Getter, {\n children: (ability: T) => h(Can, {\n ability,\n ...props,\n } as any)\n });\n}\n","import React from 'react';\nimport { AnyAbility } from '@casl/ability';\n\nexport function useAbility<T extends AnyAbility>(context: React.Context<T>): T {\n if (process.env.NODE_ENV !== 'production' && typeof React.useContext !== 'function') {\n /* istanbul ignore next */\n throw new Error('You must use React >= 16.8 in order to use useAbility()');\n }\n\n const ability = React.useContext<T>(context);\n const [rules, setRules] = React.useState<T['rules']>();\n\n React.useEffect(() => ability.on('updated', (event) => {\n if (event.rules !== rules) {\n setRules(event.rules);\n }\n }), []);\n\n return ability;\n}\n"],"names":["noop","Can","_isAllowed","_ability","_unsubscribeFromAbility","componentWillUnmount","_connectToAbility","ability","this","on","_this2","forceUpdate","_canRender","props","subject","of","a","an","can","not","I","do","field","render","passThrough","_renderChildren","children","elements","PureComponent","createCanBoundTo","defaultProps","createContextualCan","Getter","h","useAbility","context","process","env","NODE_ENV","React","useContext","Error","useState","rules","setRules","useEffect","event"],"mappings":"q/BAWA,IAAMA,EAAO,SAAPA,UAgCOC,2JAIHC,EAAsB,QACtBC,EAAqB,OACrBC,EAAuCJ,+BAE/CK,qBAAA,kBACOD,OAGCE,EAAR,2BAA0BC,iBACpBA,IAAYC,KAAKL,cAIhBC,SACAD,EAAW,QAEZI,EAAS,MACNJ,EAAWI,OACXH,EAA0BG,EAAQE,GAAG,WAAW,kBAAMC,EAAKC,qBAQ5DC,EAAR,iBACQC,EAAaL,KAAKK,UAClBC,EAAUD,EAAME,IAAMF,EAAMG,GAAKH,EAAMI,IAAMJ,EAAML,MAAQK,EAAMJ,OACjES,EAAML,EAAMM,IAAM,SAAW,aAE5BN,EAAMN,QAAQW,GAAKL,EAAMO,GAAKP,EAAMQ,GAAIP,EAASD,EAAMS,UAGhEC,OAAA,kBACOjB,EAAkBE,KAAKK,MAAMN,cAC7BL,EAAaM,KAAKI,WAChBJ,KAAKK,MAAMW,aAAehB,KAAKN,EAAaM,KAAKiB,IAAoB,QAGtEA,EAAR,mBACgCjB,KAAKK,MAA3Ba,IAAAA,SAAUnB,IAAAA,YACZoB,EAA+B,oBAAbD,EACpBA,EAASlB,KAAKN,EAAYK,GAC1BmB,SAEGC,2BAxBT,oBACSnB,KAAKN,gBAxBN0B,iBCtCH,SAASC,EAAuCtB,qGAChCN,KACZ6B,aAAe,CAAEvB,QAAAA,KAIrB,SAASwB,EACdC,UAEO,SAACnB,UAA4BoB,gBAAED,EAAQ,CAC5CN,SAAU,WAACnB,UAAe0B,gBAAEhC,KAC1BM,QAAAA,GACGM,QCjBF,SAASqB,WAAiCC,MAClB,eAAzBC,QAAQC,IAAIC,UAAyD,oBAArBC,aAAMC,iBAElD,IAAIC,MAAM,+DAGZlC,EAAUgC,aAAMC,WAAcL,SACVI,aAAMG,WAAzBC,OAAOC,OAEdL,aAAMM,WAAU,kBAAMtC,EAAQE,GAAG,WAAW,SAACqC,MACvCA,EAAMH,QAAUA,EAClBC,EAASE,EAAMH,YAEf,WAEGpC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@casl/react",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "3.0.0",
|
|
4
4
|
"description": "React component for CASL which makes it easy to add permissions in any React application",
|
|
5
5
|
"main": "dist/umd/index.js",
|
|
6
6
|
"module": "dist/es5m/index.js",
|
|
@@ -14,7 +14,8 @@
|
|
|
14
14
|
},
|
|
15
15
|
"repository": {
|
|
16
16
|
"type": "git",
|
|
17
|
-
"url": "https://github.com/stalniy/casl.git"
|
|
17
|
+
"url": "https://github.com/stalniy/casl.git",
|
|
18
|
+
"directory": "packages/casl-react"
|
|
18
19
|
},
|
|
19
20
|
"homepage": "https://casl.js.org",
|
|
20
21
|
"publishConfig": {
|
|
@@ -40,18 +41,18 @@
|
|
|
40
41
|
"license": "MIT",
|
|
41
42
|
"peerDependencies": {
|
|
42
43
|
"@casl/ability": "^3.0.0 || ^4.0.0 || ^5.1.0",
|
|
43
|
-
"react": "^
|
|
44
|
+
"react": "^16.0.0 || ^17.0.0 || ^18.0.0"
|
|
44
45
|
},
|
|
45
46
|
"devDependencies": {
|
|
46
47
|
"@casl/ability": "^5.1.0",
|
|
47
48
|
"@casl/dx": "workspace:^1.0.0",
|
|
48
49
|
"@testing-library/react-hooks": "^4.0.1",
|
|
49
50
|
"@types/node": "^14.0.5",
|
|
50
|
-
"@types/react": "^
|
|
51
|
+
"@types/react": "^18.0.0",
|
|
51
52
|
"chai": "^4.1.0",
|
|
52
53
|
"chai-spies": "^1.0.0",
|
|
53
|
-
"react": "^
|
|
54
|
-
"react-test-renderer": "^
|
|
54
|
+
"react": "^18.0.0",
|
|
55
|
+
"react-test-renderer": "^18.0.0"
|
|
55
56
|
},
|
|
56
57
|
"files": [
|
|
57
58
|
"dist",
|
package/CHANGELOG.md
DELETED
|
@@ -1,285 +0,0 @@
|
|
|
1
|
-
# Change Log
|
|
2
|
-
|
|
3
|
-
All notable changes to this project will be documented in this file.
|
|
4
|
-
|
|
5
|
-
# [2.3.0](https://github.com/stalniy/casl/compare/@casl/react@2.2.2...@casl/react@2.3.0) (2021-05-12)
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
### Bug Fixes
|
|
9
|
-
|
|
10
|
-
* adjusts package tags to improve discoverability ([73e88b0](https://github.com/stalniy/casl/commit/73e88b0a256625b193b2cd9dc4a219f2e1193cbc))
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
### Features
|
|
14
|
-
|
|
15
|
-
* **prisma:** adds prisma integration ([#505](https://github.com/stalniy/casl/issues/505)) ([9f91ac4](https://github.com/stalniy/casl/commit/9f91ac403f05c8fac5229b1c9e243909379efbc6)), closes [#161](https://github.com/stalniy/casl/issues/161) [#161](https://github.com/stalniy/casl/issues/161)
|
|
16
|
-
|
|
17
|
-
## [2.2.2](https://github.com/stalniy/casl/compare/@casl/react@2.2.1...@casl/react@2.2.2) (2021-01-14)
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
### Features
|
|
21
|
-
|
|
22
|
-
* **react:** updates react to v17
|
|
23
|
-
|
|
24
|
-
## [2.2.1](https://github.com/stalniy/casl/compare/@casl/react@2.2.0...@casl/react@2.2.1) (2020-12-28)
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
### Bug Fixes
|
|
28
|
-
|
|
29
|
-
* **dist:** adds separate `tsconfig.build.json` to every completementary project ([87742ce](https://github.com/stalniy/casl/commit/87742cec518a8a68d5fc29be2bbc9561cbc7da6c)), closes [#419](https://github.com/stalniy/casl/issues/419)
|
|
30
|
-
|
|
31
|
-
# [2.2.0](https://github.com/stalniy/casl/compare/@casl/react@2.1.1...@casl/react@2.2.0) (2020-12-26)
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
### Bug Fixes
|
|
35
|
-
|
|
36
|
-
* **angular:** fixes sourcemap generation for the code built by ngc ([7715263](https://github.com/stalniy/casl/commit/771526379ff8203170a433d71b68644a48ff44eb)), closes [#387](https://github.com/stalniy/casl/issues/387) [#382](https://github.com/stalniy/casl/issues/382)
|
|
37
|
-
* **package:** removes `engine` section that points to npm@6 ([eecd12a](https://github.com/stalniy/casl/commit/eecd12ac49f56d6a0f57d1a57fb37487335b5f03)), closes [#417](https://github.com/stalniy/casl/issues/417)
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
### Features
|
|
41
|
-
|
|
42
|
-
* **builder:** improves typings for AbilityBuilder [skip release] ([ebd4d17](https://github.com/stalniy/casl/commit/ebd4d17a355a2646467033118a3d6efee4321d27)), closes [#379](https://github.com/stalniy/casl/issues/379)
|
|
43
|
-
* **esm:** adds ESM support for latest Node.js through `exports` prop in package.json ([cac2506](https://github.com/stalniy/casl/commit/cac2506a80c18f194210c2d89108d1d094751fa4)), closes [#331](https://github.com/stalniy/casl/issues/331)
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
### BREAKING CHANGES
|
|
47
|
-
|
|
48
|
-
* **builder:** changes main generic parameter to be a class instead of instance and makes `defineAbility` to accept options as the 2nd argument.
|
|
49
|
-
|
|
50
|
-
**Before**
|
|
51
|
-
|
|
52
|
-
```ts
|
|
53
|
-
import { AbilityBuilder, defineAbility, Ability } from '@casl/ability';
|
|
54
|
-
|
|
55
|
-
const resolveAction = (action: string) => {/* custom implementation */ };
|
|
56
|
-
const ability = defineAbility({ resolveAction }, (can) => can('read', 'Item'));
|
|
57
|
-
const builder = new AbilityBuilder<Ability>(Ability);
|
|
58
|
-
```
|
|
59
|
-
|
|
60
|
-
**After**
|
|
61
|
-
|
|
62
|
-
```ts
|
|
63
|
-
import { AbilityBuilder, defineAbility, Ability } from '@casl/ability';
|
|
64
|
-
|
|
65
|
-
const resolveAction = (action: string) => {/* custom implementation */ };
|
|
66
|
-
const ability = defineAbility((can) => can('read', 'Item'), { resolveAction });
|
|
67
|
-
const builder = new AbilityBuilder(Ability); // first argument is now mandatory!
|
|
68
|
-
```
|
|
69
|
-
|
|
70
|
-
The 1st parameter to `AbilityBuilder` is now madatory. This allows to infer generic parameters from it and makes AbilityType that is built to be explicit.
|
|
71
|
-
|
|
72
|
-
## [2.1.1](https://github.com/stalniy/casl/compare/@casl/react@2.1.0...@casl/react@2.1.1) (2020-06-09)
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
### Bug Fixes
|
|
76
|
-
|
|
77
|
-
* **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)
|
|
78
|
-
|
|
79
|
-
# [2.1.0](https://github.com/stalniy/casl/compare/@casl/react@2.0.2...@casl/react@2.1.0) (2020-04-18)
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
### Features
|
|
83
|
-
|
|
84
|
-
* **react:** adds `useAbility` hook ([#292](https://github.com/stalniy/casl/issues/292)) ([cd81a22](https://github.com/stalniy/casl/commit/cd81a224b4d44b036ecf5e53601e34d7a51e7be3)), closes [#291](https://github.com/stalniy/casl/issues/291)
|
|
85
|
-
|
|
86
|
-
## [2.0.2](https://github.com/stalniy/casl/compare/@casl/react@2.0.1...@casl/react@2.0.2) (2020-04-10)
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
### Bug Fixes
|
|
90
|
-
|
|
91
|
-
* **react:** ensure that terser doesn't mangle reserved required props ([08eb4f4](https://github.com/stalniy/casl/commit/08eb4f4f730f1b453b3a026d5e0e0ca4ff24be10))
|
|
92
|
-
|
|
93
|
-
## [2.0.1](https://github.com/stalniy/casl/compare/@casl/react@2.0.0...@casl/react@2.0.1) (2020-04-09)
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
### Bug Fixes
|
|
97
|
-
|
|
98
|
-
* **react:** adds support for casl/ability@4 in package.json ([4367b43](https://github.com/stalniy/casl/commit/4367b430fcfd2076292607581df4aa0d247e011b))
|
|
99
|
-
|
|
100
|
-
# [2.0.0](https://github.com/stalniy/casl/compare/@casl/react@1.0.4...@casl/react@2.0.0) (2020-04-09)
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
### Bug Fixes
|
|
104
|
-
|
|
105
|
-
* **react:** makes sure `Can` infers types for props from provided `Ability` ([5813b25](https://github.com/stalniy/casl/commit/5813b25d286af6ff76bec6c266fe21af817fe45b)), closes [#248](https://github.com/stalniy/casl/issues/248)
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
### Features
|
|
109
|
-
|
|
110
|
-
* **react:** adds generics for Ability and related components [skip ci] ([3102b6e](https://github.com/stalniy/casl/commit/3102b6e639213553570cf97661b7b7f4c3640687)), closes [#256](https://github.com/stalniy/casl/issues/256)
|
|
111
|
-
* **react:** adds support for action only components ([a2db577](https://github.com/stalniy/casl/commit/a2db577910763ecc0b5eca3196bdc22fc8ff3dba)), closes [#107](https://github.com/stalniy/casl/issues/107)
|
|
112
|
-
* **vue:** adds better generics typying for Vue ([5cc7b60](https://github.com/stalniy/casl/commit/5cc7b60d8a2a53db217f8ad1a4673a28f67aefce)), closes [#107](https://github.com/stalniy/casl/issues/107)
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
### BREAKING CHANGES
|
|
116
|
-
|
|
117
|
-
* **react:** support for react v15 was loosen. If you use react v15 you will need to add `@casl/react/contextApiPatch.d.ts` file into your typings
|
|
118
|
-
* **typescript:** weak hand written declaration files are removed as `@casl/react` has been completely rewritten to TypeScript. TypeScript now checks that you correctly use property aliases
|
|
119
|
-
* **Can:** `of` alias is removed and field was extracted to a separate prop
|
|
120
|
-
|
|
121
|
-
**Before**
|
|
122
|
-
|
|
123
|
-
```jsx
|
|
124
|
-
export default <Can I="read title" of="Post">...</Can>
|
|
125
|
-
```
|
|
126
|
-
|
|
127
|
-
**After**
|
|
128
|
-
|
|
129
|
-
```jsx
|
|
130
|
-
export default <Can I="read" a="Post" field="title">...</Can>
|
|
131
|
-
```
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
# [@casl/react-v1.0.4](https://github.com/stalniy/casl/compare/@casl/react@1.0.3...@casl/react@1.0.4) (2019-07-28)
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
### Performance Improvements
|
|
138
|
-
|
|
139
|
-
* **react:** adds check if children array has length of 1 then render it without React.Fragment ([655d08f](https://github.com/stalniy/casl/commit/655d08f)), closes [#211](https://github.com/stalniy/casl/issues/211)
|
|
140
|
-
|
|
141
|
-
# [@casl/react-v1.0.3](https://github.com/stalniy/casl/compare/@casl/react@1.0.2...@casl/react@1.0.3) (2019-03-25)
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
### Bug Fixes
|
|
145
|
-
|
|
146
|
-
* **react:** handles `an` prop as subject name ([608c99b](https://github.com/stalniy/casl/commit/608c99b)), closes [#169](https://github.com/stalniy/casl/issues/169)
|
|
147
|
-
|
|
148
|
-
# [@casl/react-v1.0.2](https://github.com/stalniy/casl/compare/@casl/react@1.0.1...@casl/react@1.0.2) (2019-02-16)
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
### Performance Improvements
|
|
152
|
-
|
|
153
|
-
* **react:** checks whether ability changed before unsubsribing ([d865fa8](https://github.com/stalniy/casl/commit/d865fa8)), closes [#159](https://github.com/stalniy/casl/issues/159)
|
|
154
|
-
|
|
155
|
-
# [@casl/react-v1.0.1](https://github.com/stalniy/casl/compare/@casl/react@1.0.0...@casl/react@1.0.1) (2019-02-10)
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
### Bug Fixes
|
|
159
|
-
|
|
160
|
-
* **packages:** increases peerDependency of [@casl](https://github.com/casl)/ability ([9f6a7b8](https://github.com/stalniy/casl/commit/9f6a7b8)), closes [#119](https://github.com/stalniy/casl/issues/119)
|
|
161
|
-
|
|
162
|
-
# [@casl/react-v1.0.0](https://github.com/stalniy/casl/compare/@casl/react@0.8.1...@casl/react@1.0.0) (2019-02-03)
|
|
163
|
-
|
|
164
|
-
### Breaking Changes
|
|
165
|
-
|
|
166
|
-
* **react:** removes internal state in <Can> component ([#122](https://github.com/stalniy/casl/issues/122)) ([df9dd51](https://github.com/stalniy/casl/commit/df9dd51)), closes [#122](https://github.com/stalniy/casl/issues/122)
|
|
167
|
-
|
|
168
|
-
# [@casl/react-v0.8.1](https://github.com/stalniy/casl/compare/@casl/react@0.8.0...@casl/react@0.8.1) (2018-11-08)
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
### Bug Fixes
|
|
172
|
-
|
|
173
|
-
* **react:** moves this.connectToAbility to the setState callback ([#129](https://github.com/stalniy/casl/issues/129)) ([9d0c839](https://github.com/stalniy/casl/commit/9d0c839)), closes [#128](https://github.com/stalniy/casl/issues/128)
|
|
174
|
-
|
|
175
|
-
# [@casl/react-v0.8.0](https://github.com/stalniy/casl/compare/@casl/react@0.7.2...@casl/react@0.8.0) (2018-09-03)
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
### Bug Fixes
|
|
179
|
-
|
|
180
|
-
* **README:** changes links to [@casl](https://github.com/casl)/ability to point to npm package instead to git root [skip ci] ([a74086b](https://github.com/stalniy/casl/commit/a74086b)), closes [#102](https://github.com/stalniy/casl/issues/102)
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
### Features
|
|
184
|
-
|
|
185
|
-
* **react:can:** adds `an` alias to `on` prop ([748ea64](https://github.com/stalniy/casl/commit/748ea64))
|
|
186
|
-
* **react:can:** adds `passThrough` option ([045318c](https://github.com/stalniy/casl/commit/045318c)), closes [#105](https://github.com/stalniy/casl/issues/105)
|
|
187
|
-
* **react:can:** adds support for multiple <Can> children ([c022b32](https://github.com/stalniy/casl/commit/c022b32))
|
|
188
|
-
* **react:can:** updates typescript declarations ([70953ed](https://github.com/stalniy/casl/commit/70953ed))
|
|
189
|
-
* **react:can:** updates typescript declarations ([213dcde](https://github.com/stalniy/casl/commit/213dcde))
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
### Performance Improvements
|
|
193
|
-
|
|
194
|
-
* **react:can:** moves prop type checks undef `if`, so they can be removed for production builds ([4bebf0b](https://github.com/stalniy/casl/commit/4bebf0b))
|
|
195
|
-
|
|
196
|
-
# [@casl/react-v0.7.2](https://github.com/stalniy/casl/compare/@casl/react@0.7.1...@casl/react@0.7.2) (2018-07-29)
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
### Bug Fixes
|
|
200
|
-
|
|
201
|
-
* **react:** makes `not` prop to be optional ([8f841bf](https://github.com/stalniy/casl/commit/8f841bf)), closes [#95](https://github.com/stalniy/casl/issues/95)
|
|
202
|
-
|
|
203
|
-
<a name="@casl/react-v0.7.1"></a>
|
|
204
|
-
# [@casl/react-v0.7.1](https://github.com/stalniy/casl/compare/@casl/react@0.7.0...@casl/react@0.7.1) (2018-07-02)
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
### Bug Fixes
|
|
208
|
-
|
|
209
|
-
* **package:** changes location of ES5M modules ([2b1ad4e](https://github.com/stalniy/casl/commit/2b1ad4e)), closes [#89](https://github.com/stalniy/casl/issues/89)
|
|
210
|
-
|
|
211
|
-
<a name="@casl/react-v0.7.0"></a>
|
|
212
|
-
# [@casl/react-v0.7.0](https://github.com/stalniy/casl/compare/@casl/react@0.6.0...@casl/react@0.7.0) (2018-06-15)
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
### Bug Fixes
|
|
216
|
-
|
|
217
|
-
* **react:** adds ts defs for `not` attribute ([17f76a9](https://github.com/stalniy/casl/commit/17f76a9))
|
|
218
|
-
* **react:** contextual can don't respect 'not' prop ([#74](https://github.com/stalniy/casl/issues/74)) ([d727230](https://github.com/stalniy/casl/commit/d727230))
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
### Features
|
|
222
|
-
|
|
223
|
-
* **vue:** adds can component ([42ee540](https://github.com/stalniy/casl/commit/42ee540)), closes [#63](https://github.com/stalniy/casl/issues/63)
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
<a name="@casl/react-v0.6.0"></a>
|
|
227
|
-
# [@casl/react-v0.6.0](https://github.com/stalniy/casl/compare/@casl/react@0.5.0...@casl/react@0.6.0) (2018-05-28)
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
### Bug Fixes
|
|
231
|
-
|
|
232
|
-
* **react:** adds `I`, `a`, `of`, `this` aliases in types ([a412868](https://github.com/stalniy/casl/commit/a412868)), closes [#65](https://github.com/stalniy/casl/issues/65)
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
### Features
|
|
236
|
-
|
|
237
|
-
* **react:** adds `not` attribute ([94ef6d4](https://github.com/stalniy/casl/commit/94ef6d4)), by @emilbruckner in [#66](https://github.com/stalniy/casl/issues/66)
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
<a name="0.5.0"></a>
|
|
241
|
-
# 0.5.0 (2018-05-14)
|
|
242
|
-
|
|
243
|
-
### Features
|
|
244
|
-
|
|
245
|
-
* **react:** support for more readable component ([1a8c1ec](https://github.com/stalniy/casl/commit/1a8c1ec))
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
<a name="0.4.0"></a>
|
|
250
|
-
# 0.4.0 (2018-04-23)
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
### Bug Fixes
|
|
254
|
-
|
|
255
|
-
* **react:** rechecks abilities in `Can` on props update ([e08db1e](https://github.com/stalniy/casl/commit/e08db1e)), closes [#55](https://github.com/stalniy/casl/issues/55)
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
<a name="0.3.0"></a>
|
|
259
|
-
# 0.3.0 (2018-04-20)
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
### Bug Fixes
|
|
263
|
-
|
|
264
|
-
* **react:** fixes support for React 15.x ([8e17738](https://github.com/stalniy/casl/commit/8e17738))
|
|
265
|
-
* **react:** fixes typings for react 15.x & 16.x ([f147a8a](https://github.com/stalniy/casl/commit/f147a8a)), closes [#38](https://github.com/stalniy/casl/issues/38)
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
<a name="0.2.0"></a>
|
|
270
|
-
# 0.2.0 (2018-04-20)
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
### Features
|
|
274
|
-
|
|
275
|
-
* **react:** adds typescript definition for package [@casl](https://github.com/casl)/react ([37718fe](https://github.com/stalniy/casl/commit/37718fe)), closes [#54](https://github.com/stalniy/casl/issues/54)
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
<a name="0.1.0"></a>
|
|
279
|
-
# 0.1.0 (2018-03-23)
|
|
280
|
-
|
|
281
|
-
### Features
|
|
282
|
-
|
|
283
|
-
* **component:** adds `Can` component, relates to [#23](https://github.com/stalniy/casl/issues/23)
|
|
284
|
-
* **integration:** adds `createContextualCan` function which allows to work with new React Context API, relates to [#23](https://github.com/stalniy/casl/issues/23)
|
|
285
|
-
* **integration:** adds `createCanBoundTo` function which allows to bind ability to component, relates to [#23](https://github.com/stalniy/casl/issues/23)
|