@orbe-agro/client-core 5.3.34 → 5.3.35
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,15 +1,19 @@
|
|
|
1
1
|
import { useMemo as f } from "react";
|
|
2
2
|
import o from "lodash/isEmpty";
|
|
3
|
-
function
|
|
4
|
-
const
|
|
5
|
-
if (n.some((
|
|
3
|
+
function i(e = [], n = [], c = !1) {
|
|
4
|
+
const s = f(() => {
|
|
5
|
+
if (n.some((t) => e.includes(t)))
|
|
6
6
|
return !0;
|
|
7
|
-
const
|
|
8
|
-
return e.
|
|
7
|
+
const r = window.location.pathname;
|
|
8
|
+
return e.some((t) => {
|
|
9
|
+
if (t === r) return !0;
|
|
10
|
+
const a = t.replace(/:[^/]+/g, "[^/]+");
|
|
11
|
+
return new RegExp(`^${a}$`).test(r);
|
|
12
|
+
});
|
|
9
13
|
}, [n, e]);
|
|
10
|
-
return o(n) && o(e) && typeof n > "u" ? !
|
|
14
|
+
return o(n) && o(e) && typeof n > "u" ? !c : s;
|
|
11
15
|
}
|
|
12
16
|
export {
|
|
13
|
-
|
|
17
|
+
i as default
|
|
14
18
|
};
|
|
15
19
|
//# sourceMappingURL=useAuthority.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useAuthority.js","sources":["../../../../lib/@ecme/utils/hooks/useAuthority.ts"],"sourcesContent":["import { useMemo } from
|
|
1
|
+
{"version":3,"file":"useAuthority.js","sources":["../../../../lib/@ecme/utils/hooks/useAuthority.ts"],"sourcesContent":["import { useMemo } from \"react\";\nimport isEmpty from \"lodash/isEmpty\";\n\nfunction useAuthority(\n userAuthority: string[] = [],\n authority: string[] = [],\n emptyCheck = false\n) {\n const roleMatched = useMemo(() => {\n const hasRoleMatch = authority.some((role) => userAuthority.includes(role));\n if (hasRoleMatch) {\n return true;\n }\n\n const currentPath = window.location.pathname;\n\n return userAuthority.some((userPath) => {\n if (userPath === currentPath) return true;\n\n const regexPath = userPath.replace(/:[^/]+/g, \"[^/]+\");\n const regex = new RegExp(`^${regexPath}$`);\n return regex.test(currentPath);\n });\n }, [authority, userAuthority]);\n\n if (\n isEmpty(authority) &&\n isEmpty(userAuthority) &&\n typeof authority === \"undefined\"\n ) {\n return !emptyCheck;\n }\n\n return roleMatched;\n}\n\nexport default useAuthority;\n"],"names":["useAuthority","userAuthority","authority","emptyCheck","roleMatched","useMemo","role","currentPath","userPath","regexPath","isEmpty"],"mappings":";;AAGA,SAASA,EACPC,IAA0B,CAAA,GAC1BC,IAAsB,CAAA,GACtBC,IAAa,IACb;AACA,QAAMC,IAAcC,EAAQ,MAAM;AAEhC,QADqBH,EAAU,KAAK,CAACI,MAASL,EAAc,SAASK,CAAI,CAAC;AAExE,aAAO;AAGT,UAAMC,IAAc,OAAO,SAAS;AAEpC,WAAON,EAAc,KAAK,CAACO,MAAa;AACtC,UAAIA,MAAaD,EAAa,QAAO;AAErC,YAAME,IAAYD,EAAS,QAAQ,WAAW,OAAO;AAErD,aADc,IAAI,OAAO,IAAIC,CAAS,GAAG,EAC5B,KAAKF,CAAW;AAAA,IAC/B,CAAC;AAAA,EACH,GAAG,CAACL,GAAWD,CAAa,CAAC;AAE7B,SACES,EAAQR,CAAS,KACjBQ,EAAQT,CAAa,KACrB,OAAOC,IAAc,MAEd,CAACC,IAGHC;AACT;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useAuthority.d.ts","sourceRoot":"","sources":["../../../../../lib/@ecme/utils/hooks/useAuthority.ts"],"names":[],"mappings":"AAGA,iBAAS,YAAY,
|
|
1
|
+
{"version":3,"file":"useAuthority.d.ts","sourceRoot":"","sources":["../../../../../lib/@ecme/utils/hooks/useAuthority.ts"],"names":[],"mappings":"AAGA,iBAAS,YAAY,CACnB,aAAa,GAAE,MAAM,EAAO,EAC5B,SAAS,GAAE,MAAM,EAAO,EACxB,UAAU,UAAQ,WA4BnB;AAED,eAAe,YAAY,CAAC"}
|