@orbe-agro/client-core 5.6.122 → 5.6.124

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.
Files changed (70) hide show
  1. package/dist/@ecme/assets/styles/app.css +15 -0
  2. package/dist/@ecme/assets/styles/tailwind/index.css +15 -0
  3. package/dist/@ecme/components/template/VerticalMenuContent/VerticalMenuContent.js +31 -6
  4. package/dist/@ecme/components/template/VerticalMenuContent/VerticalMenuContent.js.map +1 -1
  5. package/dist/@ecme/components/template/VerticalMenuContent/VerticalMenuContent.stories.js +234 -0
  6. package/dist/@ecme/components/template/VerticalMenuContent/VerticalMenuContent.stories.js.map +1 -0
  7. package/dist/@ecme/components/template/VerticalMenuContent/VerticalSingleMenuItem.js +18 -40
  8. package/dist/@ecme/components/template/VerticalMenuContent/VerticalSingleMenuItem.js.map +1 -1
  9. package/dist/@ecme/components/ui/Button/Button.stories.js +17 -0
  10. package/dist/@ecme/components/ui/Button/Button.stories.js.map +1 -0
  11. package/dist/@types/@ecme/components/template/VerticalMenuContent/VerticalMenuContent.d.ts +3 -3
  12. package/dist/@types/@ecme/components/template/VerticalMenuContent/VerticalMenuContent.d.ts.map +1 -1
  13. package/dist/@types/@ecme/components/template/VerticalMenuContent/VerticalSingleMenuItem.d.ts +3 -3
  14. package/dist/@types/@ecme/components/template/VerticalMenuContent/VerticalSingleMenuItem.d.ts.map +1 -1
  15. package/dist/@types/@ecme/components/ui/Button/Button.stories.d.ts +9 -0
  16. package/dist/@types/@ecme/components/ui/Button/Button.stories.d.ts.map +1 -0
  17. package/dist/@types/base/@types/models/ativos/centralAtivosUser.d.ts +42 -0
  18. package/dist/@types/base/@types/models/ativos/centralAtivosUser.d.ts.map +1 -0
  19. package/dist/@types/base/@types/models/ativos/tipo.d.ts +1 -0
  20. package/dist/@types/base/@types/models/ativos/tipo.d.ts.map +1 -1
  21. package/dist/@types/base/configs/endpoints.config/ativos/ativos.d.ts +26 -0
  22. package/dist/@types/base/configs/endpoints.config/ativos/ativos.d.ts.map +1 -1
  23. package/dist/@types/base/configs/endpoints.config/ativos/config/centralAtivosUser.d.ts +24 -0
  24. package/dist/@types/base/configs/endpoints.config/ativos/config/centralAtivosUser.d.ts.map +1 -0
  25. package/dist/@types/base/configs/endpoints.config/ativos/config/tipo.d.ts +4 -0
  26. package/dist/@types/base/configs/endpoints.config/ativos/config/tipo.d.ts.map +1 -1
  27. package/dist/@types/base/configs/endpoints.config/endpoints.navigation.d.ts +26 -0
  28. package/dist/@types/base/configs/endpoints.config/endpoints.navigation.d.ts.map +1 -1
  29. package/dist/@types/base/configs/navigation.config/submenu/ativos/ativos.submenu.d.ts.map +1 -1
  30. package/dist/@types/base/configs/navigation.config/submenu/ativos/config/centralAtivosUser.submenu.d.ts +4 -0
  31. package/dist/@types/base/configs/navigation.config/submenu/ativos/config/centralAtivosUser.submenu.d.ts.map +1 -0
  32. package/dist/@types/base/services/modules/ativos/centralAtivosUser/CentralAtivosUserService.d.ts +8 -0
  33. package/dist/@types/base/services/modules/ativos/centralAtivosUser/CentralAtivosUserService.d.ts.map +1 -0
  34. package/dist/@types/base/services/modules/ativos/tipo/TipoService.d.ts +4 -0
  35. package/dist/@types/base/services/modules/ativos/tipo/TipoService.d.ts.map +1 -1
  36. package/dist/base/@types/models/ativos/centralAtivosUser.js +2 -0
  37. package/dist/base/@types/models/ativos/centralAtivosUser.js.map +1 -0
  38. package/dist/base/assets/styles/init.css +15 -0
  39. package/dist/base/configs/endpoints.config/ativos/ativos.js +2 -0
  40. package/dist/base/configs/endpoints.config/ativos/ativos.js.map +1 -1
  41. package/dist/base/configs/endpoints.config/ativos/config/centralAtivosUser.js +12 -0
  42. package/dist/base/configs/endpoints.config/ativos/config/centralAtivosUser.js.map +1 -0
  43. package/dist/base/configs/endpoints.config/ativos/config/tipo.js +2 -1
  44. package/dist/base/configs/endpoints.config/ativos/config/tipo.js.map +1 -1
  45. package/dist/base/configs/navigation.config/submenu/ativos/ativos.submenu.js +2 -0
  46. package/dist/base/configs/navigation.config/submenu/ativos/ativos.submenu.js.map +1 -1
  47. package/dist/base/configs/navigation.config/submenu/ativos/config/centralAtivosUser.submenu.js +16 -0
  48. package/dist/base/configs/navigation.config/submenu/ativos/config/centralAtivosUser.submenu.js.map +1 -0
  49. package/dist/base/index.js +2 -1
  50. package/dist/base/services/index.js +2 -1
  51. package/dist/base/services/modules/ativos/centralAtivosUser/CentralAtivosUserService.js +44 -0
  52. package/dist/base/services/modules/ativos/centralAtivosUser/CentralAtivosUserService.js.map +1 -0
  53. package/dist/base/services/modules/ativos/index.js +2 -1
  54. package/dist/base/services/modules/ativos/tipo/TipoService.js +8 -0
  55. package/dist/base/services/modules/ativos/tipo/TipoService.js.map +1 -1
  56. package/dist/base/services/modules/index.js +2 -1
  57. package/lib/@ecme/components/template/VerticalMenuContent/VerticalMenuContent.stories.tsx +244 -0
  58. package/lib/@ecme/components/template/VerticalMenuContent/VerticalMenuContent.tsx +203 -172
  59. package/lib/@ecme/components/template/VerticalMenuContent/VerticalSingleMenuItem.tsx +135 -157
  60. package/lib/@ecme/components/ui/Button/Button.stories.tsx +22 -0
  61. package/lib/base/@types/models/ativos/centralAtivosUser.ts +42 -0
  62. package/lib/base/@types/models/ativos/tipo.ts +1 -0
  63. package/lib/base/configs/endpoints.config/ativos/ativos.ts +2 -0
  64. package/lib/base/configs/endpoints.config/ativos/config/centralAtivosUser.ts +11 -0
  65. package/lib/base/configs/endpoints.config/ativos/config/tipo.ts +1 -0
  66. package/lib/base/configs/navigation.config/submenu/ativos/ativos.submenu.ts +2 -0
  67. package/lib/base/configs/navigation.config/submenu/ativos/config/centralAtivosUser.submenu.ts +16 -0
  68. package/lib/base/services/modules/ativos/centralAtivosUser/CentralAtivosUserService.ts +44 -0
  69. package/lib/base/services/modules/ativos/tipo/TipoService.ts +8 -0
  70. package/package.json +9 -1
@@ -1 +1 @@
1
- {"version":3,"file":"TipoService.js","sources":["../../../../../../lib/base/services/modules/ativos/tipo/TipoService.ts"],"sourcesContent":["import ApiService from \"@/services/ApiService\";\nimport { IFilterParams, TQueryResponse } from \"@base/@types/api\";\nimport { TTipo } from \"@base/@types/models/ativos/tipo\";\nimport endpointConfig from \"@base/configs/endpoints.config/endpoints.navigation\";\n\nconst TIPO_ENDPOINT = endpointConfig.ativos.tipo;\n\nexport async function apiGetAtivosTipo(id: number) {\n return ApiService.fetchDataWithAxios<TTipo>({\n url: TIPO_ENDPOINT.findOne.endpoint + `${id}`,\n method: TIPO_ENDPOINT.findOne.method,\n })\n}\n\nexport async function apiAddAtivosTipo(body: TTipo) {\n return ApiService.fetchDataWithAxios<TQueryResponse<TTipo>>({\n url: TIPO_ENDPOINT.add.endpoint,\n method: TIPO_ENDPOINT.add.method,\n data: body,\n })\n}\n\nexport async function apiUpdateAtivosTipo(body: TTipo) {\n return ApiService.fetchDataWithAxios<TQueryResponse<TTipo>>({\n url: TIPO_ENDPOINT.update.endpoint,\n method: TIPO_ENDPOINT.update.method,\n data: body,\n })\n}\n\nexport async function apiDeleteAtivosTipo(id: number) {\n return ApiService.fetchDataWithAxios<TQueryResponse<TTipo>>({\n url: TIPO_ENDPOINT.delete.endpoint + `${id}`,\n method: TIPO_ENDPOINT.delete.method,\n })\n}\n\nexport async function apiFindMonitorAtivosTipo(body?: IFilterParams) {\n return ApiService.fetchDataWithAxios<TQueryResponse<TTipo>>({\n url: TIPO_ENDPOINT.findMonitor.endpoint,\n method: TIPO_ENDPOINT.findMonitor.method,\n data: body,\n })\n}\n"],"names":["endpointConfig"],"mappings":";;AAKA,MAAM,gBAAgBA,yBAAe,OAAO;AAE5C,eAAsB,iBAAiB,IAAY;AAC/C,SAAO,WAAW,mBAA0B;AAAA,IACxC,KAAK,cAAc,QAAQ,WAAW,GAAG,EAAE;AAAA,IAC3C,QAAQ,cAAc,QAAQ;AAAA,EAAA,CACjC;AACL;AAEA,eAAsB,iBAAiB,MAAa;AAChD,SAAO,WAAW,mBAA0C;AAAA,IACxD,KAAK,cAAc,IAAI;AAAA,IACvB,QAAQ,cAAc,IAAI;AAAA,IAC1B,MAAM;AAAA,EAAA,CACT;AACL;AAEA,eAAsB,oBAAoB,MAAa;AACnD,SAAO,WAAW,mBAA0C;AAAA,IACxD,KAAK,cAAc,OAAO;AAAA,IAC1B,QAAQ,cAAc,OAAO;AAAA,IAC7B,MAAM;AAAA,EAAA,CACT;AACL;AAEA,eAAsB,oBAAoB,IAAY;AAClD,SAAO,WAAW,mBAA0C;AAAA,IACxD,KAAK,cAAc,OAAO,WAAW,GAAG,EAAE;AAAA,IAC1C,QAAQ,cAAc,OAAO;AAAA,EAAA,CAChC;AACL;AAEA,eAAsB,yBAAyB,MAAsB;AACjE,SAAO,WAAW,mBAA0C;AAAA,IACxD,KAAK,cAAc,YAAY;AAAA,IAC/B,QAAQ,cAAc,YAAY;AAAA,IAClC,MAAM;AAAA,EAAA,CACT;AACL;"}
1
+ {"version":3,"file":"TipoService.js","sources":["../../../../../../lib/base/services/modules/ativos/tipo/TipoService.ts"],"sourcesContent":["import ApiService from \"@/services/ApiService\";\nimport { IFilterParams, TQueryResponse } from \"@base/@types/api\";\nimport { TTipo } from \"@base/@types/models/ativos/tipo\";\nimport endpointConfig from \"@base/configs/endpoints.config/endpoints.navigation\";\n\nconst TIPO_ENDPOINT = endpointConfig.ativos.tipo;\n\nexport async function apiGetAtivosTipo(id: number) {\n return ApiService.fetchDataWithAxios<TTipo>({\n url: TIPO_ENDPOINT.findOne.endpoint + `${id}`,\n method: TIPO_ENDPOINT.findOne.method,\n })\n}\n\nexport async function apiAddAtivosTipo(body: TTipo) {\n return ApiService.fetchDataWithAxios<TQueryResponse<TTipo>>({\n url: TIPO_ENDPOINT.add.endpoint,\n method: TIPO_ENDPOINT.add.method,\n data: body,\n })\n}\n\nexport async function apiUpdateAtivosTipo(body: TTipo) {\n return ApiService.fetchDataWithAxios<TQueryResponse<TTipo>>({\n url: TIPO_ENDPOINT.update.endpoint,\n method: TIPO_ENDPOINT.update.method,\n data: body,\n })\n}\n\nexport async function apiDeleteAtivosTipo(id: number) {\n return ApiService.fetchDataWithAxios<TQueryResponse<TTipo>>({\n url: TIPO_ENDPOINT.delete.endpoint + `${id}`,\n method: TIPO_ENDPOINT.delete.method,\n })\n}\n\nexport async function apiFindMonitorAtivosTipo(body?: IFilterParams) {\n return ApiService.fetchDataWithAxios<TQueryResponse<TTipo>>({\n url: TIPO_ENDPOINT.findMonitor.endpoint,\n method: TIPO_ENDPOINT.findMonitor.method,\n data: body,\n })\n}\n\nexport async function apiFindByTipoAndFormulario(body: { tipo: string; formularioCamposId?: number | null }) {\n return ApiService.fetchDataWithAxios<any[]>({\n url: TIPO_ENDPOINT.findByTipoAndFormulario.endpoint,\n method: TIPO_ENDPOINT.findByTipoAndFormulario.method,\n data: body,\n })\n}\n"],"names":["endpointConfig"],"mappings":";;AAKA,MAAM,gBAAgBA,yBAAe,OAAO;AAE5C,eAAsB,iBAAiB,IAAY;AAC/C,SAAO,WAAW,mBAA0B;AAAA,IACxC,KAAK,cAAc,QAAQ,WAAW,GAAG,EAAE;AAAA,IAC3C,QAAQ,cAAc,QAAQ;AAAA,EAAA,CACjC;AACL;AAEA,eAAsB,iBAAiB,MAAa;AAChD,SAAO,WAAW,mBAA0C;AAAA,IACxD,KAAK,cAAc,IAAI;AAAA,IACvB,QAAQ,cAAc,IAAI;AAAA,IAC1B,MAAM;AAAA,EAAA,CACT;AACL;AAEA,eAAsB,oBAAoB,MAAa;AACnD,SAAO,WAAW,mBAA0C;AAAA,IACxD,KAAK,cAAc,OAAO;AAAA,IAC1B,QAAQ,cAAc,OAAO;AAAA,IAC7B,MAAM;AAAA,EAAA,CACT;AACL;AAEA,eAAsB,oBAAoB,IAAY;AAClD,SAAO,WAAW,mBAA0C;AAAA,IACxD,KAAK,cAAc,OAAO,WAAW,GAAG,EAAE;AAAA,IAC1C,QAAQ,cAAc,OAAO;AAAA,EAAA,CAChC;AACL;AAEA,eAAsB,yBAAyB,MAAsB;AACjE,SAAO,WAAW,mBAA0C;AAAA,IACxD,KAAK,cAAc,YAAY;AAAA,IAC/B,QAAQ,cAAc,YAAY;AAAA,IAClC,MAAM;AAAA,EAAA,CACT;AACL;AAEA,eAAsB,2BAA2B,MAA4D;AACzG,SAAO,WAAW,mBAA0B;AAAA,IACxC,KAAK,cAAc,wBAAwB;AAAA,IAC3C,QAAQ,cAAc,wBAAwB;AAAA,IAC9C,MAAM;AAAA,EAAA,CACT;AACL;"}
@@ -30,7 +30,7 @@ import { apiAddAtivosProcessador, apiDeleteAtivosProcessador, apiFindMonitorAtiv
30
30
  import { apiAddAtivosSistemaOperacional, apiDeleteAtivosSistemaOperacional, apiFindMonitorAtivosSistemaOperacional, apiGetAtivosSistemaOperacional, apiUpdateAtivosSistemaOperacional } from "./ativos/sistemaOperacional/SistemaOperacionalService.js";
31
31
  import { apiAddAtivosSoftware, apiDeleteAtivosSoftware, apiFindMonitorAtivosSoftware, apiGetAtivosSoftware, apiUpdateAtivosSoftware } from "./ativos/software/SoftwareService.js";
32
32
  import { apiAddAtivosSubcategoria, apiDeleteAtivosSubcategoria, apiFindMonitorAtivosSubcategoria, apiGetAtivosSubcategoria, apiUpdateAtivosSubcategoria } from "./ativos/subcategoria/SubcategoriaService.js";
33
- import { apiAddAtivosTipo, apiDeleteAtivosTipo, apiFindMonitorAtivosTipo, apiGetAtivosTipo, apiUpdateAtivosTipo } from "./ativos/tipo/TipoService.js";
33
+ import { apiAddAtivosTipo, apiDeleteAtivosTipo, apiFindByTipoAndFormulario, apiFindMonitorAtivosTipo, apiGetAtivosTipo, apiUpdateAtivosTipo } from "./ativos/tipo/TipoService.js";
34
34
  import { apiAddAtivosVersaoAndroid, apiDeleteAtivosVersaoAndroid, apiFindMonitorAtivosVersaoAndroid, apiGetAtivosVersaoAndroid, apiUpdateAtivosVersaoAndroid } from "./ativos/versaoAndroid/VersaoAndroidService.js";
35
35
  import { apiAddAtivosVersaoMSOffice, apiDeleteAtivosVersaoMSOffice, apiFindMonitorAtivosVersaoMSOffice, apiGetAtivosVersaoMSOffice, apiUpdateAtivosVersaoMSOffice } from "./ativos/versaoMSOffice/VersaoMSOfficeService.js";
36
36
  import { apiAddAtivosVlan, apiDeleteAtivosVlan, apiFindMonitorAtivosVlan, apiGetAtivosVlan, apiUpdateAtivosVlan } from "./ativos/vlan/VlanService.js";
@@ -383,6 +383,7 @@ export {
383
383
  apiFindByIdsProduto,
384
384
  apiFindByNomeOrCodigo,
385
385
  apiFindByNotaFiscal,
386
+ apiFindByTipoAndFormulario,
386
387
  apiFindCalculoFrete,
387
388
  apiFindCartaoPortadorFreteByTipoBusca,
388
389
  apiFindCentrosByUserId,
@@ -0,0 +1,244 @@
1
+ import type { Meta, StoryObj } from '@storybook/react'
2
+ import { BrowserRouter } from 'react-router-dom'
3
+ import VerticalMenuContent from './VerticalMenuContent'
4
+ import type { NavigationTree } from '@/@types/navigation'
5
+ import {
6
+ NAV_ITEM_TYPE_COLLAPSE,
7
+ NAV_ITEM_TYPE_ITEM,
8
+ } from '@/constants/navigation.constant'
9
+
10
+ const mockNavigationTree: NavigationTree[] = [
11
+ {
12
+ key: 'inicio',
13
+ path: '/inicio',
14
+ title: 'Início',
15
+ translateKey: 'nav.inicio',
16
+ icon: '',
17
+ type: NAV_ITEM_TYPE_ITEM,
18
+ authority: ['/inicio'],
19
+ subMenu: [],
20
+ },
21
+ {
22
+ key: 'cadastros',
23
+ path: '',
24
+ title: 'Cadastros',
25
+ translateKey: 'nav.cadastros',
26
+ icon: '',
27
+ type: NAV_ITEM_TYPE_COLLAPSE,
28
+ authority: ['/cadastros'],
29
+ subMenu: [
30
+ {
31
+ key: 'clientes',
32
+ path: '/cadastros/clientes',
33
+ title: 'Clientes',
34
+ translateKey: 'nav.clientes',
35
+ icon: '',
36
+ type: NAV_ITEM_TYPE_ITEM,
37
+ authority: ['/cadastros/clientes'],
38
+ subMenu: [],
39
+ },
40
+ {
41
+ key: 'fornecedores',
42
+ path: '/cadastros/fornecedores',
43
+ title: 'Fornecedores',
44
+ translateKey: 'nav.fornecedores',
45
+ icon: '',
46
+ type: NAV_ITEM_TYPE_ITEM,
47
+ authority: ['/cadastros/fornecedores'],
48
+ subMenu: [],
49
+ },
50
+ ],
51
+ },
52
+ {
53
+ key: 'relatorios',
54
+ path: '/relatorios',
55
+ title: 'Relatórios',
56
+ translateKey: 'nav.relatorios',
57
+ icon: 'ChartBarIcon',
58
+ type: NAV_ITEM_TYPE_ITEM,
59
+ authority: ['/relatorios'],
60
+ subMenu: [],
61
+ },
62
+ {
63
+ key: 'configuracoes',
64
+ path: '',
65
+ title: 'Configurações',
66
+ translateKey: 'nav.configuracoes',
67
+ icon: '',
68
+ type: NAV_ITEM_TYPE_COLLAPSE,
69
+ authority: ['/configuracoes'],
70
+ subMenu: [
71
+ {
72
+ key: 'perfil',
73
+ path: '/configuracoes/perfil',
74
+ title: 'Perfil',
75
+ translateKey: 'nav.perfil',
76
+ icon: '',
77
+ type: NAV_ITEM_TYPE_ITEM,
78
+ authority: ['/configuracoes/perfil'],
79
+ subMenu: [],
80
+ },
81
+ {
82
+ key: 'integracoes',
83
+ path: '',
84
+ title: 'Integrações',
85
+ translateKey: 'nav.integracoes',
86
+ icon: '',
87
+ type: NAV_ITEM_TYPE_COLLAPSE,
88
+ authority: ['/configuracoes/integracoes'],
89
+ subMenu: [
90
+ {
91
+ key: 'webhooks',
92
+ path: '/configuracoes/integracoes/webhooks',
93
+ title: 'Webhooks',
94
+ translateKey: 'nav.webhooks',
95
+ icon: 'WebhookIcon',
96
+ type: NAV_ITEM_TYPE_ITEM,
97
+ authority: ['/configuracoes/integracoes/webhooks'],
98
+ subMenu: [],
99
+ },
100
+ {
101
+ key: 'lorem.ipsum',
102
+ path: '/configuracoes/integracoes/lorem-ipsum',
103
+ title: 'Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.',
104
+ translateKey: 'nav.loremIpsum',
105
+ icon: 'LoremIpsumIcon',
106
+ type: NAV_ITEM_TYPE_ITEM,
107
+ authority: ['/configuracoes/integracoes/lorem-ipsum'],
108
+ subMenu: [],
109
+ },
110
+ ],
111
+ },
112
+ ],
113
+ },
114
+ ]
115
+
116
+ const allUserAuthority = [
117
+ '/inicio',
118
+ '/cadastros/clientes',
119
+ '/cadastros/fornecedores',
120
+ '/relatorios',
121
+ '/configuracoes/perfil',
122
+ '/configuracoes/integracoes/webhooks',
123
+ '/configuracoes/integracoes/lorem-ipsum',
124
+ ]
125
+
126
+ const meta = {
127
+ title: '@ecme/Template/VerticalMenuContent',
128
+ component: VerticalMenuContent,
129
+ parameters: {
130
+ layout: 'padded',
131
+ },
132
+ tags: ['autodocs'],
133
+ decorators: [
134
+ (Story) => (
135
+ <BrowserRouter>
136
+ <Story />
137
+ </BrowserRouter>
138
+ ),
139
+ ],
140
+ argTypes: {
141
+ collapsed: {
142
+ control: 'boolean',
143
+ },
144
+ direction: {
145
+ control: { type: 'select' },
146
+ options: ['ltr', 'rtl'],
147
+ },
148
+ routeKey: {
149
+ control: 'text',
150
+ },
151
+ },
152
+ } satisfies Meta<typeof VerticalMenuContent>
153
+
154
+ export default meta
155
+ type TStory = StoryObj<typeof meta>
156
+
157
+ export const Default: TStory = {
158
+ args: {
159
+ collapsed: false,
160
+ routeKey: '/inicio',
161
+ navigationTree: mockNavigationTree,
162
+ userAuthority: allUserAuthority,
163
+ direction: 'ltr',
164
+ translationSetup: true,
165
+ },
166
+ }
167
+
168
+ export const Collapsed: TStory = {
169
+ args: {
170
+ collapsed: true,
171
+ routeKey: '/cadastros/clientes',
172
+ navigationTree: mockNavigationTree,
173
+ userAuthority: allUserAuthority,
174
+ direction: 'ltr',
175
+ translationSetup: true,
176
+ },
177
+ }
178
+
179
+ export const WithExpandedMenu: TStory = {
180
+ args: {
181
+ collapsed: false,
182
+ routeKey: '/configuracoes/integracoes/webhooks',
183
+ navigationTree: mockNavigationTree,
184
+ userAuthority: allUserAuthority,
185
+ direction: 'ltr',
186
+ translationSetup: true,
187
+ },
188
+ }
189
+
190
+ export const LimitedAuthority: TStory = {
191
+ args: {
192
+ collapsed: false,
193
+ routeKey: '/inicio',
194
+ navigationTree: mockNavigationTree,
195
+ userAuthority: ['/inicio', '/relatorios'],
196
+ direction: 'ltr',
197
+ translationSetup: true,
198
+ },
199
+ }
200
+
201
+ export const RTLDirection: TStory = {
202
+ args: {
203
+ collapsed: false,
204
+ routeKey: '/inicio',
205
+ navigationTree: mockNavigationTree,
206
+ userAuthority: allUserAuthority,
207
+ direction: 'rtl',
208
+ translationSetup: true,
209
+ },
210
+ }
211
+
212
+ export const MinimalNavigation: TStory = {
213
+ args: {
214
+ collapsed: false,
215
+ routeKey: '/inicio',
216
+ navigationTree: [
217
+ {
218
+ key: 'inicio',
219
+ path: '/inicio',
220
+ title: 'Início',
221
+ translateKey: 'nav.inicio',
222
+ icon: '',
223
+ type: NAV_ITEM_TYPE_ITEM,
224
+ authority: ['/inicio'],
225
+ subMenu: [],
226
+ },
227
+ ],
228
+ userAuthority: ['/inicio'],
229
+ direction: 'ltr',
230
+ translationSetup: true,
231
+ },
232
+ }
233
+
234
+ export const WithMenuClick: TStory = {
235
+ args: {
236
+ collapsed: false,
237
+ routeKey: '/inicio',
238
+ navigationTree: mockNavigationTree,
239
+ userAuthority: allUserAuthority,
240
+ direction: 'ltr',
241
+ translationSetup: true,
242
+ onMenuItemClick: () => alert('Menu item clicked!'),
243
+ },
244
+ }
@@ -1,192 +1,223 @@
1
- import { useState, useEffect, useMemo, Fragment } from "react";
2
- import Menu from "@/components/ui/Menu";
3
- import VerticalSingleMenuItem from "./VerticalSingleMenuItem";
4
- import VerticalCollapsedMenuItem from "./VerticalCollapsedMenuItem";
5
- import { themeConfig } from "@/configs/theme.config";
1
+ import { useState, useEffect, useMemo, Fragment } from 'react'
2
+ import Menu from '@/components/ui/Menu'
3
+ import VerticalSingleMenuItem from './VerticalSingleMenuItem'
4
+ import VerticalCollapsedMenuItem from './VerticalCollapsedMenuItem'
5
+ import { themeConfig } from '@/configs/theme.config'
6
6
  import {
7
- NAV_ITEM_TYPE_TITLE,
8
- NAV_ITEM_TYPE_COLLAPSE,
9
- NAV_ITEM_TYPE_ITEM,
10
- } from "@/constants/navigation.constant";
11
- import useMenuActive from "@/utils/hooks/useMenuActive";
12
- import useTranslation from "@/utils/hooks/useTranslation";
13
- import { Direction } from "@/@types/theme";
14
- import type { NavigationTree } from "@/@types/navigation";
15
- import type { TraslationFn } from "@/@types/common";
16
- import { LinkRenderer } from "@/components/layouts/Layouts";
7
+ NAV_ITEM_TYPE_TITLE,
8
+ NAV_ITEM_TYPE_COLLAPSE,
9
+ NAV_ITEM_TYPE_ITEM,
10
+ } from '@/constants/navigation.constant'
11
+ import useMenuActive from '@/utils/hooks/useMenuActive'
12
+ import useTranslation from '@/utils/hooks/useTranslation'
13
+ import { Direction } from '@/@types/theme'
14
+ import type { NavigationTree } from '@/@types/navigation'
15
+ import type { TraslationFn } from '@/@types/common'
16
+ import { LinkRenderer } from '@/components/layouts/Layouts'
17
17
 
18
18
  export interface VerticalMenuContentProps {
19
- collapsed?: boolean;
20
- routeKey: string;
21
- navigationTree?: NavigationTree[];
22
- onMenuItemClick?: () => void;
23
- direction?: Direction;
24
- translationSetup?: boolean;
25
- userAuthority: string[];
26
- linkRenderer?: LinkRenderer;
19
+ collapsed?: boolean
20
+ routeKey: string
21
+ navigationTree?: NavigationTree[]
22
+ onMenuItemClick?: () => void
23
+ direction?: Direction
24
+ translationSetup?: boolean
25
+ userAuthority: string[]
26
+ linkRenderer?: LinkRenderer
27
27
  }
28
28
 
29
- const { MenuGroup } = Menu;
29
+ const { MenuGroup } = Menu
30
30
 
31
31
  const findAncestorKeys = (
32
- navTree: NavigationTree[],
33
- targetKey: string
32
+ navTree: NavigationTree[],
33
+ targetKey: string,
34
34
  ): string[] | null => {
35
- for (const node of navTree) {
36
- if (node.key === targetKey) return [];
37
- if (node.subMenu && node.subMenu.length > 0) {
38
- const found = findAncestorKeys(node.subMenu, targetKey);
39
- if (found !== null) return [node.key, ...found];
35
+ for (const node of navTree) {
36
+ if (node.key === targetKey) return []
37
+ if (node.subMenu && node.subMenu.length > 0) {
38
+ const found = findAncestorKeys(node.subMenu, targetKey)
39
+ if (found !== null) return [node.key, ...found]
40
+ }
40
41
  }
41
- }
42
- return null;
43
- };
42
+ return null
43
+ }
44
44
 
45
45
  const filterNavigationByAuthority = (
46
- navTree: NavigationTree[],
47
- userAuthority: string[]
46
+ navTree: NavigationTree[],
47
+ userAuthority: string[],
48
48
  ): NavigationTree[] => {
49
- return navTree.reduce((acc: NavigationTree[], nav) => {
50
- // Verifica se deve excluir o item quando o usuário possui alguma funcionalidade específica
51
- if (nav.excludeWhenHasPaths && nav.excludeWhenHasPaths.length > 0) {
52
- const shouldExclude = nav.excludeWhenHasPaths.some((path) =>
53
- userAuthority.includes(path)
54
- );
55
- if (shouldExclude) {
56
- return acc;
57
- }
58
- }
49
+ return navTree.reduce((acc: NavigationTree[], nav) => {
50
+ // Verifica se deve excluir o item quando o usuário possui alguma funcionalidade específica
51
+ if (nav.excludeWhenHasPaths && nav.excludeWhenHasPaths.length > 0) {
52
+ const shouldExclude = nav.excludeWhenHasPaths.some((path) =>
53
+ userAuthority.includes(path),
54
+ )
55
+ if (shouldExclude) {
56
+ return acc
57
+ }
58
+ }
59
59
 
60
- if (nav.subMenu && nav.subMenu.length > 0) {
61
- const filteredSubMenu = filterNavigationByAuthority(
62
- nav.subMenu,
63
- userAuthority
64
- );
65
- if (filteredSubMenu.length > 0) {
66
- acc.push({ ...nav, subMenu: filteredSubMenu });
67
- }
68
- } else {
69
- if ((nav.path && userAuthority.includes(nav.path)) || !nav.path) {
70
- acc.push(nav);
71
- }
72
- }
73
- return acc;
74
- }, []);
75
- };
60
+ if (nav.subMenu && nav.subMenu.length > 0) {
61
+ const filteredSubMenu = filterNavigationByAuthority(
62
+ nav.subMenu,
63
+ userAuthority,
64
+ )
65
+ if (filteredSubMenu.length > 0) {
66
+ acc.push({ ...nav, subMenu: filteredSubMenu })
67
+ }
68
+ } else {
69
+ if ((nav.path && userAuthority.includes(nav.path)) || !nav.path) {
70
+ acc.push(nav)
71
+ }
72
+ }
73
+ return acc
74
+ }, [])
75
+ }
76
+
77
+ const sortNavigationRecursively = (
78
+ navTree: NavigationTree[],
79
+ ): NavigationTree[] => {
80
+ return [...navTree]
81
+ .map((nav) => ({
82
+ ...nav,
83
+ subMenu: nav.subMenu
84
+ ? sortNavigationRecursively(nav.subMenu)
85
+ : nav.subMenu,
86
+ }))
87
+ .sort((a, b) => a.title.localeCompare(b.title, 'pt-BR'))
88
+ }
76
89
 
77
90
  const VerticalMenuContent = (props: VerticalMenuContentProps) => {
78
- const {
79
- collapsed,
80
- routeKey,
81
- navigationTree = [],
82
- onMenuItemClick,
83
- direction = themeConfig.direction,
84
- translationSetup,
85
- userAuthority,
86
- linkRenderer,
87
- } = props;
88
-
89
- const { t } = useTranslation(!translationSetup);
90
- const [defaulExpandKey, setDefaulExpandKey] = useState<string[]>([]);
91
- const filteredNavigationTree = useMemo(
92
- () => filterNavigationByAuthority(navigationTree, userAuthority),
93
- [navigationTree, userAuthority]
94
- );
95
-
96
- const { activedRoute } = useMenuActive(filteredNavigationTree, routeKey);
97
-
98
- useEffect(() => {
99
- if (activedRoute?.key) {
100
- const ancestors = findAncestorKeys(
101
- filteredNavigationTree,
102
- activedRoute.key
103
- );
104
- setDefaulExpandKey(ancestors ?? []);
91
+ const {
92
+ collapsed,
93
+ routeKey,
94
+ navigationTree = [],
95
+ onMenuItemClick,
96
+ direction = themeConfig.direction,
97
+ translationSetup,
98
+ userAuthority,
99
+ linkRenderer,
100
+ } = props
101
+
102
+ const { t } = useTranslation(!translationSetup)
103
+ const [defaulExpandKey, setDefaulExpandKey] = useState<string[]>([])
104
+
105
+ const filteredNavigationTree = useMemo(() => {
106
+ const filteredTree = filterNavigationByAuthority(
107
+ navigationTree,
108
+ userAuthority,
109
+ )
110
+
111
+ return sortNavigationRecursively(filteredTree)
112
+ }, [navigationTree, userAuthority])
113
+
114
+ console.log('Filtered Navigation Tree:', filteredNavigationTree)
115
+
116
+ const { activedRoute } = useMenuActive(filteredNavigationTree, routeKey)
117
+
118
+ useEffect(() => {
119
+ if (activedRoute?.key) {
120
+ const ancestors = findAncestorKeys(
121
+ filteredNavigationTree,
122
+ activedRoute.key,
123
+ )
124
+ setDefaulExpandKey(ancestors ?? [])
125
+ }
126
+ }, [activedRoute?.key, filteredNavigationTree])
127
+
128
+ const handleLinkClick = () => {
129
+ onMenuItemClick?.()
105
130
  }
106
- }, [activedRoute?.key, filteredNavigationTree]);
107
131
 
108
- const handleLinkClick = () => {
109
- onMenuItemClick?.();
110
- };
132
+ const renderNavigation = (
133
+ navTree: NavigationTree[],
134
+ cascade: number = 0,
135
+ indent?: boolean,
136
+ ) => {
137
+ const nextCascade = cascade + 1
111
138
 
112
- const renderNavigation = (
113
- navTree: NavigationTree[],
114
- cascade: number = 0,
115
- indent?: boolean
116
- ) => {
117
- const nextCascade = cascade + 1;
139
+ return (
140
+ <>
141
+ {navTree.map((nav) => (
142
+ <Fragment key={nav.key}>
143
+ {nav.type === NAV_ITEM_TYPE_ITEM && (
144
+ <VerticalSingleMenuItem
145
+ key={nav.key}
146
+ currentKey={activedRoute?.key}
147
+ parentKeys={defaulExpandKey}
148
+ nav={nav}
149
+ sideCollapsed={collapsed}
150
+ direction={direction}
151
+ indent={indent}
152
+ renderAsIcon={cascade <= 0}
153
+ showIcon={cascade <= 0}
154
+ userAuthority={userAuthority}
155
+ showTitle={
156
+ nav.forceShowTitle ??
157
+ (collapsed ? cascade >= 1 : cascade <= 1)
158
+ }
159
+ t={t as TraslationFn}
160
+ onLinkClick={handleLinkClick}
161
+ linkRenderer={linkRenderer}
162
+ />
163
+ )}
164
+ {nav.type === NAV_ITEM_TYPE_COLLAPSE && (
165
+ <VerticalCollapsedMenuItem
166
+ key={nav.key}
167
+ currentKey={activedRoute?.key}
168
+ parentKeys={defaulExpandKey}
169
+ nav={nav}
170
+ sideCollapsed={collapsed}
171
+ direction={direction}
172
+ indent={nextCascade >= 2}
173
+ dotIndent={nextCascade >= 2}
174
+ renderAsIcon={nextCascade <= 1}
175
+ userAuthority={userAuthority}
176
+ t={t as TraslationFn}
177
+ onLinkClick={onMenuItemClick}
178
+ >
179
+ {nav.subMenu &&
180
+ nav.subMenu.length > 0 &&
181
+ renderNavigation(
182
+ nav.subMenu,
183
+ nextCascade,
184
+ true,
185
+ )}
186
+ </VerticalCollapsedMenuItem>
187
+ )}
188
+ {nav.type === NAV_ITEM_TYPE_TITLE && (
189
+ <MenuGroup
190
+ key={nav.key}
191
+ label={t(nav.translateKey) || nav.title}
192
+ >
193
+ {nav.subMenu &&
194
+ nav.subMenu.length > 0 &&
195
+ renderNavigation(
196
+ nav.subMenu,
197
+ cascade,
198
+ false,
199
+ )}
200
+ </MenuGroup>
201
+ )}
202
+ </Fragment>
203
+ ))}
204
+ </>
205
+ )
206
+ }
118
207
 
119
208
  return (
120
- <>
121
- {navTree.map((nav) => (
122
- <Fragment key={nav.key}>
123
- {nav.type === NAV_ITEM_TYPE_ITEM && (
124
- <VerticalSingleMenuItem
125
- key={nav.key}
126
- currentKey={activedRoute?.key}
127
- parentKeys={defaulExpandKey}
128
- nav={nav}
129
- sideCollapsed={collapsed}
130
- direction={direction}
131
- indent={indent}
132
- renderAsIcon={cascade <= 0}
133
- showIcon={cascade <= 0}
134
- userAuthority={userAuthority}
135
- showTitle={
136
- nav.forceShowTitle ??
137
- (collapsed ? cascade >= 1 : cascade <= 1)
138
- }
139
- t={t as TraslationFn}
140
- onLinkClick={handleLinkClick}
141
- linkRenderer={linkRenderer}
142
- />
143
- )}
144
- {nav.type === NAV_ITEM_TYPE_COLLAPSE && (
145
- <VerticalCollapsedMenuItem
146
- key={nav.key}
147
- currentKey={activedRoute?.key}
148
- parentKeys={defaulExpandKey}
149
- nav={nav}
150
- sideCollapsed={collapsed}
151
- direction={direction}
152
- indent={nextCascade >= 2}
153
- dotIndent={nextCascade >= 2}
154
- renderAsIcon={nextCascade <= 1}
155
- userAuthority={userAuthority}
156
- t={t as TraslationFn}
157
- onLinkClick={onMenuItemClick}
158
- >
159
- {nav.subMenu &&
160
- nav.subMenu.length > 0 &&
161
- renderNavigation(nav.subMenu, nextCascade, true)}
162
- </VerticalCollapsedMenuItem>
163
- )}
164
- {nav.type === NAV_ITEM_TYPE_TITLE && (
165
- <MenuGroup key={nav.key} label={t(nav.translateKey) || nav.title}>
166
- {nav.subMenu &&
167
- nav.subMenu.length > 0 &&
168
- renderNavigation(nav.subMenu, cascade, false)}
169
- </MenuGroup>
170
- )}
171
- </Fragment>
172
- ))}
173
- </>
174
- );
175
- };
176
-
177
- return (
178
- <Menu
179
- className="px-4 pb-4"
180
- sideCollapsed={collapsed}
181
- defaultActiveKeys={activedRoute?.key ? [activedRoute.key] : []}
182
- defaultExpandedKeys={defaulExpandKey}
183
- defaultCollapseActiveKeys={
184
- activedRoute?.parentKey ? [activedRoute.parentKey] : []
185
- }
186
- >
187
- {renderNavigation(filteredNavigationTree, 0)}
188
- </Menu>
189
- );
190
- };
191
-
192
- export default VerticalMenuContent;
209
+ <Menu
210
+ className="px-4 pb-4"
211
+ sideCollapsed={collapsed}
212
+ defaultActiveKeys={activedRoute?.key ? [activedRoute.key] : []}
213
+ defaultExpandedKeys={defaulExpandKey}
214
+ defaultCollapseActiveKeys={
215
+ activedRoute?.parentKey ? [activedRoute.parentKey] : []
216
+ }
217
+ >
218
+ {renderNavigation(filteredNavigationTree, 0)}
219
+ </Menu>
220
+ )
221
+ }
222
+
223
+ export default VerticalMenuContent