@matir-js/react 0.1.3 → 0.2.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/index.d.mts CHANGED
@@ -27,6 +27,7 @@ declare function MatirProvider({
27
27
  }): react_jsx_runtime0.JSX.Element;
28
28
  declare function useCurrent(): {
29
29
  role: CurrentRole;
30
+ permissions: Record<string, string[]> | null;
30
31
  setRole: (role: string) => void;
31
32
  setPermissions: (permissions: Record<string, string[]>) => void;
32
33
  clearAll: () => void;
package/dist/index.mjs CHANGED
@@ -5,6 +5,7 @@ import { Fragment, jsx } from "react/jsx-runtime";
5
5
  const MatirContext = createContext(null);
6
6
  function MatirProvider({ children, schema, current: initialCurrent }) {
7
7
  const [role, setRole] = useState(null);
8
+ const [permissions, setPermissions] = useState(null);
8
9
  const [, forceUpdate] = useReducer((x) => x + 1, 0);
9
10
  const { ability, current } = useMemo(() => {
10
11
  const instance = matir$1.createSchema(schema);
@@ -18,6 +19,7 @@ function MatirProvider({ children, schema, current: initialCurrent }) {
18
19
  }, [current]);
19
20
  const setCurrentPermissions = useCallback((permissions) => {
20
21
  current.permissions(permissions);
22
+ setPermissions(permissions);
21
23
  forceUpdate();
22
24
  }, [current]);
23
25
  const clearAll = useCallback(() => {
@@ -27,6 +29,7 @@ function MatirProvider({ children, schema, current: initialCurrent }) {
27
29
  return /* @__PURE__ */ jsx(MatirContext.Provider, {
28
30
  value: {
29
31
  role,
32
+ permissions,
30
33
  ability,
31
34
  setCurrentRole,
32
35
  setCurrentPermissions,
@@ -40,6 +43,7 @@ function useCurrent() {
40
43
  if (!ctx) throw new Error("useAbility must be used within <MatirProvider />");
41
44
  return {
42
45
  role: ctx.role,
46
+ permissions: ctx.permissions,
43
47
  setRole: ctx.setCurrentRole,
44
48
  setPermissions: ctx.setCurrentPermissions,
45
49
  clearAll: ctx.clearAll
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@matir-js/react",
3
- "version": "0.1.3",
3
+ "version": "0.2.0",
4
4
  "description": "",
5
5
  "type": "module",
6
6
  "main": "dist/index.mjs",
@@ -21,7 +21,7 @@
21
21
  "author": "andrefelipeschulle",
22
22
  "license": "MIT",
23
23
  "dependencies": {
24
- "@matir-js/core": "0.6.0"
24
+ "@matir-js/core": "0.7.0"
25
25
  },
26
26
  "peerDependencies": {
27
27
  "react": "^19",