@corva/ui 0.55.0-1 → 0.55.0-2

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.
@@ -1 +1 @@
1
- "use strict";var e=require("react"),r=require("./PermissionsContext.js");module.exports=function(t){var i=r.default(),n=i.permissions,s=i.fetchPermissions;return e.useEffect((function(){s(t)}),["".concat(t)]),t.map((function(e){return n[e]||{active:!1,loading:!0}}))};
1
+ "use strict";var r=require("react"),e=require("lodash"),i=require("./PermissionsContext.js");module.exports=function(s){var t=i.default(),n=t.permissions,a=t.fetchPermissions,o=e.toArray(s);r.useEffect((function(){a(o)}),[o.join()]);var u=function(r){return n[r]||{active:!1,loading:!0}};return e.isArray(s)?s.map(u):e.mapValues(s,u)};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@corva/ui",
3
- "version": "0.55.0-1",
3
+ "version": "0.55.0-2",
4
4
  "description": "Shared components/utils for Corva ui projects",
5
5
  "keywords": [
6
6
  "corva-ui"
@@ -1,3 +1,12 @@
1
1
  export default usePermissions;
2
- declare function usePermissions(permissionKeys: any): any;
2
+ /**
3
+ * Custom hook for fetching user permissions.
4
+ * @param {string[] | Object<string, string>} permissionKeys - An array of permission keys to check, or an object mapping named keys to permission keys.
5
+ * @returns {object[] | Object<string, object>} An array of objects representing the status of each permission, or an object mapping permission keys to their status objects.
6
+ */
7
+ declare function usePermissions(permissionKeys: string[] | {
8
+ [x: string]: string;
9
+ }): object[] | {
10
+ [x: string]: object;
11
+ };
3
12
  //# sourceMappingURL=usePermissions.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"usePermissions.d.ts","sourceRoot":"","sources":["../../src/permissions/usePermissions.js"],"names":[],"mappings":";AAIA,0DAQC"}
1
+ {"version":3,"file":"usePermissions.d.ts","sourceRoot":"","sources":["../../src/permissions/usePermissions.js"],"names":[],"mappings":";AAKA;;;;GAIG;AACH,gDAHW,MAAM,EAAE;QAAU,MAAM,GAAE,MAAM;CAAC,GAC/B,MAAM,EAAE;QAAU,MAAM,GAAE,MAAM;CAAC,CAmB7C"}
@@ -1 +1 @@
1
- import{useEffect as t}from"react";import n from"./PermissionsContext.js";function o(o){var r=n(),i=r.permissions,e=r.fetchPermissions;return t((function(){e(o)}),["".concat(o)]),o.map((function(t){return i[t]||{active:!1,loading:!0}}))}export{o as default};
1
+ import{useEffect as o}from"react";import{toArray as r,isArray as i,mapValues as t}from"lodash";import n from"./PermissionsContext.js";function s(s){var e=n(),m=e.permissions,a=e.fetchPermissions,f=r(s);o((function(){a(f)}),[f.join()]);var c=function(o){return m[o]||{active:!1,loading:!0}};return i(s)?s.map(c):t(s,c)}export{s as default};