@orbe-agro/client-core 5.3.37 → 5.3.38
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,19 +1,20 @@
|
|
|
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 u(t = [], n = [], c = !1) {
|
|
4
|
+
const a = f(() => {
|
|
5
|
+
if (n.some((e) => t.includes(e)))
|
|
6
6
|
return !0;
|
|
7
7
|
const r = window.location.pathname;
|
|
8
|
-
return
|
|
9
|
-
if (
|
|
10
|
-
|
|
11
|
-
|
|
8
|
+
return t.some((e) => {
|
|
9
|
+
if (!e) return !1;
|
|
10
|
+
if (e === r) return !0;
|
|
11
|
+
const s = e.replace(/:[^/]+/g, "[^/]+");
|
|
12
|
+
return new RegExp(`^${s}$`).test(r);
|
|
12
13
|
});
|
|
13
|
-
}, [n,
|
|
14
|
-
return o(n) && o(
|
|
14
|
+
}, [n, t]);
|
|
15
|
+
return o(n) && o(t) && typeof n > "u" ? !c : a;
|
|
15
16
|
}
|
|
16
17
|
export {
|
|
17
|
-
|
|
18
|
+
u as default
|
|
18
19
|
};
|
|
19
20
|
//# sourceMappingURL=useAuthority.js.map
|
|
@@ -1 +1 @@
|
|
|
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
|
|
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 const pathMatched = userAuthority.some((userPath) => {\n if (!userPath) return false;\n\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\n return pathMatched;\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;AAYpC,WAVoBN,EAAc,KAAK,CAACO,MAAa;AACnD,UAAI,CAACA,EAAU,QAAO;AAEtB,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,EAGH,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,CACnB,aAAa,GAAE,MAAM,EAAO,EAC5B,SAAS,GAAE,MAAM,EAAO,EACxB,UAAU,UAAQ,
|
|
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,WAgCnB;AAED,eAAe,YAAY,CAAC"}
|