@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 i(e = [], n = [], c = !1) {
4
- const s = f(() => {
5
- if (n.some((t) => e.includes(t)))
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 e.some((t) => {
9
- if (t === r) return !0;
10
- const a = t.replace(/:[^/]+/g, "[^/]+");
11
- return new RegExp(`^${a}$`).test(r);
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, e]);
14
- return o(n) && o(e) && typeof n > "u" ? !c : s;
14
+ }, [n, t]);
15
+ return o(n) && o(t) && typeof n > "u" ? !c : a;
15
16
  }
16
17
  export {
17
- i as default
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 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
+ {"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,WA4BnB;AAED,eAAe,YAAY,CAAC"}
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"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@orbe-agro/client-core",
3
- "version": "5.3.37",
3
+ "version": "5.3.38",
4
4
  "description": "Biblioteca principal de componentes e utilidades para os microfrontends do Orbe Agro.",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",