@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 d(e = [], n = [], t = !1) {
4
- const c = f(() => {
5
- if (n.some((a) => e.includes(a)))
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 s = window.location.pathname;
8
- return e.includes(s);
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" ? !t : c;
14
+ return o(n) && o(e) && typeof n > "u" ? !c : s;
11
15
  }
12
16
  export {
13
- d as default
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 '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 return userAuthority.includes(currentPath);\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","isEmpty"],"mappings":";;AAGA,SAASA,EACLC,IAA0B,CAAA,GAC1BC,IAAsB,CAAA,GACtBC,IAAa,IACf;AACE,QAAMC,IAAcC,EAAQ,MAAM;AAE9B,QADqBH,EAAU,KAAK,CAACI,MAASL,EAAc,SAASK,CAAI,CAAC;AAEtE,aAAO;AAGX,UAAMC,IAAc,OAAO,SAAS;AACpC,WAAON,EAAc,SAASM,CAAW;AAAA,EAC7C,GAAG,CAACL,GAAWD,CAAa,CAAC;AAE7B,SACIO,EAAQN,CAAS,KACjBM,EAAQP,CAAa,KACrB,OAAOC,IAAc,MAEd,CAACC,IAGLC;AACX;"}
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,CACjB,aAAa,GAAE,MAAM,EAAO,EAC5B,SAAS,GAAE,MAAM,EAAO,EACxB,UAAU,UAAQ,WAqBrB;AAED,eAAe,YAAY,CAAA"}
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"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@orbe-agro/client-core",
3
- "version": "5.3.34",
3
+ "version": "5.3.35",
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",