@wavemaker-ai/react-runtime 1.0.0-rc.647502 → 1.0.0-rc.647565

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 (574) hide show
  1. package/.npmignore +4 -0
  2. package/actions/base-action.js +12 -29
  3. package/actions/login-action.js +35 -52
  4. package/actions/logout-action.js +21 -38
  5. package/actions/navigation-action.js +251 -346
  6. package/actions/notification-action.js +121 -149
  7. package/actions/timer-action.js +95 -151
  8. package/actions/toast-provider.js +62 -76
  9. package/actions/toast.js +95 -91
  10. package/actions/toast.service.js +59 -79
  11. package/actions/types/index.js +6 -9
  12. package/components/advanced/carousel/index.js +358 -366
  13. package/components/advanced/carousel/props.js +0 -5
  14. package/components/advanced/carousel/template.js +102 -80
  15. package/components/advanced/login/index.js +227 -285
  16. package/components/advanced/login/props.js +0 -5
  17. package/components/advanced/marquee/index.js +169 -163
  18. package/components/advanced/marquee/props.js +0 -5
  19. package/components/basic/anchor/index.js +207 -187
  20. package/components/basic/anchor/props.js +0 -5
  21. package/components/basic/audio/index.js +110 -72
  22. package/components/basic/audio/props.js +0 -5
  23. package/components/basic/html/index.js +163 -203
  24. package/components/basic/html/props.js +0 -5
  25. package/components/basic/html/utils.js +30 -28
  26. package/components/basic/icon/index.js +98 -84
  27. package/components/basic/icon/props.js +0 -5
  28. package/components/basic/iframe/iframe.utils.js +7 -16
  29. package/components/basic/iframe/index.js +97 -103
  30. package/components/basic/iframe/props.js +0 -5
  31. package/components/basic/label/index.js +156 -134
  32. package/components/basic/label/props.js +0 -5
  33. package/components/basic/message/index.js +129 -113
  34. package/components/basic/message/props.js +0 -5
  35. package/components/basic/picture/index.js +156 -127
  36. package/components/basic/picture/props.js +0 -5
  37. package/components/basic/progress-bar/index.js +240 -176
  38. package/components/basic/progress-bar/props.js +5 -31
  39. package/components/basic/progress-circle/index.js +166 -183
  40. package/components/basic/progress-circle/props.js +14 -34
  41. package/components/basic/richtexteditor/index.js +430 -396
  42. package/components/basic/richtexteditor/props.js +0 -5
  43. package/components/basic/search/index.js +812 -931
  44. package/components/basic/search/props.js +0 -5
  45. package/components/basic/search/providers.js +233 -380
  46. package/components/basic/spinner/index.js +210 -200
  47. package/components/basic/spinner/props.js +4 -22
  48. package/components/basic/tile/index.js +73 -81
  49. package/components/basic/tile/props.js +0 -5
  50. package/components/basic/tree/Components/TreeNodeComponent.js +238 -170
  51. package/components/basic/tree/hooks/useTreePartialNodeApi.js +143 -135
  52. package/components/basic/tree/index.js +378 -454
  53. package/components/basic/tree/props.js +0 -5
  54. package/components/basic/tree/utils.js +129 -185
  55. package/components/basic/video/index.js +161 -107
  56. package/components/basic/video/props.js +0 -5
  57. package/components/chart/index.js +42 -50
  58. package/components/chart/props.js +31 -37
  59. package/components/chart/src/ChartRenderer.js +172 -154
  60. package/components/chart/src/chart.js +391 -213
  61. package/components/chart/src/chartStyles.generated.js +6 -14
  62. package/components/chart/src/chartUtils.js +228 -272
  63. package/components/chart/src/constants.d.ts +13 -0
  64. package/components/chart/src/constants.js +316 -90
  65. package/components/chart/src/d3Setup.js +11 -30
  66. package/components/chart/src/dataUtils.js +362 -446
  67. package/components/chart/src/formatUtils.js +47 -38
  68. package/components/chart/src/index.js +11 -19
  69. package/components/chart/src/nvd3Source.generated.js +5 -13
  70. package/components/chart/src/pieDonutResponsiveLayout.d.ts +5 -0
  71. package/components/chart/src/pieDonutResponsiveLayout.js +76 -96
  72. package/components/chart/src/types.js +0 -5
  73. package/components/common/AppSpinner.js +17 -33
  74. package/components/common/app-spinner.js +11 -22
  75. package/components/common/customTemplate/index.d.ts +3 -0
  76. package/components/common/customTemplate/index.js +6 -0
  77. package/components/common/customTemplate/props.d.ts +20 -0
  78. package/components/common/customTemplate/props.js +0 -0
  79. package/components/common/customTemplate/template.d.ts +3 -0
  80. package/components/common/customTemplate/template.js +27 -0
  81. package/components/common/customTemplate/useCustomTemplate.d.ts +8 -0
  82. package/components/common/customTemplate/useCustomTemplate.js +17 -0
  83. package/components/common/customTemplate/utils.d.ts +6 -0
  84. package/components/common/customTemplate/utils.js +12 -0
  85. package/components/common/index.js +4 -12
  86. package/components/constants.js +81 -77
  87. package/components/container/accordion/accordion-pane/index.js +105 -118
  88. package/components/container/accordion/accordion-pane/props.js +5 -21
  89. package/components/container/accordion/index.js +225 -243
  90. package/components/container/accordion/props.js +5 -16
  91. package/components/container/index.js +214 -150
  92. package/components/container/layout-grid/grid-column/index.js +68 -43
  93. package/components/container/layout-grid/grid-column/props.js +0 -5
  94. package/components/container/layout-grid/grid-row/index.js +12 -29
  95. package/components/container/layout-grid/grid-row/props.js +0 -5
  96. package/components/container/layout-grid/index.js +53 -38
  97. package/components/container/layout-grid/props.js +0 -5
  98. package/components/container/linear-layout/index.js +56 -60
  99. package/components/container/linear-layout/linear-layout-item/index.js +43 -47
  100. package/components/container/linear-layout/linear-layout-item/props.js +0 -5
  101. package/components/container/linear-layout/props.js +0 -5
  102. package/components/container/panel/components/panel-content/index.js +7 -16
  103. package/components/container/panel/components/panel-header/index.js +166 -146
  104. package/components/container/panel/components/panel-header/props.js +0 -5
  105. package/components/container/panel/hooks.js +76 -102
  106. package/components/container/panel/index.js +289 -252
  107. package/components/container/panel/props.js +0 -5
  108. package/components/container/props.js +0 -5
  109. package/components/container/repeat-template/index.js +65 -44
  110. package/components/container/repeat-template/props.js +0 -5
  111. package/components/container/tabs/index.js +517 -526
  112. package/components/container/tabs/props.js +5 -28
  113. package/components/container/tabs/tab-pane/index.js +105 -100
  114. package/components/container/tabs/tab-pane/props.js +0 -5
  115. package/components/container/tabs/utils.js +30 -35
  116. package/components/container/wizard/WizardContext.js +9 -11
  117. package/components/container/wizard/components/StepComponents.js +76 -99
  118. package/components/container/wizard/components/WizardStep.js +107 -85
  119. package/components/container/wizard/index.js +791 -921
  120. package/components/container/wizard/props.js +0 -5
  121. package/components/container/wizard/utils.js +97 -131
  122. package/components/container/wizard/wizard-action/index.js +41 -81
  123. package/components/container/wizard/wizard-step/index.js +140 -120
  124. package/components/data/card/card-actions/index.js +13 -31
  125. package/components/data/card/card-content/index.js +27 -36
  126. package/components/data/card/card-footer/index.js +13 -31
  127. package/components/data/card/index.js +192 -199
  128. package/components/data/card/props.js +0 -5
  129. package/components/data/form/base-form/constant.js +5 -8
  130. package/components/data/form/base-form/hooks/index.js +26 -77
  131. package/components/data/form/base-form/hooks/useFormDataSync.js +106 -212
  132. package/components/data/form/base-form/hooks/useFormOperations.js +109 -161
  133. package/components/data/form/base-form/hooks/useFormSubmission.js +220 -280
  134. package/components/data/form/base-form/hooks/useFormValidation.js +119 -168
  135. package/components/data/form/base-form/hooks/useParentFormRelationship.js +67 -103
  136. package/components/data/form/base-form/index.js +531 -646
  137. package/components/data/form/base-form/props.js +74 -151
  138. package/components/data/form/base-form/utils.js +210 -323
  139. package/components/data/form/dynamic-fields/constant.js +43 -53
  140. package/components/data/form/dynamic-fields/index.js +135 -144
  141. package/components/data/form/dynamic-fields/props.js +0 -5
  142. package/components/data/form/dynamic-fields/utils.js +99 -158
  143. package/components/data/form/form-action/index.js +107 -85
  144. package/components/data/form/form-body/index.js +52 -26
  145. package/components/data/form/form-context.js +43 -59
  146. package/components/data/form/form-controller/hooks/index.js +43 -57
  147. package/components/data/form/form-controller/props.js +5 -8
  148. package/components/data/form/form-controller/utils.js +54 -49
  149. package/components/data/form/form-controller/validation-contrustor.js +203 -426
  150. package/components/data/form/form-controller/withFormController.js +319 -269
  151. package/components/data/form/form-dynamic-section/index.js +47 -41
  152. package/components/data/form/form-dynamic-section/props.js +0 -5
  153. package/components/data/form/form-field/base-field.js +97 -109
  154. package/components/data/form/form-field/index.js +91 -82
  155. package/components/data/form/form-field/props.js +0 -5
  156. package/components/data/form/form-footer/index.js +52 -25
  157. package/components/data/form/form-header/index.js +61 -58
  158. package/components/data/form/index.js +95 -74
  159. package/components/data/form/props.js +0 -5
  160. package/components/data/list/components/GroupHeader.js +34 -33
  161. package/components/data/list/components/GroupedListItems.js +108 -104
  162. package/components/data/list/components/ListContainer.js +22 -27
  163. package/components/data/list/components/ListDND.js +193 -185
  164. package/components/data/list/components/ListHeader.js +32 -49
  165. package/components/data/list/components/ListItem.js +153 -146
  166. package/components/data/list/components/ListItemWithTemplate.js +87 -105
  167. package/components/data/list/components/ListItems.js +180 -194
  168. package/components/data/list/components/ListPagination.js +127 -153
  169. package/components/data/list/components/LoadMoreButton.js +25 -33
  170. package/components/data/list/components/NoDataMessage.js +9 -22
  171. package/components/data/list/components/StandardListItems.js +79 -85
  172. package/components/data/list/components/index.js +31 -119
  173. package/components/data/list/components/props.js +0 -5
  174. package/components/data/list/hooks/index.js +22 -75
  175. package/components/data/list/hooks/props.js +0 -5
  176. package/components/data/list/hooks/useCurrentPageItems.js +20 -38
  177. package/components/data/list/hooks/useGroupedData.js +19 -33
  178. package/components/data/list/hooks/useListData.js +17 -47
  179. package/components/data/list/hooks/useListEffects.js +168 -237
  180. package/components/data/list/hooks/useListEventHandlers.js +301 -285
  181. package/components/data/list/hooks/useListPagination.js +90 -136
  182. package/components/data/list/hooks/useListState.js +49 -91
  183. package/components/data/list/hooks/useListStateManager.js +104 -159
  184. package/components/data/list/hooks/usePaginatedGroupedData.js +74 -110
  185. package/components/data/list/index.d.ts +1 -0
  186. package/components/data/list/index.js +579 -621
  187. package/components/data/list/props.d.ts +4 -0
  188. package/components/data/list/props.js +0 -5
  189. package/components/data/list/templates/media-template.js +29 -50
  190. package/components/data/list/utils/constants.js +20 -32
  191. package/components/data/list/utils/list-helpers.d.ts +2 -1
  192. package/components/data/list/utils/list-helpers.js +71 -115
  193. package/components/data/list/utils/list-widget-methods.js +56 -76
  194. package/components/data/list/utils/widget-instance-utils.js +20 -57
  195. package/components/data/live-filter/index.js +219 -271
  196. package/components/data/live-filter/props.js +5 -12
  197. package/components/data/live-form/index.js +68 -91
  198. package/components/data/live-form/props.js +5 -12
  199. package/components/data/pagination/components/BasicPagination.js +124 -104
  200. package/components/data/pagination/components/ClassicPagination.js +167 -190
  201. package/components/data/pagination/components/InlinePagination.js +97 -98
  202. package/components/data/pagination/components/LoadingComponent.js +17 -30
  203. package/components/data/pagination/components/PageSizeSelector.js +176 -169
  204. package/components/data/pagination/components/PagerNavigation.js +84 -105
  205. package/components/data/pagination/components/TotalRecords.js +48 -47
  206. package/components/data/pagination/components/index.js +14 -47
  207. package/components/data/pagination/components/props.js +0 -5
  208. package/components/data/pagination/hooks/index.js +6 -19
  209. package/components/data/pagination/hooks/props.js +0 -5
  210. package/components/data/pagination/hooks/useNavigationSize.js +12 -21
  211. package/components/data/pagination/hooks/usePagination.js +702 -905
  212. package/components/data/pagination/index.js +336 -389
  213. package/components/data/table/components/AddNewRow.js +122 -154
  214. package/components/data/table/components/EditableCell.js +68 -75
  215. package/components/data/table/components/FieldValidationError.js +19 -20
  216. package/components/data/table/components/RowCells.js +97 -80
  217. package/components/data/table/components/RowExpansionButton.js +43 -39
  218. package/components/data/table/components/SummaryCell.js +54 -88
  219. package/components/data/table/components/SummaryRow.js +45 -52
  220. package/components/data/table/components/SummaryRowFooter.js +35 -42
  221. package/components/data/table/components/TableBody.js +222 -218
  222. package/components/data/table/components/TableDataRow.js +113 -106
  223. package/components/data/table/components/TableFilters.js +391 -390
  224. package/components/data/table/components/TableFooterActions.js +25 -32
  225. package/components/data/table/components/TableHeader.js +460 -435
  226. package/components/data/table/components/TablePanelHeading.js +157 -181
  227. package/components/data/table/components/index.js +27 -95
  228. package/components/data/table/hooks/index.js +21 -230
  229. package/components/data/table/hooks/use-edited-rows.js +59 -94
  230. package/components/data/table/hooks/useCellState.js +58 -83
  231. package/components/data/table/hooks/useCustomExpressionColumns.js +65 -86
  232. package/components/data/table/hooks/useDynamicColumns.js +59 -92
  233. package/components/data/table/hooks/useEditingState.js +30 -41
  234. package/components/data/table/hooks/useFormWidget.js +163 -172
  235. package/components/data/table/hooks/usePaginationState.js +67 -77
  236. package/components/data/table/hooks/usePanelStructure.js +47 -41
  237. package/components/data/table/hooks/useResponsiveColumns.js +14 -20
  238. package/components/data/table/hooks/useRowExpansion.js +131 -127
  239. package/components/data/table/hooks/useRowHandlers.js +56 -69
  240. package/components/data/table/hooks/useRowSelection.js +249 -329
  241. package/components/data/table/hooks/useServerSideSorting.js +109 -175
  242. package/components/data/table/hooks/useTableColumns.js +322 -331
  243. package/components/data/table/hooks/useTableData.js +111 -166
  244. package/components/data/table/hooks/useTableEdit.js +526 -564
  245. package/components/data/table/hooks/useTableEffects.js +60 -107
  246. package/components/data/table/hooks/useTableFilter.js +244 -237
  247. package/components/data/table/hooks/useTableInitialization.js +44 -76
  248. package/components/data/table/hooks/useTableState.js +39 -61
  249. package/components/data/table/hooks/useTableStateManager.js +295 -468
  250. package/components/data/table/index.js +1553 -1713
  251. package/components/data/table/live-table/index.js +157 -219
  252. package/components/data/table/props.js +0 -5
  253. package/components/data/table/table-action/index.js +97 -75
  254. package/components/data/table/table-column/index.js +48 -42
  255. package/components/data/table/table-group/index.js +7 -25
  256. package/components/data/table/table-row/index.js +63 -55
  257. package/components/data/table/table-row-action/index.js +102 -77
  258. package/components/data/table/utils/buildSelectionColumns.js +86 -137
  259. package/components/data/table/utils/columnBuilder.js +116 -158
  260. package/components/data/table/utils/columnProxy.js +48 -66
  261. package/components/data/table/utils/columnWidthDistribution.js +40 -64
  262. package/components/data/table/utils/constants.js +92 -40
  263. package/components/data/table/utils/crud-handlers.js +292 -473
  264. package/components/data/table/utils/dynamic-columns.js +99 -144
  265. package/components/data/table/utils/groupHeaderUtils.js +36 -61
  266. package/components/data/table/utils/index.d.ts +8 -5
  267. package/components/data/table/utils/index.js +419 -639
  268. package/components/data/table/utils/renderDisplayCell.js +127 -169
  269. package/components/data/table/utils/script-page-size-broadcast.js +17 -29
  270. package/components/data/table/utils/selectionUtils.js +59 -113
  271. package/components/data/table/utils/table-helpers.js +38 -74
  272. package/components/data/table/utils/validation.js +35 -78
  273. package/components/data/table/utils/widgetMapping.d.ts +5 -0
  274. package/components/data/table/utils/widgetMapping.js +41 -0
  275. package/components/data/types.js +112 -112
  276. package/components/data/utils/field-data-utils.js +38 -42
  277. package/components/data/utils/filter-field-util.js +42 -44
  278. package/components/data/utils/index.js +112 -111
  279. package/components/dialogs/alert-dialog/index.js +83 -78
  280. package/components/dialogs/alert-dialog/props.js +0 -5
  281. package/components/dialogs/confirm-dialog/index.js +102 -92
  282. package/components/dialogs/confirm-dialog/props.js +0 -5
  283. package/components/dialogs/dialog/index.js +93 -69
  284. package/components/dialogs/dialog/props.js +0 -5
  285. package/components/dialogs/dialog-actions/index.js +12 -26
  286. package/components/dialogs/dialog-actions/props.js +0 -5
  287. package/components/dialogs/dialog-body/index.js +13 -30
  288. package/components/dialogs/dialog-body/props.js +0 -5
  289. package/components/dialogs/dialog-content/index.js +48 -41
  290. package/components/dialogs/dialog-content/props.js +0 -5
  291. package/components/dialogs/dialog-header/index.js +88 -101
  292. package/components/dialogs/dialog-header/props.js +0 -5
  293. package/components/dialogs/iframe-dialog/index.js +136 -128
  294. package/components/dialogs/iframe-dialog/props.js +0 -5
  295. package/components/dialogs/index.js +104 -101
  296. package/components/dialogs/login-dialog/index.js +285 -347
  297. package/components/dialogs/login-dialog/props.js +0 -5
  298. package/components/dialogs/page-dialog/index.js +95 -86
  299. package/components/dialogs/page-dialog/props.js +0 -5
  300. package/components/dialogs/props.js +0 -5
  301. package/components/dialogs/withDialogWrapper.js +110 -83
  302. package/components/form/button/index.js +296 -245
  303. package/components/form/button/props.js +0 -5
  304. package/components/form/button-group/index.js +80 -69
  305. package/components/form/button-group/props.js +0 -5
  306. package/components/input/calendar/index.js +409 -362
  307. package/components/input/calendar/props.js +0 -5
  308. package/components/input/calendar/utils.js +164 -172
  309. package/components/input/chips/SortableChip/index.js +109 -100
  310. package/components/input/chips/SortableChip/props.js +0 -5
  311. package/components/input/chips/index.js +663 -570
  312. package/components/input/chips/props.js +0 -5
  313. package/components/input/chips/utils.js +131 -122
  314. package/components/input/color-picker/index.js +536 -594
  315. package/components/input/color-picker/props.js +0 -5
  316. package/components/input/composite/index.js +71 -110
  317. package/components/input/composite/props.js +0 -5
  318. package/components/input/currency/index.js +277 -224
  319. package/components/input/currency/props.js +0 -5
  320. package/components/input/default/checkbox/index.js +329 -250
  321. package/components/input/default/checkbox/props.js +0 -5
  322. package/components/input/default/checkboxset/index.d.ts +2 -0
  323. package/components/input/default/checkboxset/index.js +529 -446
  324. package/components/input/default/checkboxset/props.d.ts +4 -0
  325. package/components/input/default/checkboxset/props.js +0 -5
  326. package/components/input/default/checkboxset/utils.js +15 -25
  327. package/components/input/default/radioset/index.d.ts +2 -0
  328. package/components/input/default/radioset/index.js +409 -350
  329. package/components/input/default/radioset/props.d.ts +6 -0
  330. package/components/input/default/radioset/props.js +0 -5
  331. package/components/input/default/switch/index.js +494 -458
  332. package/components/input/default/switch/prop.js +0 -5
  333. package/components/input/epoch/date/components/DatePickerPopover.js +242 -193
  334. package/components/input/epoch/date/index.js +638 -518
  335. package/components/input/epoch/date/props.js +0 -5
  336. package/components/input/epoch/date/styled.js +61 -70
  337. package/components/input/epoch/date/utils.js +67 -115
  338. package/components/input/epoch/datetime/index.js +758 -695
  339. package/components/input/epoch/datetime/props.js +0 -5
  340. package/components/input/epoch/datetime/utils.js +121 -186
  341. package/components/input/epoch/time/index.js +441 -415
  342. package/components/input/epoch/time/props.js +0 -5
  343. package/components/input/epoch/time/utils.js +101 -112
  344. package/components/input/fileupload/Utils.js +70 -97
  345. package/components/input/fileupload/components/ListItems.js +132 -130
  346. package/components/input/fileupload/components/MultiUpload.js +80 -77
  347. package/components/input/fileupload/components/SingleUpload.js +57 -57
  348. package/components/input/fileupload/index.js +253 -178
  349. package/components/input/fileupload/props.js +0 -5
  350. package/components/input/fileupload/useFileUpload.js +209 -258
  351. package/components/input/number/index.js +434 -393
  352. package/components/input/number/props.js +0 -5
  353. package/components/input/rating/index.js +401 -394
  354. package/components/input/rating/props.js +0 -5
  355. package/components/input/select/index.js +408 -463
  356. package/components/input/select/props.js +0 -5
  357. package/components/input/slider/index.js +339 -332
  358. package/components/input/slider/props.js +0 -5
  359. package/components/input/text/index.d.ts +3 -3
  360. package/components/input/text/index.js +438 -475
  361. package/components/input/text/props.d.ts +1 -1
  362. package/components/input/text/props.js +0 -5
  363. package/components/input/text/util.js +82 -222
  364. package/components/input/textarea/index.js +322 -358
  365. package/components/input/textarea/props.js +0 -5
  366. package/components/input/upload/index.js +135 -131
  367. package/components/input/upload/props.js +0 -5
  368. package/components/input/util/index.js +9 -11
  369. package/components/layout/footer/index.js +12 -35
  370. package/components/layout/footer/props.js +0 -5
  371. package/components/layout/header/index.js +12 -38
  372. package/components/layout/header/props.js +0 -5
  373. package/components/layout/leftnav/index.js +38 -44
  374. package/components/layout/leftnav/props.js +0 -5
  375. package/components/layout/rightnav/index.js +12 -36
  376. package/components/layout/rightnav/props.js +0 -5
  377. package/components/layout/topnav/index.js +24 -38
  378. package/components/layout/topnav/props.js +0 -5
  379. package/components/navbar/index.js +119 -98
  380. package/components/navbar/nav/index.js +236 -232
  381. package/components/navbar/nav/props.js +0 -5
  382. package/components/navbar/nav-item/index.js +74 -65
  383. package/components/navbar/nav-item/props.js +0 -5
  384. package/components/navigation/breadcrumb/index.js +38 -61
  385. package/components/navigation/breadcrumb/props.js +0 -5
  386. package/components/navigation/menu/components/ListItems.js +76 -67
  387. package/components/navigation/menu/constants.js +27 -42
  388. package/components/navigation/menu/hooks/useHoverState.hook.js +20 -47
  389. package/components/navigation/menu/hooks/useKeyboardMovements.hook.js +34 -28
  390. package/components/navigation/menu/hooks/useTransformedDataset.hook.js +21 -14
  391. package/components/navigation/menu/index.js +911 -846
  392. package/components/navigation/menu/props.js +0 -5
  393. package/components/navigation/menu/utils/action-task.js +6 -9
  394. package/components/navigation/menu/utils/role-filter.js +41 -56
  395. package/components/navigation/popover/index.js +191 -205
  396. package/components/navigation/popover/props.js +5 -8
  397. package/components/page/content/index.js +9 -31
  398. package/components/page/content/props.js +0 -5
  399. package/components/page/error-boundary/index.js +115 -105
  400. package/components/page/error-boundary/props.js +0 -5
  401. package/components/page/index.js +84 -102
  402. package/components/page/page-content/index.js +21 -30
  403. package/components/page/page-content/props.js +0 -5
  404. package/components/page/partial/index.js +50 -45
  405. package/components/page/partial/props.js +0 -5
  406. package/components/page/partial-container/index.js +81 -107
  407. package/components/page/partial-container/props.d.ts +1 -1
  408. package/components/page/partial-container/props.js +0 -5
  409. package/components/page/props.js +0 -5
  410. package/components/page/toast-container/index.js +20 -41
  411. package/components/page/toast-container/props.js +0 -5
  412. package/components/prefab/container/index.js +60 -53
  413. package/components/prefab/container/props.js +0 -5
  414. package/components/prefab/index.js +76 -61
  415. package/components/prefab/props.js +0 -5
  416. package/context/AppContext.d.ts +1 -1
  417. package/context/AppContext.js +17 -18
  418. package/context/AppSpinnerProvider.js +19 -34
  419. package/context/LayoutProvider.js +54 -57
  420. package/context/LocalizationProvider.js +34 -49
  421. package/context/PrefabContext.js +68 -119
  422. package/context/WidgetProvider.js +160 -166
  423. package/core/app-config.js +0 -1
  424. package/core/app.service.js +200 -327
  425. package/core/appVariablesStore.js +10 -15
  426. package/core/appstore.js +37 -53
  427. package/core/constants/currency-constant.js +81 -83
  428. package/core/constants/events.js +34 -44
  429. package/core/constants/index.js +21 -31
  430. package/core/dialog.service.js +52 -72
  431. package/core/event-notifier.js +94 -131
  432. package/core/formatter/array-formatters.js +18 -32
  433. package/core/formatter/date-formatters.js +140 -204
  434. package/core/formatter/index.js +64 -117
  435. package/core/formatter/number-formatters.js +115 -159
  436. package/core/formatter/security-formatters.js +233 -283
  437. package/core/formatter/string-formatters.js +23 -45
  438. package/core/formatter/types.js +12 -18
  439. package/core/formatters.js +6 -24
  440. package/core/proxy-service.js +242 -306
  441. package/core/script-registry.js +87 -134
  442. package/core/security.service.js +8 -11
  443. package/core/util/compare.js +13 -25
  444. package/core/util/dom.js +32 -63
  445. package/core/util/index.d.ts +5 -0
  446. package/core/util/index.js +95 -95
  447. package/core/util/safe-is-equal.js +42 -94
  448. package/core/util/security.js +114 -153
  449. package/core/util/utils.d.ts +8 -1
  450. package/core/util/utils.js +124 -132
  451. package/core/widget-observer.js +34 -61
  452. package/higherOrder/BaseApp.js +327 -500
  453. package/higherOrder/BaseAppProps.js +0 -5
  454. package/higherOrder/BaseDateTime.js +277 -231
  455. package/higherOrder/BasePage.js +479 -735
  456. package/higherOrder/BasePartial.js +87 -114
  457. package/higherOrder/BasePrefab.js +190 -206
  458. package/higherOrder/DataNav.js +287 -302
  459. package/higherOrder/helper.js +62 -48
  460. package/higherOrder/props.js +0 -5
  461. package/higherOrder/withBaseWrapper.js +123 -168
  462. package/higherOrder/withStandalone.js +28 -26
  463. package/hooks/useAccess.js +113 -289
  464. package/hooks/useAppConfig.js +15 -40
  465. package/hooks/useAuth.js +256 -495
  466. package/hooks/useDataSourceSubscription.d.ts +3 -3
  467. package/hooks/useDataSourceSubscription.js +99 -109
  468. package/hooks/useDebounce.js +28 -56
  469. package/hooks/useDeviceVisibility.js +14 -23
  470. package/hooks/useHttp.d.ts +1 -0
  471. package/hooks/useHttp.js +318 -493
  472. package/libs/index.js +4 -13
  473. package/libs/prefab/index.js +6 -20
  474. package/mui-config/theme-provider.js +9 -17
  475. package/mui-config/theme.js +6 -9
  476. package/package-lock.json +808 -3177
  477. package/package.json +3 -19
  478. package/providers/AppProviders.js +21 -24
  479. package/runtime-dynamic/App.js +65 -93
  480. package/runtime-dynamic/app-initializer.js +207 -400
  481. package/runtime-dynamic/components/ErrorBoundary.js +59 -76
  482. package/runtime-dynamic/components/PageWrapper.js +23 -35
  483. package/runtime-dynamic/components/PrefabPreview.js +40 -69
  484. package/runtime-dynamic/components/partial-content.d.ts +2 -3
  485. package/runtime-dynamic/components/partial-content.js +66 -48
  486. package/runtime-dynamic/components/prefab-content.js +37 -30
  487. package/runtime-dynamic/components/use-dynamic-component.js +62 -150
  488. package/runtime-dynamic/factories/build-base-page-like-component.js +44 -58
  489. package/runtime-dynamic/factories/dynamic-component.d.ts +9 -0
  490. package/runtime-dynamic/factories/dynamic-component.js +83 -0
  491. package/runtime-dynamic/factories/prefab-factory.js +60 -81
  492. package/runtime-dynamic/factories/startup-info.js +12 -25
  493. package/runtime-dynamic/factories/utils.d.ts +1 -9
  494. package/runtime-dynamic/factories/utils.js +47 -130
  495. package/runtime-dynamic/index.js +56 -191
  496. package/runtime-dynamic/main.js +42 -70
  497. package/runtime-dynamic/preview-mode.js +14 -29
  498. package/runtime-dynamic/preview-navigation.js +21 -30
  499. package/runtime-dynamic/preview-path.d.ts +5 -0
  500. package/runtime-dynamic/preview-path.js +13 -0
  501. package/runtime-dynamic/preview-resource-base.js +15 -31
  502. package/runtime-dynamic/registry/component-registry.js +269 -334
  503. package/runtime-dynamic/registry/custom-widget-registry.js +11 -15
  504. package/runtime-dynamic/registry/index.js +24 -63
  505. package/runtime-dynamic/registry/store.d.ts +1 -0
  506. package/runtime-dynamic/registry/store.js +18 -23
  507. package/runtime-dynamic/routes.js +53 -81
  508. package/runtime-dynamic/services/app-extension-provider.js +17 -44
  509. package/runtime-dynamic/services/autolayout-inject.d.ts +4 -0
  510. package/runtime-dynamic/services/autolayout-inject.js +27 -0
  511. package/runtime-dynamic/services/cache.js +27 -33
  512. package/runtime-dynamic/services/compile-render.d.ts +9 -0
  513. package/runtime-dynamic/services/compile-render.js +142 -0
  514. package/runtime-dynamic/services/component-ref-provider.js +70 -124
  515. package/runtime-dynamic/services/css-scoping.js +27 -28
  516. package/runtime-dynamic/services/fragment-url.js +37 -50
  517. package/runtime-dynamic/services/index.js +48 -152
  518. package/runtime-dynamic/services/markup-transpiler.d.ts +2 -2
  519. package/runtime-dynamic/services/markup-transpiler.js +39 -231
  520. package/runtime-dynamic/services/prefab-resources.js +42 -130
  521. package/runtime-dynamic/services/resource-manager.d.ts +2 -1
  522. package/runtime-dynamic/services/resource-manager.js +32 -63
  523. package/runtime-dynamic/services/script-executor.js +50 -61
  524. package/runtime-dynamic/services/variable-factory.js +141 -184
  525. package/runtime-dynamic/services/variable-registry.js +69 -115
  526. package/runtime-dynamic/services/variable-transpiler.js +73 -103
  527. package/runtime-dynamic/shims/next-image.js +79 -50
  528. package/runtime-dynamic/shims/next-link.js +58 -32
  529. package/runtime-dynamic/shims/next-navigation.js +17 -34
  530. package/runtime-dynamic/utils/index.d.ts +2 -0
  531. package/runtime-dynamic/utils/index.js +22 -24
  532. package/store/bindActions/i18nActions.js +16 -18
  533. package/store/index.js +29 -35
  534. package/store/middleware/navigationMiddleware.js +25 -45
  535. package/store/middleware/pendingTabNavigationIntentMiddleware.js +20 -25
  536. package/store/slices/appConfigSlice.js +65 -94
  537. package/store/slices/authSlice.js +317 -471
  538. package/store/slices/i18nSlice.js +169 -168
  539. package/store/slices/navigationSlice.js +22 -20
  540. package/store/util/resolve-path.d.ts +1 -0
  541. package/store/util/resolve-path.js +7 -0
  542. package/store/viewport.service.js +150 -194
  543. package/types/index.js +10 -15
  544. package/utils/attr.js +198 -41
  545. package/utils/custom-expression/index.js +55 -151
  546. package/utils/custom-expression/parser.js +106 -182
  547. package/utils/dataset-util.js +113 -154
  548. package/utils/eval-expression.js +10 -19
  549. package/utils/form-state.util.js +60 -118
  550. package/utils/form-utils.js +49 -190
  551. package/utils/format-util.js +113 -184
  552. package/utils/layoutsize-util.js +11 -17
  553. package/utils/lib-error-skipper.js +54 -52
  554. package/utils/page-params-util.js +50 -40
  555. package/utils/pending-tab-navigation-intent.js +7 -17
  556. package/utils/resource-url.js +8 -19
  557. package/utils/state-persistance.js +136 -253
  558. package/utils/style-utils.d.ts +2 -0
  559. package/utils/style-utils.js +25 -74
  560. package/utils/transformedDataset-utils.js +353 -381
  561. package/utils/widget-cleanup-util.js +42 -74
  562. package/utils/widgets.js +19 -31
  563. package/variables/base-variable.js +117 -166
  564. package/variables/constants.js +5 -8
  565. package/variables/crud-variable.js +150 -181
  566. package/variables/live-variable.d.ts +1 -1
  567. package/variables/live-variable.js +140 -174
  568. package/variables/metadata.service.js +74 -116
  569. package/variables/model-variable.js +68 -78
  570. package/variables/service-variable.js +171 -285
  571. package/wm-namespace.js +11 -14
  572. package/components/chart/src/css.d.js +0 -1
  573. package/tsconfig.declaration.tsbuildinfo +0 -1
  574. package/types/global.d.js +0 -3
@@ -1,916 +1,948 @@
1
- "use strict";
2
-
3
- var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
- var _typeof = require("@babel/runtime/helpers/typeof");
5
- Object.defineProperty(exports, "__esModule", {
6
- value: true
7
- });
8
- exports["default"] = exports.WmMenu = void 0;
9
- var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
10
- var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
11
- var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
12
- var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
13
- var _objectWithoutProperties2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutProperties"));
14
- var _react = _interopRequireWildcard(require("react"));
15
- var _clsx = _interopRequireDefault(require("clsx"));
16
- var _Box = _interopRequireDefault(require("@mui/material/Box"));
17
- var _Button = _interopRequireDefault(require("@mui/material/Button"));
18
- var _Tooltip = _interopRequireDefault(require("@mui/material/Tooltip"));
19
- var _withBaseWrapper = require("@wavemaker-ai/react-runtime/higherOrder/withBaseWrapper");
20
- var _transformedDatasetUtils = require("@wavemaker-ai/react-runtime/utils/transformedDataset-utils");
21
- var _constants = require("./constants");
22
- var _lodash = require("lodash");
23
- var _Link = _interopRequireDefault(require("@mui/material/Link"));
24
- var _ListItems = require("./components/ListItems");
25
- var _utils = require("@wavemaker-ai/react-runtime/core/util/utils");
26
- var _navigation = require("next/navigation");
27
- var _actionTask = require("@wavemaker-ai/react-runtime/components/navigation/menu/utils/action-task");
28
- var _roleFilter = require("@wavemaker-ai/react-runtime/components/navigation/menu/utils/role-filter");
29
- var _useKeyboardMovements = require("./hooks/useKeyboardMovements.hook");
30
- var _useTransformedDataset = require("./hooks/useTransformedDataset.hook");
31
- var _useHoverState2 = require("./hooks/useHoverState.hook");
32
- var _constants2 = require("@wavemaker-ai/react-runtime/core/constants");
33
- var _attr = require("@wavemaker-ai/react-runtime/utils/attr");
34
- var _excluded = ["menualign", "menuposition", "menulayout", "menuclass", "linktarget", "iconclass", "type", "animateitems", "disableMenuContext", "showonhover", "panelPosition", "autoclose", "autoopen", "hint", "arialabel", "width", "height", "iconposition", "caption", "shortcutkey", "onClick", "onSelect", "navNodes", "styles", "conditionalstyles", "className", "children", "listener", "name", "resetNavNodes", "nodes$", "dataset", "orderby", "itemlabel", "itemlink", "itemicon", "itemaction", "userrole", "loggedInUser", "itemchildren", "isactive", "displayValue", "onActionsclick", "dataPath", "isFromNav", "onNavItemActivate", "isNavItemActive"];
35
- function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function _interopRequireWildcard(e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, "default": e }; if (null === e || "object" != _typeof(e) && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (var _t2 in e) "default" !== _t2 && {}.hasOwnProperty.call(e, _t2) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, _t2)) && (i.get || i.set) ? o(f, _t2, i) : f[_t2] = e[_t2]); return f; })(e, t); }
36
- var __jsx = _react["default"].createElement;
37
- function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
38
- function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { (0, _defineProperty2["default"])(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
39
- /**
40
- * Checks if the current path matches the nav item link.
41
- * Uses path-segment matching to avoid false positives when one page name
42
- * is a substring of another (e.g. "Tasks" should not match "/TasksService").
43
- */
44
- var isPathMatchingLink = function isPathMatchingLink(path, link) {
45
- var cleanLink = link.replace(/^#\/?/, "").split("?")[0].trim();
1
+ var __defProp = Object.defineProperty;
2
+ var __defProps = Object.defineProperties;
3
+ var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
4
+ var __getOwnPropSymbols = Object.getOwnPropertySymbols;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __propIsEnum = Object.prototype.propertyIsEnumerable;
7
+ var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
8
+ var __spreadValues = (a, b) => {
9
+ for (var prop in b || (b = {}))
10
+ if (__hasOwnProp.call(b, prop))
11
+ __defNormalProp(a, prop, b[prop]);
12
+ if (__getOwnPropSymbols)
13
+ for (var prop of __getOwnPropSymbols(b)) {
14
+ if (__propIsEnum.call(b, prop))
15
+ __defNormalProp(a, prop, b[prop]);
16
+ }
17
+ return a;
18
+ };
19
+ var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
20
+ var __objRest = (source, exclude) => {
21
+ var target = {};
22
+ for (var prop in source)
23
+ if (__hasOwnProp.call(source, prop) && exclude.indexOf(prop) < 0)
24
+ target[prop] = source[prop];
25
+ if (source != null && __getOwnPropSymbols)
26
+ for (var prop of __getOwnPropSymbols(source)) {
27
+ if (exclude.indexOf(prop) < 0 && __propIsEnum.call(source, prop))
28
+ target[prop] = source[prop];
29
+ }
30
+ return target;
31
+ };
32
+ import { jsx, jsxs } from "react/jsx-runtime";
33
+ import React, { memo, useEffect, useRef, useState, useMemo, useCallback } from "react";
34
+ import clsx from "clsx";
35
+ import Box from "@mui/material/Box";
36
+ import Button from "@mui/material/Button";
37
+ import Tooltip from "@mui/material/Tooltip";
38
+ import { withBaseWrapper } from "../../../higherOrder/withBaseWrapper";
39
+ import { transformDataset } from "../../../utils/transformedDataset-utils";
40
+ import {
41
+ POSITION,
42
+ LAYOUT,
43
+ AUTO_OPEN,
44
+ AUTO_CLOSE,
45
+ TOOLTIP_ENTER_DELAY,
46
+ CARET_CLS,
47
+ menuAlignClass
48
+ } from "./constants";
49
+ import { isEmpty, cloneDeep } from "lodash";
50
+ import Link from "@mui/material/Link";
51
+ import { buildMenuListClasses, CollapsibleMenu, MenuList } from "./components/ListItems";
52
+ import {
53
+ getRouteNameFromLink,
54
+ triggerItemAction
55
+ } from "../../../core/util/utils";
56
+ import { usePathname } from "next/navigation";
57
+ import { executeActionTaskFromItem } from "./utils/action-task";
58
+ import { filterMenuNodesByRole } from "./utils/role-filter";
59
+ import { useKeyboardMovements } from "./hooks/useKeyboardMovements.hook";
60
+ import { useTransformedDataset } from "./hooks/useTransformedDataset.hook";
61
+ import { useHoverState } from "./hooks/useHoverState.hook";
62
+ import { hyperLinkMofify } from "../../../core/constants";
63
+ import { removeInvalidAttributes } from "../../../utils/attr";
64
+ const isPathMatchingLink = (path, link) => {
65
+ const cleanLink = link.replace(/^#\/?/, "").split("?")[0].trim();
46
66
  if (!cleanLink) return false;
47
- // Match link as a full path segment: preceded by ^ or /, followed by $ or /
48
- return new RegExp("(^|/)".concat(cleanLink, "($|/)"), "i").test(path);
67
+ return new RegExp(`(^|/)${cleanLink}($|/)`, "i").test(path);
49
68
  };
50
- var _hasLinkToCurrentPage = function hasLinkToCurrentPage(nodes, currentPath) {
69
+ const hasLinkToCurrentPage = (nodes, currentPath) => {
51
70
  if (!nodes || !Array.isArray(nodes)) return false;
52
- return nodes.some(function (node) {
71
+ return nodes.some((node) => {
53
72
  if (node.link === currentPath) return true;
54
- return node.children && _hasLinkToCurrentPage(node.children, currentPath);
73
+ return node.children && hasLinkToCurrentPage(node.children, currentPath);
55
74
  });
56
75
  };
57
-
58
- // Main component
59
- var WmMenu = exports.WmMenu = /*#__PURE__*/(0, _react.memo)(function (props) {
60
- var _listener$appConfig2, _listener$appLocale;
61
- var _props$menualign = props.menualign,
62
- menualign = _props$menualign === void 0 ? "left" : _props$menualign,
63
- _props$menuposition = props.menuposition,
64
- initialMenuPosition = _props$menuposition === void 0 ? "down,right" : _props$menuposition,
65
- _props$menulayout = props.menulayout,
66
- menulayout = _props$menulayout === void 0 ? "vertical" : _props$menulayout,
67
- menuclass = props.menuclass,
68
- _props$linktarget = props.linktarget,
69
- linktarget = _props$linktarget === void 0 ? "_self" : _props$linktarget,
70
- iconclass = props.iconclass,
71
- _props$type = props.type,
72
- type = _props$type === void 0 ? "button" : _props$type,
73
- animateitems = props.animateitems,
74
- _props$disableMenuCon = props.disableMenuContext,
75
- disableMenuContext = _props$disableMenuCon === void 0 ? false : _props$disableMenuCon,
76
- _props$showonhover = props.showonhover,
77
- showonhover = _props$showonhover === void 0 ? false : _props$showonhover,
78
- panelPosition = props.panelPosition,
79
- _props$autoclose = props.autoclose,
80
- autoclose = _props$autoclose === void 0 ? "outsideClick" : _props$autoclose,
81
- _props$autoopen = props.autoopen,
82
- autoopen = _props$autoopen === void 0 ? "never" : _props$autoopen,
83
- hint = props.hint,
84
- arialabel = props.arialabel,
85
- width = props.width,
86
- height = props.height,
87
- _props$iconposition = props.iconposition,
88
- iconposition = _props$iconposition === void 0 ? "left" : _props$iconposition,
89
- caption = props.caption,
90
- shortcutkey = props.shortcutkey,
91
- onClick = props.onClick,
92
- onSelect = props.onSelect,
93
- _props$navNodes = props.navNodes,
94
- navNodes = _props$navNodes === void 0 ? [] : _props$navNodes,
95
- styles = props.styles,
96
- conditionalstyles = props.conditionalstyles,
97
- className = props.className,
98
- children = props.children,
99
- listener = props.listener,
100
- name = props.name,
101
- resetNavNodes = props.resetNavNodes,
102
- nodes$ = props.nodes$,
103
- dataset = props.dataset,
104
- orderby = props.orderby,
105
- _props$itemlabel = props.itemlabel,
106
- itemlabel = _props$itemlabel === void 0 ? "label" : _props$itemlabel,
107
- _props$itemlink = props.itemlink,
108
- itemlink = _props$itemlink === void 0 ? "Link" : _props$itemlink,
109
- _props$itemicon = props.itemicon,
110
- itemicon = _props$itemicon === void 0 ? "Icon" : _props$itemicon,
111
- itemaction = props.itemaction,
112
- userrole = props.userrole,
113
- loggedInUser = props.loggedInUser,
114
- _props$itemchildren = props.itemchildren,
115
- itemchildren = _props$itemchildren === void 0 ? "children" : _props$itemchildren,
116
- isactive = props.isactive,
117
- displayValue = props.displayValue,
118
- onActionsclick = props.onActionsclick,
119
- dataPath = props.dataPath,
120
- _props$isFromNav = props.isFromNav,
121
- isFromNav = _props$isFromNav === void 0 ? false : _props$isFromNav,
122
- onNavItemActivate = props.onNavItemActivate,
123
- _props$isNavItemActiv = props.isNavItemActive,
124
- isNavItemActive = _props$isNavItemActiv === void 0 ? false : _props$isNavItemActiv,
125
- restProps = (0, _objectWithoutProperties2["default"])(props, _excluded);
126
-
127
- // deeply cloning the dataset, it was getting mutated in the useTransformedDataset hook
128
- var deepCloneDataset = (0, _lodash.cloneDeep)(dataset);
129
- var itemLabelWrapper = typeof itemlabel === "function" ? function (rest) {
130
- return itemlabel(_objectSpread({
131
- App: listener === null || listener === void 0 ? void 0 : listener.App
132
- }, rest));
133
- } : itemlabel;
134
- var path = (0, _navigation.usePathname)();
135
- var user = (0, _react.useMemo)(function () {
136
- var _ref, _listener$appConfig;
137
- return (_ref = loggedInUser !== null && loggedInUser !== void 0 ? loggedInUser : listener === null || listener === void 0 || (_listener$appConfig = listener.appConfig) === null || _listener$appConfig === void 0 ? void 0 : _listener$appConfig.loggedInUser) !== null && _ref !== void 0 ? _ref : null;
138
- }, [loggedInUser, listener === null || listener === void 0 || (_listener$appConfig2 = listener.appConfig) === null || _listener$appConfig2 === void 0 ? void 0 : _listener$appConfig2.loggedInUser]);
139
-
140
- // State
141
- var _useState = (0, _react.useState)(false),
142
- open = _useState[0],
143
- setOpen = _useState[1];
144
- var _useState2 = (0, _react.useState)(null),
145
- activeItem = _useState2[0],
146
- setActiveItem = _useState2[1];
147
- var _useState3 = (0, _react.useState)(-1),
148
- focusedIndex = _useState3[0],
149
- setFocusedIndex = _useState3[1];
150
- var _useState4 = (0, _react.useState)(initialMenuPosition),
151
- menuPosition = _useState4[0],
152
- setMenuPosition = _useState4[1];
153
-
154
- // Refs
155
- var buttonRef = (0, _react.useRef)(null);
156
- var menuRef = (0, _react.useRef)(null);
157
-
158
- // Custom hooks
159
- var keyboardMovements = (0, _useKeyboardMovements.useKeyboardMovements)(menuPosition);
160
- var transformedDataset = (0, _useTransformedDataset.useTransformedDataset)(deepCloneDataset, itemLabelWrapper, orderby, itemchildren, dataPath);
161
-
162
- // Apply role-based filtering if userrole prop is provided
163
- var filteredDataset = (0, _react.useMemo)(function () {
76
+ const WmMenu = memo((props) => {
77
+ var _b, _c;
78
+ const _a = props, {
79
+ menualign = "left",
80
+ menuposition: initialMenuPosition = "down,right",
81
+ menulayout = "vertical",
82
+ menuclass,
83
+ linktarget = "_self",
84
+ iconclass,
85
+ type = "button",
86
+ animateitems,
87
+ disableMenuContext = false,
88
+ showonhover = false,
89
+ panelPosition,
90
+ autoclose = "outsideClick",
91
+ autoopen = "never",
92
+ hint,
93
+ arialabel,
94
+ width,
95
+ height,
96
+ iconposition = "left",
97
+ caption,
98
+ shortcutkey,
99
+ onClick,
100
+ onSelect,
101
+ navNodes = [],
102
+ styles,
103
+ conditionalstyles,
104
+ className,
105
+ children,
106
+ listener,
107
+ name,
108
+ resetNavNodes,
109
+ nodes$,
110
+ dataset,
111
+ orderby,
112
+ itemlabel = "label",
113
+ itemlink = "Link",
114
+ itemicon = "Icon",
115
+ itemaction,
116
+ userrole,
117
+ loggedInUser,
118
+ itemchildren = "children",
119
+ isactive,
120
+ displayValue,
121
+ onActionsclick,
122
+ dataPath,
123
+ isFromNav = false,
124
+ onNavItemActivate,
125
+ isNavItemActive = false
126
+ } = _a, restProps = __objRest(_a, [
127
+ "menualign",
128
+ "menuposition",
129
+ "menulayout",
130
+ "menuclass",
131
+ "linktarget",
132
+ "iconclass",
133
+ "type",
134
+ "animateitems",
135
+ "disableMenuContext",
136
+ "showonhover",
137
+ "panelPosition",
138
+ "autoclose",
139
+ "autoopen",
140
+ "hint",
141
+ "arialabel",
142
+ "width",
143
+ "height",
144
+ "iconposition",
145
+ "caption",
146
+ "shortcutkey",
147
+ "onClick",
148
+ "onSelect",
149
+ "navNodes",
150
+ "styles",
151
+ "conditionalstyles",
152
+ "className",
153
+ "children",
154
+ "listener",
155
+ "name",
156
+ "resetNavNodes",
157
+ "nodes$",
158
+ "dataset",
159
+ "orderby",
160
+ "itemlabel",
161
+ "itemlink",
162
+ "itemicon",
163
+ "itemaction",
164
+ "userrole",
165
+ "loggedInUser",
166
+ "itemchildren",
167
+ "isactive",
168
+ "displayValue",
169
+ "onActionsclick",
170
+ "dataPath",
171
+ "isFromNav",
172
+ "onNavItemActivate",
173
+ "isNavItemActive"
174
+ ]);
175
+ const deepCloneDataset = cloneDeep(dataset);
176
+ const itemLabelWrapper = typeof itemlabel === "function" ? (rest) => itemlabel(__spreadValues({ App: listener == null ? void 0 : listener.App }, rest)) : itemlabel;
177
+ const path = usePathname();
178
+ const user = useMemo(
179
+ () => {
180
+ var _a2, _b2;
181
+ return (_b2 = loggedInUser != null ? loggedInUser : (_a2 = listener == null ? void 0 : listener.appConfig) == null ? void 0 : _a2.loggedInUser) != null ? _b2 : null;
182
+ },
183
+ [loggedInUser, (_b = listener == null ? void 0 : listener.appConfig) == null ? void 0 : _b.loggedInUser]
184
+ );
185
+ const [open, setOpen] = useState(false);
186
+ const [activeItem, setActiveItem] = useState(null);
187
+ const [focusedIndex, setFocusedIndex] = useState(-1);
188
+ const [menuPosition, setMenuPosition] = useState(initialMenuPosition);
189
+ const buttonRef = useRef(null);
190
+ const menuRef = useRef(null);
191
+ const keyboardMovements = useKeyboardMovements(menuPosition);
192
+ const transformedDataset = useTransformedDataset(
193
+ deepCloneDataset,
194
+ itemLabelWrapper,
195
+ orderby,
196
+ itemchildren,
197
+ dataPath
198
+ );
199
+ const filteredDataset = useMemo(() => {
164
200
  if (!userrole || !transformedDataset) {
165
201
  return transformedDataset;
166
202
  }
167
-
168
- // Get user roles from the logged-in user
169
- var userRoles = (user === null || user === void 0 ? void 0 : user.roles) || [];
170
-
171
- // Apply role filtering with the dynamic userrole key
172
- return (0, _roleFilter.filterMenuNodesByRole)(transformedDataset, userRoles, userrole);
173
- }, [transformedDataset, userrole, user === null || user === void 0 ? void 0 : user.roles]);
174
- var _useHoverState = (0, _useHoverState2.useHoverState)(),
175
- hoveredPaths = _useHoverState.hoveredPaths,
176
- handlePathMouseEnter = _useHoverState.handlePathMouseEnter,
177
- handlePathMouseLeave = _useHoverState.handlePathMouseLeave;
178
-
179
- // Hover handlers for showonhover functionality
180
- var handleContainerMouseEnter = (0, _react.useCallback)(function () {
203
+ const userRoles = (user == null ? void 0 : user.roles) || [];
204
+ return filterMenuNodesByRole(transformedDataset, userRoles, userrole);
205
+ }, [transformedDataset, userrole, user == null ? void 0 : user.roles]);
206
+ const { hoveredPaths, handlePathMouseEnter, handlePathMouseLeave } = useHoverState();
207
+ const handleContainerMouseEnter = useCallback(() => {
181
208
  if (showonhover) {
182
209
  setOpen(true);
183
210
  }
184
211
  }, [showonhover]);
185
- var handleContainerMouseLeave = (0, _react.useCallback)(function (event) {
186
- var _relatedTarget$classL, _relatedTarget$closes, _relatedTarget$closes2;
187
- if (!showonhover) return;
188
- var relatedTarget = event === null || event === void 0 ? void 0 : event.relatedTarget;
189
- var isMovingToMenu = relatedTarget && (((_relatedTarget$classL = relatedTarget.classList) === null || _relatedTarget$classL === void 0 ? void 0 : _relatedTarget$classL.contains("dropdown-menu")) || ((_relatedTarget$closes = relatedTarget.closest) === null || _relatedTarget$closes === void 0 ? void 0 : _relatedTarget$closes.call(relatedTarget, ".dropdown-menu")) !== null || ((_relatedTarget$closes2 = relatedTarget.closest) === null || _relatedTarget$closes2 === void 0 ? void 0 : _relatedTarget$closes2.call(relatedTarget, ".app-menu")) !== null);
190
- if (!isMovingToMenu) {
191
- setOpen(false);
192
- setFocusedIndex(-1);
193
- setActiveItem(null);
194
- }
195
- }, [showonhover]);
196
-
197
- // Memoized values
198
- var transformChildrenDataset = (0, _react.useCallback)(function (children) {
199
- if (!children || !Array.isArray(children)) return [];
200
- return (0, _transformedDatasetUtils.transformDataset)(children, "", itemLabelWrapper, undefined, undefined, orderby, undefined, undefined, itemchildren);
201
- }, [itemLabelWrapper, orderby]);
202
- var createRefsForNodes = (0, _react.useCallback)(function (nodes) {
203
- if (!nodes || !Array.isArray(nodes)) return [];
204
- return nodes.map(function (node) {
205
- var _dataObject;
206
- var nodeWithRef = _objectSpread({}, node);
207
- if (!nodeWithRef.nodeRef) {
208
- nodeWithRef.nodeRef = /*#__PURE__*/_react["default"].createRef();
209
- }
210
-
211
- // Check for children at node.children first, then at dataObject.children (where datasetItems stores them)
212
- var existingChildren = nodeWithRef.children || ((_dataObject = nodeWithRef.dataObject) === null || _dataObject === void 0 ? void 0 : _dataObject.children);
213
- if (existingChildren && existingChildren.length) {
214
- var _existingChildren$;
215
- // If children already have dataObject (already transformed by datasetItems), just add refs
216
- // Otherwise, transform them first
217
- var alreadyTransformed = ((_existingChildren$ = existingChildren[0]) === null || _existingChildren$ === void 0 ? void 0 : _existingChildren$.dataObject) !== undefined;
218
- var processedChildren = alreadyTransformed ? existingChildren : transformChildrenDataset(existingChildren);
219
- nodeWithRef.children = createRefsForNodes(processedChildren);
212
+ const handleContainerMouseLeave = useCallback(
213
+ (event) => {
214
+ var _a2, _b2, _c2;
215
+ if (!showonhover) return;
216
+ const relatedTarget = event == null ? void 0 : event.relatedTarget;
217
+ const isMovingToMenu = relatedTarget && (((_a2 = relatedTarget.classList) == null ? void 0 : _a2.contains("dropdown-menu")) || ((_b2 = relatedTarget.closest) == null ? void 0 : _b2.call(relatedTarget, ".dropdown-menu")) !== null || ((_c2 = relatedTarget.closest) == null ? void 0 : _c2.call(relatedTarget, ".app-menu")) !== null);
218
+ if (!isMovingToMenu) {
219
+ setOpen(false);
220
+ setFocusedIndex(-1);
221
+ setActiveItem(null);
220
222
  }
221
- return nodeWithRef;
222
- });
223
- }, [transformChildrenDataset]);
224
- var nodesWithRefs = (0, _react.useMemo)(function () {
225
- return createRefsForNodes(filteredDataset);
226
- }, [filteredDataset, createRefsForNodes]);
227
- var flattenNodes = (0, _react.useCallback)(function (nodes) {
223
+ },
224
+ [showonhover]
225
+ );
226
+ const transformChildrenDataset = useCallback(
227
+ (children2) => {
228
+ if (!children2 || !Array.isArray(children2)) return [];
229
+ return transformDataset(
230
+ children2,
231
+ "",
232
+ itemLabelWrapper,
233
+ void 0,
234
+ void 0,
235
+ orderby,
236
+ void 0,
237
+ void 0,
238
+ itemchildren
239
+ );
240
+ },
241
+ [itemLabelWrapper, orderby]
242
+ );
243
+ const createRefsForNodes = useCallback(
244
+ (nodes) => {
245
+ if (!nodes || !Array.isArray(nodes)) return [];
246
+ return nodes.map((node) => {
247
+ var _a2, _b2;
248
+ const nodeWithRef = __spreadValues({}, node);
249
+ if (!nodeWithRef.nodeRef) {
250
+ nodeWithRef.nodeRef = React.createRef();
251
+ }
252
+ const existingChildren = nodeWithRef.children || ((_a2 = nodeWithRef.dataObject) == null ? void 0 : _a2.children);
253
+ if (existingChildren && existingChildren.length) {
254
+ const alreadyTransformed = ((_b2 = existingChildren[0]) == null ? void 0 : _b2.dataObject) !== void 0;
255
+ const processedChildren = alreadyTransformed ? existingChildren : transformChildrenDataset(existingChildren);
256
+ nodeWithRef.children = createRefsForNodes(processedChildren);
257
+ }
258
+ return nodeWithRef;
259
+ });
260
+ },
261
+ [transformChildrenDataset]
262
+ );
263
+ const nodesWithRefs = useMemo(
264
+ () => createRefsForNodes(filteredDataset),
265
+ [filteredDataset, createRefsForNodes]
266
+ );
267
+ const flattenNodes = useCallback((nodes) => {
228
268
  if (!nodes || !Array.isArray(nodes)) return [];
229
- return nodes.reduce(function (acc, node) {
269
+ return nodes.reduce((acc, node) => {
230
270
  acc.push(node);
231
271
  if (node.children && node.children.length) {
232
- acc.push.apply(acc, (0, _toConsumableArray2["default"])(flattenNodes(node.children)));
272
+ acc.push(...flattenNodes(node.children));
233
273
  }
234
274
  return acc;
235
275
  }, []);
236
276
  }, []);
237
- var flattenedNodes = (0, _react.useMemo)(function () {
238
- return flattenNodes(nodesWithRefs);
239
- }, [nodesWithRefs, flattenNodes]);
240
- var getNodeProperties = (0, _react.useCallback)(function (node) {
241
- var dataObject = node.dataObject || {};
242
- var label;
243
- var children;
244
-
245
- // Handle itemlabel - can be a string (field name) or function (expression)
246
- if (typeof itemLabelWrapper === "function") {
247
- try {
248
- label = itemLabelWrapper(dataObject);
249
- } catch (error) {
250
- console.warn("Error evaluating itemlabel expression:", error);
251
- label = (node === null || node === void 0 ? void 0 : node["label"]) || dataObject["label"];
277
+ const flattenedNodes = useMemo(() => flattenNodes(nodesWithRefs), [nodesWithRefs, flattenNodes]);
278
+ const getNodeProperties = useCallback(
279
+ (node) => {
280
+ const dataObject = node.dataObject || {};
281
+ let label;
282
+ let children2;
283
+ if (typeof itemLabelWrapper === "function") {
284
+ try {
285
+ label = itemLabelWrapper(dataObject);
286
+ } catch (error) {
287
+ console.warn("Error evaluating itemlabel expression:", error);
288
+ label = (node == null ? void 0 : node["label"]) || dataObject["label"];
289
+ }
290
+ } else {
291
+ label = (node == null ? void 0 : node[itemLabelWrapper]) || dataObject[itemLabelWrapper];
252
292
  }
253
- } else {
254
- label = (node === null || node === void 0 ? void 0 : node[itemLabelWrapper]) || dataObject[itemLabelWrapper];
255
- }
256
-
257
- // Handle itemchildren - can be a string (field name) or function (expression)
258
- if (typeof itemchildren === "function") {
259
- try {
260
- var childrenData = itemchildren(dataObject);
261
- if (Array.isArray(childrenData)) {
262
- children = transformChildrenDataset(childrenData);
263
- } else {
264
- children = childrenData;
293
+ if (typeof itemchildren === "function") {
294
+ try {
295
+ const childrenData = itemchildren(dataObject);
296
+ if (Array.isArray(childrenData)) {
297
+ children2 = transformChildrenDataset(childrenData);
298
+ } else {
299
+ children2 = childrenData;
300
+ }
301
+ } catch (error) {
302
+ console.warn("Error evaluating itemchildren expression:", error);
303
+ children2 = (node == null ? void 0 : node["children"]) || dataObject["children"];
265
304
  }
266
- } catch (error) {
267
- console.warn("Error evaluating itemchildren expression:", error);
268
- children = (node === null || node === void 0 ? void 0 : node["children"]) || dataObject["children"];
305
+ } else {
306
+ children2 = (node == null ? void 0 : node.children) || (dataObject == null ? void 0 : dataObject.children) || (node == null ? void 0 : node[itemchildren]) || (dataObject == null ? void 0 : dataObject[itemchildren]);
269
307
  }
270
- } else {
271
- // First check for already-transformed children (stored at 'children' by datasetItems),
272
- // then fall back to raw data at the itemchildren key
273
- children = (node === null || node === void 0 ? void 0 : node.children) || (dataObject === null || dataObject === void 0 ? void 0 : dataObject.children) || (node === null || node === void 0 ? void 0 : node[itemchildren]) || (dataObject === null || dataObject === void 0 ? void 0 : dataObject[itemchildren]);
274
- }
275
- return {
276
- label: label,
277
- icon: (node === null || node === void 0 ? void 0 : node[itemicon]) || dataObject[itemicon],
278
- link: (node === null || node === void 0 ? void 0 : node[itemlink]) || dataObject[itemlink] || dataObject["link"],
279
- hint: (node === null || node === void 0 ? void 0 : node[hint]) || dataObject[hint],
280
- disabled: (node === null || node === void 0 ? void 0 : node.disabled) || dataObject.disabled,
281
- children: children
282
- };
283
- }, [itemlabel, itemicon, itemlink, hint, itemchildren]);
284
-
285
- // Computed styles
286
- var buttonStyles = (0, _react.useMemo)(function () {
287
- return _objectSpread(_objectSpread(_objectSpread(_objectSpread({}, styles), conditionalstyles), width !== undefined && {
288
- width: typeof width === "number" ? "".concat(width, "px") : width
289
- }), height !== undefined && {
290
- height: typeof height === "number" ? "".concat(height, "px") : height
291
- });
292
- }, [styles, conditionalstyles, width, height]);
293
- var menuContainerStyles = (0, _react.useMemo)(function () {
294
- return {
308
+ return {
309
+ label,
310
+ icon: (node == null ? void 0 : node[itemicon]) || dataObject[itemicon],
311
+ link: (node == null ? void 0 : node[itemlink]) || dataObject[itemlink] || dataObject["link"],
312
+ hint: (node == null ? void 0 : node[hint]) || dataObject[hint],
313
+ disabled: (node == null ? void 0 : node.disabled) || dataObject.disabled,
314
+ children: children2
315
+ };
316
+ },
317
+ [itemlabel, itemicon, itemlink, hint, itemchildren]
318
+ );
319
+ const buttonStyles = useMemo(
320
+ () => __spreadValues(__spreadValues(__spreadValues(__spreadValues({}, styles), conditionalstyles), width !== void 0 && { width: typeof width === "number" ? `${width}px` : width }), height !== void 0 && { height: typeof height === "number" ? `${height}px` : height }),
321
+ [styles, conditionalstyles, width, height]
322
+ );
323
+ const menuContainerStyles = useMemo(
324
+ () => ({
295
325
  textAlign: menualign,
296
326
  position: "relative"
297
- };
298
- }, [menualign]);
299
- var getMenuLayoutStyles = (0, _react.useCallback)(function () {
327
+ }),
328
+ [menualign]
329
+ );
330
+ const getMenuLayoutStyles = useCallback(() => {
300
331
  switch (menulayout) {
301
- case _constants.LAYOUT.HORIZONTAL:
332
+ case LAYOUT.HORIZONTAL:
302
333
  return {
303
334
  display: "flex",
304
335
  flexDirection: "row"
305
336
  };
306
- case _constants.LAYOUT.GRID:
337
+ case LAYOUT.GRID:
307
338
  return {
308
339
  display: "grid",
309
340
  gridTemplateColumns: "repeat(auto-fill, minmax(150px, 1fr))",
310
341
  gap: "8px"
311
342
  };
312
- case _constants.LAYOUT.VERTICAL:
343
+ case LAYOUT.VERTICAL:
313
344
  default:
314
345
  return {
315
346
  display: "block"
316
347
  };
317
348
  }
318
349
  }, [menulayout]);
319
-
320
- // Event handlers
321
- var handleMenuClick = (0, _react.useCallback)(function (event) {
322
- event.preventDefault();
323
- if (onClick && listener !== null && listener !== void 0 && listener.Widgets && name && listener.Widgets[name]) {
324
- onClick(event, listener.Widgets[name]);
325
- }
326
- setOpen(function (prevState) {
327
- return !prevState;
328
- });
329
- if (!open) {
330
- setActiveItem(null);
331
- setFocusedIndex(-1);
332
- }
333
-
334
- // If menu is from nav, notify nav to activate the nav item when menu button is clicked
335
- if (isFromNav && onNavItemActivate) {
336
- onNavItemActivate();
337
- }
338
- }, [onClick, listener, name, open, isFromNav, onNavItemActivate]);
339
- var handleMenuItemClick = (0, _react.useCallback)(function (event, item) {
340
- var _item$dataObject, _item$dataObject2, _item$dataObject3, _item$dataObject4, _item$dataObject5;
341
- // since event is a synthetic event, we need to convert it to a native event to support the angular behavior
342
- event = event.nativeEvent;
343
- var _getNodeProperties = getNodeProperties(item),
344
- label = _getNodeProperties.label,
345
- icon = _getNodeProperties.icon,
346
- link = _getNodeProperties.link;
347
-
348
- // Only prevent default if item has children (submenu) or no valid link
349
- if (item.children && item.children.length > 0 || !link || link === "#") {
350
+ const handleMenuClick = useCallback(
351
+ (event) => {
350
352
  event.preventDefault();
351
- }
352
- setActiveItem(item);
353
- var index = flattenedNodes.findIndex(function (node) {
354
- return node === item;
355
- });
356
- if (index !== -1) {
357
- setFocusedIndex(index);
358
- }
359
- (0, _actionTask.executeActionTaskFromItem)(item, listener);
360
- if (item.children && item.children.length > 0) {
361
- item.expanded = !item.expanded;
362
- }
363
-
364
- // Create a simplified item object with only the required properties
365
- var simplifiedItem = _objectSpread(_objectSpread({}, item.dataObject || {}), {}, {
366
- name: ((_item$dataObject = item.dataObject) === null || _item$dataObject === void 0 ? void 0 : _item$dataObject.name) || name,
367
- label: label,
368
- dataValue: ((_item$dataObject2 = item.dataObject) === null || _item$dataObject2 === void 0 ? void 0 : _item$dataObject2.dataValue) || label,
369
- value: ((_item$dataObject3 = item.dataObject) === null || _item$dataObject3 === void 0 ? void 0 : _item$dataObject3.dataValue) || label,
370
- icon: ((_item$dataObject4 = item.dataObject) === null || _item$dataObject4 === void 0 ? void 0 : _item$dataObject4.icon) || icon,
371
- link: link,
372
- target: (_item$dataObject5 = item.dataObject) === null || _item$dataObject5 === void 0 ? void 0 : _item$dataObject5.target
373
- }, item === null || item === void 0 ? void 0 : item.value);
374
- if (onSelect) {
375
- onSelect(event, props, simplifiedItem);
376
- }
377
-
378
- // If menu is from nav, notify nav to activate the nav item
379
- if (isFromNav && onNavItemActivate) {
380
- onNavItemActivate();
381
- }
382
- if (name && listener !== null && listener !== void 0 && listener.Widgets[name]) {
383
- listener.Widgets[name].displayValue = label;
384
- }
385
- if (listener !== null && listener !== void 0 && listener.onChange) {
386
- listener.onChange(name, {
387
- datavalue: label
388
- });
389
- }
390
- var routeName = (0, _constants2.hyperLinkMofify)((0, _utils.getRouteNameFromLink)((simplifiedItem === null || simplifiedItem === void 0 ? void 0 : simplifiedItem.link) || ""));
391
- // Check if target route is the current page - skip navigation to prevent refresh
392
- var currentPath = window.location.pathname;
393
- if (routeName !== currentPath) {
394
- // timeout is used so that onSelect can perform its actions before the navigation happens
395
- setTimeout(function () {
396
- // this function is used to navigate when menuitem is expected to work as anchor
397
- (0, _utils.triggerItemAction)(simplifiedItem);
398
- }, 0);
399
- }
400
- if (autoclose === _constants.AUTO_CLOSE.ALWAYS && (!item.children || item.children.length === 0)) {
401
- setOpen(false);
402
- setFocusedIndex(-1);
403
- }
404
- onActionsclick === null || onActionsclick === void 0 || onActionsclick(item);
405
- }, [flattenedNodes, onSelect, props, name, listener, autoclose, getNodeProperties, isFromNav, onNavItemActivate]);
406
-
407
- // Keyboard navigation
408
- var focusNode = (0, _react.useCallback)(function (index) {
409
- var _flattenedNodes$index;
410
- if ((_flattenedNodes$index = flattenedNodes[index]) !== null && _flattenedNodes$index !== void 0 && (_flattenedNodes$index = _flattenedNodes$index.nodeRef) !== null && _flattenedNodes$index !== void 0 && _flattenedNodes$index.current) {
411
- flattenedNodes[index].nodeRef.current.focus();
412
- }
413
- }, [flattenedNodes]);
414
- var closeMenu = (0, _react.useCallback)(function () {
415
- var _buttonRef$current;
353
+ if (onClick && (listener == null ? void 0 : listener.Widgets) && name && listener.Widgets[name]) {
354
+ onClick(event, listener.Widgets[name]);
355
+ }
356
+ setOpen((prevState) => !prevState);
357
+ if (!open) {
358
+ setActiveItem(null);
359
+ setFocusedIndex(-1);
360
+ }
361
+ if (isFromNav && onNavItemActivate) {
362
+ onNavItemActivate();
363
+ }
364
+ },
365
+ [onClick, listener, name, open, isFromNav, onNavItemActivate]
366
+ );
367
+ const handleMenuItemClick = useCallback(
368
+ (event, item) => {
369
+ var _a2, _b2, _c2, _d, _e;
370
+ event = event.nativeEvent;
371
+ const { label, icon, link } = getNodeProperties(item);
372
+ if (item.children && item.children.length > 0 || !link || link === "#") {
373
+ event.preventDefault();
374
+ }
375
+ setActiveItem(item);
376
+ const index = flattenedNodes.findIndex((node) => node === item);
377
+ if (index !== -1) {
378
+ setFocusedIndex(index);
379
+ }
380
+ executeActionTaskFromItem(item, listener);
381
+ if (item.children && item.children.length > 0) {
382
+ item.expanded = !item.expanded;
383
+ }
384
+ const simplifiedItem = __spreadValues(__spreadProps(__spreadValues({}, item.dataObject || {}), {
385
+ name: ((_a2 = item.dataObject) == null ? void 0 : _a2.name) || name,
386
+ label,
387
+ dataValue: ((_b2 = item.dataObject) == null ? void 0 : _b2.dataValue) || label,
388
+ value: ((_c2 = item.dataObject) == null ? void 0 : _c2.dataValue) || label,
389
+ icon: ((_d = item.dataObject) == null ? void 0 : _d.icon) || icon,
390
+ link,
391
+ target: (_e = item.dataObject) == null ? void 0 : _e.target
392
+ }), item == null ? void 0 : item.value);
393
+ if (onSelect) {
394
+ onSelect(event, props, simplifiedItem);
395
+ }
396
+ if (isFromNav && onNavItemActivate) {
397
+ onNavItemActivate();
398
+ }
399
+ if (name && (listener == null ? void 0 : listener.Widgets[name])) {
400
+ listener.Widgets[name].displayValue = label;
401
+ }
402
+ if (listener == null ? void 0 : listener.onChange) {
403
+ listener.onChange(name, {
404
+ datavalue: label
405
+ });
406
+ }
407
+ const routeName = hyperLinkMofify(getRouteNameFromLink((simplifiedItem == null ? void 0 : simplifiedItem.link) || ""));
408
+ const currentPath = window.location.pathname;
409
+ if (routeName !== currentPath) {
410
+ setTimeout(() => {
411
+ triggerItemAction(simplifiedItem);
412
+ }, 0);
413
+ }
414
+ if (autoclose === AUTO_CLOSE.ALWAYS && (!item.children || item.children.length === 0)) {
415
+ setOpen(false);
416
+ setFocusedIndex(-1);
417
+ }
418
+ onActionsclick == null ? void 0 : onActionsclick(item);
419
+ },
420
+ [
421
+ flattenedNodes,
422
+ onSelect,
423
+ props,
424
+ name,
425
+ listener,
426
+ autoclose,
427
+ getNodeProperties,
428
+ isFromNav,
429
+ onNavItemActivate
430
+ ]
431
+ );
432
+ const focusNode = useCallback(
433
+ (index) => {
434
+ var _a2, _b2;
435
+ if ((_b2 = (_a2 = flattenedNodes[index]) == null ? void 0 : _a2.nodeRef) == null ? void 0 : _b2.current) {
436
+ flattenedNodes[index].nodeRef.current.focus();
437
+ }
438
+ },
439
+ [flattenedNodes]
440
+ );
441
+ const closeMenu = useCallback(() => {
442
+ var _a2;
416
443
  setOpen(false);
417
444
  setFocusedIndex(-1);
418
445
  setActiveItem(null);
419
- (_buttonRef$current = buttonRef.current) === null || _buttonRef$current === void 0 || _buttonRef$current.focus();
446
+ (_a2 = buttonRef.current) == null ? void 0 : _a2.focus();
420
447
  }, []);
421
- var toggleMenu = (0, _react.useCallback)(function () {
422
- setOpen(function (prevOpen) {
423
- return !prevOpen;
424
- });
448
+ const toggleMenu = useCallback(() => {
449
+ setOpen((prevOpen) => !prevOpen);
425
450
  }, []);
426
- var handleArrowDown = (0, _react.useCallback)(function (event) {
427
- if (keyboardMovements.MOVE_DOWN !== "DOWN-ARROW") return;
428
- event.preventDefault();
429
- if (!open) {
430
- setOpen(true);
431
- return;
432
- }
433
- var nextIndex = focusedIndex < 0 ? 0 : (focusedIndex + 1) % flattenedNodes.length;
434
- setFocusedIndex(nextIndex);
435
- focusNode(nextIndex);
436
- }, [keyboardMovements, open, focusedIndex, flattenedNodes.length, focusNode]);
437
- var handleArrowUp = (0, _react.useCallback)(function (event) {
438
- if (keyboardMovements.MOVE_UP !== "UP-ARROW") return;
439
- event.preventDefault();
440
- if (!open) {
441
- setOpen(true);
442
- return;
443
- }
444
- if (focusedIndex === 0) {
445
- closeMenu();
446
- return;
447
- }
448
- var prevIndex = focusedIndex <= 0 ? flattenedNodes.length - 1 : (focusedIndex - 1) % flattenedNodes.length;
449
- setFocusedIndex(prevIndex);
450
- focusNode(prevIndex);
451
- }, [keyboardMovements, open, focusedIndex, flattenedNodes.length, focusNode, closeMenu]);
452
- var handleEnterOrSpace = (0, _react.useCallback)(function (event) {
453
- if (keyboardMovements.ON_ENTER !== "ENTER") return;
454
- event.preventDefault();
455
- if (focusedIndex >= 0 && flattenedNodes[focusedIndex]) {
456
- handleMenuItemClick(event, flattenedNodes[focusedIndex]);
457
- } else if (open) {
458
- closeMenu();
459
- }
460
- }, [keyboardMovements, focusedIndex, flattenedNodes, handleMenuItemClick, open, closeMenu]);
461
- var handleEscape = (0, _react.useCallback)(function (event) {
462
- if (keyboardMovements.ON_ESCAPE !== "ESC") return;
463
- event.preventDefault();
464
- closeMenu();
465
- }, [keyboardMovements, closeMenu]);
466
- var moveFocusHorizontally = (0, _react.useCallback)(function (direction) {
467
- var nextIndex = (focusedIndex + direction + flattenedNodes.length) % flattenedNodes.length;
468
- setFocusedIndex(nextIndex);
469
- focusNode(nextIndex);
470
- }, [focusedIndex, flattenedNodes.length, focusNode]);
471
- var expandAndFocusChild = (0, _react.useCallback)(function (currentItem) {
472
- currentItem.expanded = true;
473
- var firstChild = currentItem.children[0];
474
- var childIndex = flattenedNodes.findIndex(function (node) {
475
- return node === firstChild;
476
- });
477
- if (childIndex !== -1) {
478
- setFocusedIndex(childIndex);
479
- setActiveItem(flattenedNodes[childIndex]);
480
- focusNode(childIndex);
481
- }
482
- }, [flattenedNodes, focusNode]);
483
- var collapseAndFocusParent = (0, _react.useCallback)(function (currentItem) {
484
- var parentIndex = flattenedNodes.findIndex(function (node) {
485
- var _node$children;
486
- return (_node$children = node.children) === null || _node$children === void 0 ? void 0 : _node$children.some(function (child) {
487
- return child === currentItem;
488
- });
489
- });
490
- if (parentIndex !== -1) {
491
- flattenedNodes[parentIndex].expanded = false;
492
- setFocusedIndex(parentIndex);
493
- setActiveItem(flattenedNodes[parentIndex]);
494
- focusNode(parentIndex);
495
- }
496
- }, [flattenedNodes, focusNode]);
497
- var handleArrowRight = (0, _react.useCallback)(function (event) {
498
- if (menulayout === _constants.LAYOUT.HORIZONTAL || keyboardMovements.MOVE_RIGHT !== "RIGHT-ARROW") return;
499
- event.preventDefault();
500
- if (focusedIndex >= 0 && flattenedNodes[focusedIndex]) {
501
- var currentItem = flattenedNodes[focusedIndex];
502
- if (currentItem.children && currentItem.children.length > 0) {
503
- expandAndFocusChild(currentItem);
504
- } else if (menulayout === _constants.LAYOUT.HORIZONTAL) {
505
- moveFocusHorizontally(1);
451
+ const handleArrowDown = useCallback(
452
+ (event) => {
453
+ if (keyboardMovements.MOVE_DOWN !== "DOWN-ARROW") return;
454
+ event.preventDefault();
455
+ if (!open) {
456
+ setOpen(true);
457
+ return;
506
458
  }
507
- }
508
- }, [menulayout, keyboardMovements, focusedIndex, flattenedNodes, expandAndFocusChild, moveFocusHorizontally]);
509
- var handleArrowLeft = (0, _react.useCallback)(function (event) {
510
- if (menulayout === _constants.LAYOUT.HORIZONTAL || keyboardMovements.MOVE_LEFT !== "LEFT-ARROW") return;
511
- event.preventDefault();
512
- if (focusedIndex >= 0 && flattenedNodes[focusedIndex]) {
513
- var currentItem = flattenedNodes[focusedIndex];
514
- if (menulayout === _constants.LAYOUT.HORIZONTAL) {
515
- moveFocusHorizontally(-1);
516
- } else {
517
- collapseAndFocusParent(currentItem);
459
+ const nextIndex = focusedIndex < 0 ? 0 : (focusedIndex + 1) % flattenedNodes.length;
460
+ setFocusedIndex(nextIndex);
461
+ focusNode(nextIndex);
462
+ },
463
+ [keyboardMovements, open, focusedIndex, flattenedNodes.length, focusNode]
464
+ );
465
+ const handleArrowUp = useCallback(
466
+ (event) => {
467
+ if (keyboardMovements.MOVE_UP !== "UP-ARROW") return;
468
+ event.preventDefault();
469
+ if (!open) {
470
+ setOpen(true);
471
+ return;
518
472
  }
519
- }
520
- }, [menulayout, keyboardMovements, focusedIndex, flattenedNodes, moveFocusHorizontally, collapseAndFocusParent]);
521
- var handleKeyDown = (0, _react.useCallback)(function (event) {
522
- var key = event.key;
523
- if (key === "Enter" && document.activeElement === buttonRef.current) {
473
+ if (focusedIndex === 0) {
474
+ closeMenu();
475
+ return;
476
+ }
477
+ const prevIndex = focusedIndex <= 0 ? flattenedNodes.length - 1 : (focusedIndex - 1) % flattenedNodes.length;
478
+ setFocusedIndex(prevIndex);
479
+ focusNode(prevIndex);
480
+ },
481
+ [keyboardMovements, open, focusedIndex, flattenedNodes.length, focusNode, closeMenu]
482
+ );
483
+ const handleEnterOrSpace = useCallback(
484
+ (event) => {
485
+ if (keyboardMovements.ON_ENTER !== "ENTER") return;
524
486
  event.preventDefault();
525
- toggleMenu();
526
- return;
527
- }
528
- if (!open && key === "Enter") {
487
+ if (focusedIndex >= 0 && flattenedNodes[focusedIndex]) {
488
+ handleMenuItemClick(event, flattenedNodes[focusedIndex]);
489
+ } else if (open) {
490
+ closeMenu();
491
+ }
492
+ },
493
+ [keyboardMovements, focusedIndex, flattenedNodes, handleMenuItemClick, open, closeMenu]
494
+ );
495
+ const handleEscape = useCallback(
496
+ (event) => {
497
+ if (keyboardMovements.ON_ESCAPE !== "ESC") return;
529
498
  event.preventDefault();
530
- setOpen(true);
531
- return;
532
- }
533
- if (!open && !["ArrowDown", "ArrowUp", "Enter", " "].includes(key)) {
534
- return;
535
- }
536
- if (flattenedNodes.length === 0 && open) return;
537
- var keyHandlers = {
538
- ArrowDown: handleArrowDown,
539
- ArrowUp: handleArrowUp,
540
- Enter: handleEnterOrSpace,
541
- " ": handleEnterOrSpace,
542
- Escape: handleEscape,
543
- Tab: closeMenu,
544
- ArrowRight: handleArrowRight,
545
- ArrowLeft: handleArrowLeft
546
- };
547
- var handler = keyHandlers[key];
548
- if (handler) {
549
- handler(event);
550
- }
551
- }, [open, flattenedNodes.length, toggleMenu, handleArrowDown, handleArrowUp, handleEnterOrSpace, handleEscape, closeMenu, handleArrowRight, handleArrowLeft]);
552
-
553
- // Render functions
554
- /**
555
- * Recursively renders menu items with path-based hover tracking.
556
- *
557
- * @param nodes - Array of menu nodes to render
558
- * @param pathPrefix - Parent path prefix for generating unique item paths
559
- * e.g., "" for root, "0" for first item's children, "0-1" for nested
560
- *
561
- * Path structure examples:
562
- * - Root item 0: "0"
563
- * - Root item 1: "1"
564
- * - First child of item 0: "0-0"
565
- * - Second child of item 1: "1-1"
566
- * - Grandchild: "0-0-0"
567
- */
568
- var renderMenuItems = (0, _react.useCallback)(function (nodes) {
569
- var pathPrefix = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : "";
570
- if (!nodes || !Array.isArray(nodes)) return null;
571
- return nodes.map(function (node, index) {
572
- var _value;
573
- var _getNodeProperties2 = getNodeProperties(node),
574
- label = _getNodeProperties2.label,
575
- icon = _getNodeProperties2.icon,
576
- link = _getNodeProperties2.link,
577
- hint = _getNodeProperties2.hint,
578
- disabled = _getNodeProperties2.disabled,
579
- children = _getNodeProperties2.children;
580
-
581
- // Generate unique path for this menu item by combining parent path with index
582
- var itemPath = pathPrefix ? "".concat(pathPrefix, "-").concat(index) : "".concat(index);
583
- var nodeValueLink = node === null || node === void 0 || (_value = node.value) === null || _value === void 0 ? void 0 : _value.link;
584
- var isActive = nodeValueLink && typeof nodeValueLink === "string" ? isPathMatchingLink(path, nodeValueLink) : link ? isPathMatchingLink(path, link) : false;
585
- var _menuPosition$split = menuPosition.split(","),
586
- _menuPosition$split2 = (0, _slicedToArray2["default"])(_menuPosition$split, 2),
587
- verticalPos = _menuPosition$split2[0],
588
- horizontalPos = _menuPosition$split2[1];
589
-
590
- // Check if this specific path is currently hovered
591
- var isHovered = hoveredPaths.has(itemPath);
592
-
593
- // Submenu opens when item is expanded OR hovered
594
- var isSubmenuOpen = node.expanded || isHovered;
595
- var submenuClassName = (0, _ListItems.buildMenuListClasses)(iconposition, menulayout, horizontalPos, panelPosition, animateitems, menuPosition, isHovered);
596
- return __jsx(_Box["default"], {
597
- component: "li",
598
- key: index,
599
- className: (0, _clsx["default"])(children && children.length > 0 && "dropdown-submenu", "app-menu-item", {
600
- active: isActive,
601
- hovered: isHovered
602
- })
603
- // Track hover state for this item's path
604
- ,
605
- onMouseEnter: function onMouseEnter() {
606
- return handlePathMouseEnter(itemPath);
607
- },
608
- onMouseLeave: function onMouseLeave(e) {
609
- return handlePathMouseLeave(itemPath, e);
610
- },
611
- style: {
612
- position: "relative"
613
- }
614
- }, __jsx(_Link["default"], {
615
- title: label,
616
- className: disabled ? "disabled" : "",
617
- onClick: function onClick(event) {
618
- handleMenuItemClick(event, node);
499
+ closeMenu();
500
+ },
501
+ [keyboardMovements, closeMenu]
502
+ );
503
+ const moveFocusHorizontally = useCallback(
504
+ (direction) => {
505
+ const nextIndex = (focusedIndex + direction + flattenedNodes.length) % flattenedNodes.length;
506
+ setFocusedIndex(nextIndex);
507
+ focusNode(nextIndex);
508
+ },
509
+ [focusedIndex, flattenedNodes.length, focusNode]
510
+ );
511
+ const expandAndFocusChild = useCallback(
512
+ (currentItem) => {
513
+ currentItem.expanded = true;
514
+ const firstChild = currentItem.children[0];
515
+ const childIndex = flattenedNodes.findIndex((node) => node === firstChild);
516
+ if (childIndex !== -1) {
517
+ setFocusedIndex(childIndex);
518
+ setActiveItem(flattenedNodes[childIndex]);
519
+ focusNode(childIndex);
520
+ }
521
+ },
522
+ [flattenedNodes, focusNode]
523
+ );
524
+ const collapseAndFocusParent = useCallback(
525
+ (currentItem) => {
526
+ const parentIndex = flattenedNodes.findIndex(
527
+ (node) => {
528
+ var _a2;
529
+ return (_a2 = node.children) == null ? void 0 : _a2.some((child) => child === currentItem);
619
530
  }
620
- }, children && children.length > 0 && __jsx("span", {
621
- className: (0, _clsx["default"])("pull-right fa caret", _constants.menuAlignClass[menualign] || "fa-caret-right")
622
- }), icon && __jsx("i", {
623
- className: "app-icon ".concat(icon)
624
- }), __jsx("span", {
625
- className: "anchor-caption"
626
- }, label)), children && children.length > 0 && (type !== "anchor" ? __jsx(_ListItems.CollapsibleMenu, {
627
- isOpen: isSubmenuOpen,
628
- verticalPos: verticalPos,
629
- className: submenuClassName,
630
- style: getMenuLayoutStyles()
631
- // IMPORTANT: Submenu container also tracks the PARENT's path
632
- // This keeps the parent in hover state when mouse moves to submenu
633
- ,
634
- onMouseEnter: function onMouseEnter() {
635
- return handlePathMouseEnter(itemPath);
636
- },
637
- onMouseLeave: function onMouseLeave(e) {
638
- return handlePathMouseLeave(itemPath, e);
531
+ );
532
+ if (parentIndex !== -1) {
533
+ flattenedNodes[parentIndex].expanded = false;
534
+ setFocusedIndex(parentIndex);
535
+ setActiveItem(flattenedNodes[parentIndex]);
536
+ focusNode(parentIndex);
537
+ }
538
+ },
539
+ [flattenedNodes, focusNode]
540
+ );
541
+ const handleArrowRight = useCallback(
542
+ (event) => {
543
+ if (menulayout === LAYOUT.HORIZONTAL || keyboardMovements.MOVE_RIGHT !== "RIGHT-ARROW")
544
+ return;
545
+ event.preventDefault();
546
+ if (focusedIndex >= 0 && flattenedNodes[focusedIndex]) {
547
+ const currentItem = flattenedNodes[focusedIndex];
548
+ if (currentItem.children && currentItem.children.length > 0) {
549
+ expandAndFocusChild(currentItem);
550
+ } else if (menulayout === LAYOUT.HORIZONTAL) {
551
+ moveFocusHorizontally(1);
639
552
  }
640
- }, renderMenuItems(children, itemPath)) : isSubmenuOpen && open && __jsx(_ListItems.MenuList, {
641
- iconposition: iconposition,
642
- className: submenuClassName,
643
- style: getMenuLayoutStyles()
644
- // Same hover tracking for anchor-type menus
645
- ,
646
- onMouseEnter: function onMouseEnter() {
647
- return handlePathMouseEnter(itemPath);
648
- },
649
- onMouseLeave: function onMouseLeave(e) {
650
- return handlePathMouseLeave(itemPath, e);
651
- },
652
- onClick: function onClick(event) {
653
- return onActionsclick === null || onActionsclick === void 0 ? void 0 : onActionsclick(node);
553
+ }
554
+ },
555
+ [
556
+ menulayout,
557
+ keyboardMovements,
558
+ focusedIndex,
559
+ flattenedNodes,
560
+ expandAndFocusChild,
561
+ moveFocusHorizontally
562
+ ]
563
+ );
564
+ const handleArrowLeft = useCallback(
565
+ (event) => {
566
+ if (menulayout === LAYOUT.HORIZONTAL || keyboardMovements.MOVE_LEFT !== "LEFT-ARROW") return;
567
+ event.preventDefault();
568
+ if (focusedIndex >= 0 && flattenedNodes[focusedIndex]) {
569
+ const currentItem = flattenedNodes[focusedIndex];
570
+ if (menulayout === LAYOUT.HORIZONTAL) {
571
+ moveFocusHorizontally(-1);
572
+ } else {
573
+ collapseAndFocusParent(currentItem);
654
574
  }
655
- }, renderMenuItems(children, itemPath))));
656
- });
657
- }, [getNodeProperties, menuPosition, hoveredPaths, handlePathMouseEnter, handlePathMouseLeave, hint, handleMenuItemClick, activeItem, linktarget, iconposition, animateitems, menualign, getMenuLayoutStyles, type, open, panelPosition]);
658
-
659
- // Effects
660
- (0, _react.useEffect)(function () {
575
+ }
576
+ },
577
+ [
578
+ menulayout,
579
+ keyboardMovements,
580
+ focusedIndex,
581
+ flattenedNodes,
582
+ moveFocusHorizontally,
583
+ collapseAndFocusParent
584
+ ]
585
+ );
586
+ const handleKeyDown = useCallback(
587
+ (event) => {
588
+ const key = event.key;
589
+ if (key === "Enter" && document.activeElement === buttonRef.current) {
590
+ event.preventDefault();
591
+ toggleMenu();
592
+ return;
593
+ }
594
+ if (!open && key === "Enter") {
595
+ event.preventDefault();
596
+ setOpen(true);
597
+ return;
598
+ }
599
+ if (!open && !["ArrowDown", "ArrowUp", "Enter", " "].includes(key)) {
600
+ return;
601
+ }
602
+ if (flattenedNodes.length === 0 && open) return;
603
+ const keyHandlers = {
604
+ ArrowDown: handleArrowDown,
605
+ ArrowUp: handleArrowUp,
606
+ Enter: handleEnterOrSpace,
607
+ " ": handleEnterOrSpace,
608
+ Escape: handleEscape,
609
+ Tab: closeMenu,
610
+ ArrowRight: handleArrowRight,
611
+ ArrowLeft: handleArrowLeft
612
+ };
613
+ const handler = keyHandlers[key];
614
+ if (handler) {
615
+ handler(event);
616
+ }
617
+ },
618
+ [
619
+ open,
620
+ flattenedNodes.length,
621
+ toggleMenu,
622
+ handleArrowDown,
623
+ handleArrowUp,
624
+ handleEnterOrSpace,
625
+ handleEscape,
626
+ closeMenu,
627
+ handleArrowRight,
628
+ handleArrowLeft
629
+ ]
630
+ );
631
+ const renderMenuItems = useCallback(
632
+ (nodes, pathPrefix = "") => {
633
+ if (!nodes || !Array.isArray(nodes)) return null;
634
+ return nodes.map((node, index) => {
635
+ var _a2;
636
+ const { label, icon, link, hint: hint2, disabled, children: children2 } = getNodeProperties(node);
637
+ const itemPath = pathPrefix ? `${pathPrefix}-${index}` : `${index}`;
638
+ const nodeValueLink = (_a2 = node == null ? void 0 : node.value) == null ? void 0 : _a2.link;
639
+ const isActive = nodeValueLink && typeof nodeValueLink === "string" ? isPathMatchingLink(path, nodeValueLink) : link ? isPathMatchingLink(path, link) : false;
640
+ const [verticalPos2, horizontalPos2] = menuPosition.split(",");
641
+ const isHovered = hoveredPaths.has(itemPath);
642
+ const isSubmenuOpen = node.expanded || isHovered;
643
+ const submenuClassName = buildMenuListClasses(
644
+ iconposition,
645
+ menulayout,
646
+ horizontalPos2,
647
+ panelPosition,
648
+ animateitems,
649
+ menuPosition,
650
+ isHovered
651
+ );
652
+ return /* @__PURE__ */ jsxs(
653
+ Box,
654
+ {
655
+ component: "li",
656
+ className: clsx(
657
+ children2 && children2.length > 0 && "dropdown-submenu",
658
+ "app-menu-item",
659
+ {
660
+ active: isActive,
661
+ hovered: isHovered
662
+ }
663
+ ),
664
+ onMouseEnter: () => handlePathMouseEnter(itemPath),
665
+ onMouseLeave: (e) => handlePathMouseLeave(itemPath, e),
666
+ style: { position: "relative" },
667
+ children: [
668
+ /* @__PURE__ */ jsxs(
669
+ Link,
670
+ {
671
+ title: label,
672
+ className: disabled ? "disabled" : "",
673
+ onClick: (event) => {
674
+ handleMenuItemClick(event, node);
675
+ },
676
+ children: [
677
+ children2 && children2.length > 0 && /* @__PURE__ */ jsx(
678
+ "span",
679
+ {
680
+ className: clsx(
681
+ "pull-right fa caret",
682
+ menuAlignClass[menualign] || "fa-caret-right"
683
+ )
684
+ }
685
+ ),
686
+ icon && /* @__PURE__ */ jsx("i", { className: `app-icon ${icon}` }),
687
+ /* @__PURE__ */ jsx("span", { className: "anchor-caption", children: label })
688
+ ]
689
+ }
690
+ ),
691
+ children2 && children2.length > 0 && (type !== "anchor" ? /* @__PURE__ */ jsx(
692
+ CollapsibleMenu,
693
+ {
694
+ isOpen: isSubmenuOpen,
695
+ verticalPos: verticalPos2,
696
+ className: submenuClassName,
697
+ style: getMenuLayoutStyles(),
698
+ onMouseEnter: () => handlePathMouseEnter(itemPath),
699
+ onMouseLeave: (e) => handlePathMouseLeave(itemPath, e),
700
+ children: renderMenuItems(children2, itemPath)
701
+ }
702
+ ) : isSubmenuOpen && open && /* @__PURE__ */ jsx(
703
+ MenuList,
704
+ {
705
+ iconposition,
706
+ className: submenuClassName,
707
+ style: getMenuLayoutStyles(),
708
+ onMouseEnter: () => handlePathMouseEnter(itemPath),
709
+ onMouseLeave: (e) => handlePathMouseLeave(itemPath, e),
710
+ onClick: (event) => onActionsclick == null ? void 0 : onActionsclick(node),
711
+ children: renderMenuItems(children2, itemPath)
712
+ }
713
+ ))
714
+ ]
715
+ },
716
+ index
717
+ );
718
+ });
719
+ },
720
+ [
721
+ getNodeProperties,
722
+ menuPosition,
723
+ hoveredPaths,
724
+ handlePathMouseEnter,
725
+ handlePathMouseLeave,
726
+ hint,
727
+ handleMenuItemClick,
728
+ activeItem,
729
+ linktarget,
730
+ iconposition,
731
+ animateitems,
732
+ menualign,
733
+ getMenuLayoutStyles,
734
+ type,
735
+ open,
736
+ panelPosition
737
+ ]
738
+ );
739
+ useEffect(() => {
661
740
  if (!open) return;
662
741
  setActiveItem(null);
663
742
  setFocusedIndex(-1);
664
743
  }, [open]);
665
- (0, _react.useEffect)(function () {
666
- if (autoopen === _constants.AUTO_OPEN.ALWAYS) {
744
+ useEffect(() => {
745
+ if (autoopen === AUTO_OPEN.ALWAYS) {
667
746
  setOpen(true);
668
- } else if (autoopen === _constants.AUTO_OPEN.ACTIVE_PAGE) {
669
- var hasActiveItem = filteredDataset.some(function (node) {
670
- return _hasLinkToCurrentPage([node], window.location.pathname);
671
- });
747
+ } else if (autoopen === AUTO_OPEN.ACTIVE_PAGE) {
748
+ const hasActiveItem = filteredDataset.some(
749
+ (node) => hasLinkToCurrentPage([node], window.location.pathname)
750
+ );
672
751
  if (hasActiveItem) {
673
752
  setOpen(true);
674
753
  }
675
754
  }
676
755
  }, [filteredDataset, autoopen]);
677
- var notifiedPathRef = (0, _react.useRef)(null);
678
- (0, _react.useEffect)(function () {
756
+ const notifiedPathRef = useRef(null);
757
+ useEffect(() => {
679
758
  if (!isFromNav || !onNavItemActivate || !filteredDataset || filteredDataset.length === 0) {
680
759
  return;
681
760
  }
682
-
683
- // Check if any menu item is active using the same logic as renderMenuItems
684
- var _checkIfActive = function checkIfActive(nodes) {
761
+ const checkIfActive = (nodes) => {
685
762
  if (!nodes || !Array.isArray(nodes)) return false;
686
- return nodes.some(function (node) {
687
- var _value2;
688
- var _getNodeProperties3 = getNodeProperties(node),
689
- link = _getNodeProperties3.link,
690
- children = _getNodeProperties3.children;
691
- var nodeValueLink = node === null || node === void 0 || (_value2 = node.value) === null || _value2 === void 0 ? void 0 : _value2.link;
692
- var isActive = nodeValueLink && typeof nodeValueLink === "string" ? isPathMatchingLink(path, nodeValueLink) : link ? isPathMatchingLink(path, link) : false;
763
+ return nodes.some((node) => {
764
+ var _a2;
765
+ const { link, children: children2 } = getNodeProperties(node);
766
+ const nodeValueLink = (_a2 = node == null ? void 0 : node.value) == null ? void 0 : _a2.link;
767
+ const isActive = nodeValueLink && typeof nodeValueLink === "string" ? isPathMatchingLink(path, nodeValueLink) : link ? isPathMatchingLink(path, link) : false;
693
768
  if (isActive) return true;
694
- if (children && children.length > 0) {
695
- return _checkIfActive(children);
769
+ if (children2 && children2.length > 0) {
770
+ return checkIfActive(children2);
696
771
  }
697
772
  return false;
698
773
  });
699
774
  };
700
- var hasActiveItem = _checkIfActive(filteredDataset);
701
-
702
- // Notify nav if there's an active item and we haven't notified for this path yet
775
+ const hasActiveItem = checkIfActive(filteredDataset);
703
776
  if (hasActiveItem && notifiedPathRef.current !== path) {
704
777
  onNavItemActivate();
705
778
  notifiedPathRef.current = path;
706
779
  setOpen(true);
707
780
  } else if (!hasActiveItem) {
708
- // Reset when no active item found
709
781
  notifiedPathRef.current = null;
710
782
  }
711
783
  }, [path, filteredDataset, isFromNav, onNavItemActivate, getNodeProperties]);
712
- (0, _react.useEffect)(function () {
713
- // Handle outside click for both "outsideClick" and "always" autoclose modes
714
- if (!open || autoclose === _constants.AUTO_CLOSE.NEVER || autoclose === _constants.AUTO_CLOSE.DISABLED) return;
715
- var handleOutsideClick = function handleOutsideClick(event) {
716
- var _menuRef$current, _buttonRef$current2;
784
+ useEffect(() => {
785
+ if (!open || autoclose === AUTO_CLOSE.NEVER || autoclose === AUTO_CLOSE.DISABLED) return;
786
+ const handleOutsideClick = (event) => {
787
+ var _a2, _b2, _c2;
717
788
  if (!event.target) return;
718
- var clickedInsideMenu = (_menuRef$current = menuRef.current) === null || _menuRef$current === void 0 ? void 0 : _menuRef$current.contains(event.target);
719
- var clickedOnButton = (_buttonRef$current2 = buttonRef.current) === null || _buttonRef$current2 === void 0 ? void 0 : _buttonRef$current2.contains(event.target);
789
+ const clickedInsideMenu = (_a2 = menuRef.current) == null ? void 0 : _a2.contains(event.target);
790
+ const clickedOnButton = (_b2 = buttonRef.current) == null ? void 0 : _b2.contains(event.target);
720
791
  if (!clickedInsideMenu && !clickedOnButton) {
721
- var _buttonRef$current3;
722
792
  setOpen(false);
723
793
  setFocusedIndex(-1);
724
794
  setActiveItem(null);
725
- (_buttonRef$current3 = buttonRef.current) === null || _buttonRef$current3 === void 0 || _buttonRef$current3.focus();
795
+ (_c2 = buttonRef.current) == null ? void 0 : _c2.focus();
726
796
  }
727
797
  };
728
798
  document.addEventListener("mousedown", handleOutsideClick);
729
- return function () {
799
+ return () => {
730
800
  document.removeEventListener("mousedown", handleOutsideClick);
731
801
  };
732
802
  }, [open, autoclose]);
733
- (0, _react.useEffect)(function () {
803
+ useEffect(() => {
734
804
  if (!shortcutkey) return;
735
- var handleShortcutKey = function handleShortcutKey(event) {
736
- var isModifierKey = event.altKey || navigator.platform.indexOf("Mac") !== -1 && event.ctrlKey && event.altKey;
805
+ const handleShortcutKey = (event) => {
806
+ var _a2;
807
+ const isModifierKey = event.altKey || navigator.platform.indexOf("Mac") !== -1 && event.ctrlKey && event.altKey;
737
808
  if (isModifierKey && event.key.toLowerCase() === shortcutkey.toLowerCase()) {
738
- var _buttonRef$current4;
739
809
  event.preventDefault();
740
- setOpen(function (prev) {
741
- return !prev;
742
- });
743
- (_buttonRef$current4 = buttonRef.current) === null || _buttonRef$current4 === void 0 || _buttonRef$current4.focus();
810
+ setOpen((prev) => !prev);
811
+ (_a2 = buttonRef.current) == null ? void 0 : _a2.focus();
744
812
  }
745
813
  };
746
814
  window.addEventListener("keydown", handleShortcutKey);
747
- return function () {
815
+ return () => {
748
816
  window.removeEventListener("keydown", handleShortcutKey);
749
817
  };
750
818
  }, [shortcutkey]);
751
-
752
- // Fallback: run action task once when nodes$ is absent and an active item exists in the dataset
753
- var executedInitialActiveRef = (0, _react.useRef)(false);
754
- (0, _react.useEffect)(function () {
755
- if (nodes$ && typeof nodes$.subscribe === "function") return; // nodes$ flow will handle it
819
+ const executedInitialActiveRef = useRef(false);
820
+ useEffect(() => {
821
+ if (nodes$ && typeof nodes$.subscribe === "function") return;
756
822
  if (executedInitialActiveRef.current) return;
757
823
  if (!transformedDataset || transformedDataset.length === 0) return;
758
- var itemFound = false;
759
- var _getItem = function getItem(nodes) {
824
+ let itemFound = false;
825
+ const getItem = (nodes) => {
760
826
  if (!nodes || !Array.isArray(nodes)) return;
761
- nodes.forEach(function (item) {
762
- var _dataObject2;
827
+ nodes.forEach((item) => {
828
+ var _a2;
763
829
  if (itemFound) return;
764
- if (item !== null && item !== void 0 && item.isactive || item !== null && item !== void 0 && (_dataObject2 = item.dataObject) !== null && _dataObject2 !== void 0 && _dataObject2.isactive) {
830
+ if ((item == null ? void 0 : item.isactive) || ((_a2 = item == null ? void 0 : item.dataObject) == null ? void 0 : _a2.isactive)) {
765
831
  itemFound = true;
766
- if (listener !== null && listener !== void 0 && listener.Widgets && name && onSelect) {
767
- var widget = listener.Widgets[name];
832
+ if ((listener == null ? void 0 : listener.Widgets) && name && onSelect) {
833
+ const widget = listener.Widgets[name];
768
834
  if (widget) {
769
835
  onSelect({}, widget, item);
770
836
  }
771
837
  }
772
- (0, _actionTask.executeActionTaskFromItem)(item, listener);
838
+ executeActionTaskFromItem(item, listener);
773
839
  }
774
- if (item.children && !(0, _lodash.isEmpty)(item.children)) {
775
- _getItem(item.children);
840
+ if (item.children && !isEmpty(item.children)) {
841
+ getItem(item.children);
776
842
  }
777
843
  });
778
844
  };
779
- _getItem(transformedDataset);
845
+ getItem(transformedDataset);
780
846
  if (itemFound) {
781
847
  executedInitialActiveRef.current = true;
782
848
  }
783
849
  }, []);
784
- (0, _react.useEffect)(function () {
850
+ useEffect(() => {
785
851
  if (!nodes$ || typeof nodes$.subscribe !== "function") return;
786
- var datasetSubscription = nodes$.subscribe(function () {
852
+ const datasetSubscription = nodes$.subscribe(() => {
787
853
  if (!dataset) return;
788
- var itemFound = false;
789
- var _getItem2 = function getItem(nodes) {
854
+ let itemFound = false;
855
+ const getItem = (nodes) => {
790
856
  if (!nodes || !Array.isArray(nodes)) return;
791
- nodes.forEach(function (item) {
857
+ nodes.forEach((item) => {
792
858
  if (itemFound) return;
793
859
  if (item.isactive) {
794
860
  itemFound = true;
795
- if (listener !== null && listener !== void 0 && listener.Widgets && name && onSelect) {
796
- var widget = listener.Widgets[name];
861
+ if ((listener == null ? void 0 : listener.Widgets) && name && onSelect) {
862
+ const widget = listener.Widgets[name];
797
863
  if (widget) {
798
864
  onSelect({}, widget, item);
799
865
  }
800
866
  }
801
867
  return false;
802
868
  }
803
- if (item.children && !(0, _lodash.isEmpty)(item.children)) {
804
- _getItem2(item.children);
869
+ if (item.children && !isEmpty(item.children)) {
870
+ getItem(item.children);
805
871
  }
806
872
  });
807
873
  };
808
- _getItem2(dataset);
874
+ getItem(dataset);
809
875
  });
810
- return function () {
876
+ return () => {
811
877
  if (datasetSubscription && typeof datasetSubscription.unsubscribe === "function") {
812
878
  datasetSubscription.unsubscribe();
813
879
  }
814
880
  };
815
881
  }, [dataset, nodes$, name, listener, onSelect]);
816
-
817
- // ============ Exposed Methods Implementation ============
818
- // 1. onShow - Lifecycle callback triggered when menu opens
819
- var onShowCallback = (0, _react.useCallback)(function () {
820
- // Similar to Angular's @HostListener('onShown') - lines 121-129
821
- // Focus first item if opened via keyboard
882
+ const onShowCallback = useCallback(() => {
822
883
  if (open && flattenedNodes.length > 0 && focusedIndex === 0) {
823
- setTimeout(function () {
824
- var _flattenedNodes$;
825
- (_flattenedNodes$ = flattenedNodes[0]) === null || _flattenedNodes$ === void 0 || (_flattenedNodes$ = _flattenedNodes$.nodeRef) === null || _flattenedNodes$ === void 0 || (_flattenedNodes$ = _flattenedNodes$.current) === null || _flattenedNodes$ === void 0 || _flattenedNodes$.focus();
884
+ setTimeout(() => {
885
+ var _a2, _b2, _c2;
886
+ (_c2 = (_b2 = (_a2 = flattenedNodes[0]) == null ? void 0 : _a2.nodeRef) == null ? void 0 : _b2.current) == null ? void 0 : _c2.focus();
826
887
  }, 0);
827
888
  }
828
-
829
- // add the open class to the menu
830
889
  setOpen(true);
831
890
  }, [open, flattenedNodes, focusedIndex, props, listener, name]);
832
-
833
- // 2. onHide - Lifecycle callback triggered when menu closes
834
- var onHideCallback = (0, _react.useCallback)(function () {
835
- // Similar to Angular's @HostListener('onHidden') - lines 130-137
836
- // Reset menu state
891
+ const onHideCallback = useCallback(() => {
837
892
  setFocusedIndex(-1);
838
893
  setActiveItem(null);
839
-
840
- // Reset menuposition to original value
841
894
  setMenuPosition(initialMenuPosition);
842
-
843
- // remove the open class from the menu
844
895
  setOpen(false);
845
896
  }, [initialMenuPosition, props, listener, name]);
846
-
847
- // 3. resetNodes - Method to reset/rebuild menu items
848
- var resetNodesMethod = (0, _react.useCallback)(function () {
849
- // Similar to Angular's resetNodes() - lines 227-233
850
- // Call the parent resetNavNodes if available
897
+ const resetNodesMethod = useCallback(() => {
851
898
  if (resetNavNodes) {
852
899
  resetNavNodes();
853
900
  }
854
-
855
- // Auto-open logic from Angular implementation
856
- if (autoopen === _constants.AUTO_OPEN.ACTIVE_PAGE && _hasLinkToCurrentPage(transformedDataset, path)) {
901
+ if (autoopen === AUTO_OPEN.ACTIVE_PAGE && hasLinkToCurrentPage(transformedDataset, path)) {
857
902
  setOpen(true);
858
- } else if (autoopen === _constants.AUTO_OPEN.ALWAYS) {
903
+ } else if (autoopen === AUTO_OPEN.ALWAYS) {
859
904
  setOpen(true);
860
905
  }
861
906
  }, [resetNavNodes, autoopen, transformedDataset, path]);
862
-
863
- // 4. setMenuPosition - Method to programmatically change menu position
864
- var setMenuPositionMethod = (0, _react.useCallback)(function (position) {
865
- // Similar to Angular's setMenuPosition() - lines 261-287
866
- var validPositions = [_constants.POSITION.DOWN_RIGHT, _constants.POSITION.DOWN_LEFT, _constants.POSITION.UP_RIGHT, _constants.POSITION.UP_LEFT, _constants.POSITION.INLINE];
907
+ const setMenuPositionMethod = useCallback((position) => {
908
+ const validPositions = [
909
+ POSITION.DOWN_RIGHT,
910
+ POSITION.DOWN_LEFT,
911
+ POSITION.UP_RIGHT,
912
+ POSITION.UP_LEFT,
913
+ POSITION.INLINE
914
+ ];
867
915
  if (validPositions.includes(position)) {
868
916
  setMenuPosition(position);
869
917
  } else {
870
- console.warn("Invalid menu position: ".concat(position, ". Valid positions are: ").concat(validPositions.join(", ")));
918
+ console.warn(
919
+ `Invalid menu position: ${position}. Valid positions are: ${validPositions.join(", ")}`
920
+ );
871
921
  }
872
922
  }, []);
873
-
874
- // 5. onKeyDown - Expose keyboard handler
875
- var onKeyDownMethod = (0, _react.useCallback)(function (event, eventAction) {
876
- // Similar to Angular's onKeyDown($event, eventAction) - lines 145-173
877
- // This matches Angular's signature: onKeyDown($event, eventAction)
878
- if (eventAction) {
879
- // Handle specific event action if provided
880
- }
881
- handleKeyDown(event);
882
- }, [handleKeyDown]);
883
-
884
- // 6. onMenuItemSelect - Expose menu item select handler
885
- var onMenuItemSelectMethod = (0, _react.useCallback)(function (event, item) {
886
- var _listener$Widgets;
887
- // Similar to Angular's onMenuItemSelect(args) - lines 289-293
888
- // This matches Angular's signature: onMenuItemSelect({ $event, $item })
889
- if (onSelect && listener !== null && listener !== void 0 && (_listener$Widgets = listener.Widgets) !== null && _listener$Widgets !== void 0 && _listener$Widgets[name]) {
890
- onSelect(event, listener.Widgets[name], item);
891
- }
892
- }, [onSelect, listener, name]);
893
-
894
- // ============ Expose Methods to Widget Proxy ============
895
- // This makes methods accessible via Page.Widgets.menu4.methodName
896
- (0, _react.useEffect)(function () {
897
- if (listener !== null && listener !== void 0 && listener.onChange && name) {
898
- Object.defineProperty(onShowCallback, "name", {
899
- value: "onShow",
900
- writable: false
901
- });
902
- Object.defineProperty(onHideCallback, "name", {
903
- value: "onHide",
904
- writable: false
905
- });
906
- Object.defineProperty(onKeyDownMethod, "name", {
907
- value: "onKeyDown",
908
- writable: false
909
- });
910
- Object.defineProperty(resetNodesMethod, "name", {
911
- value: "resetNodes",
912
- writable: false
913
- });
923
+ const onKeyDownMethod = useCallback(
924
+ (event, eventAction) => {
925
+ if (eventAction) {
926
+ }
927
+ handleKeyDown(event);
928
+ },
929
+ [handleKeyDown]
930
+ );
931
+ const onMenuItemSelectMethod = useCallback(
932
+ (event, item) => {
933
+ var _a2;
934
+ if (onSelect && ((_a2 = listener == null ? void 0 : listener.Widgets) == null ? void 0 : _a2[name])) {
935
+ onSelect(event, listener.Widgets[name], item);
936
+ }
937
+ },
938
+ [onSelect, listener, name]
939
+ );
940
+ useEffect(() => {
941
+ if ((listener == null ? void 0 : listener.onChange) && name) {
942
+ Object.defineProperty(onShowCallback, "name", { value: "onShow", writable: false });
943
+ Object.defineProperty(onHideCallback, "name", { value: "onHide", writable: false });
944
+ Object.defineProperty(onKeyDownMethod, "name", { value: "onKeyDown", writable: false });
945
+ Object.defineProperty(resetNodesMethod, "name", { value: "resetNodes", writable: false });
914
946
  Object.defineProperty(setMenuPositionMethod, "name", {
915
947
  value: "setMenuPosition",
916
948
  writable: false
@@ -929,103 +961,136 @@ var WmMenu = exports.WmMenu = /*#__PURE__*/(0, _react.memo)(function (props) {
929
961
  });
930
962
  }
931
963
  }, []);
932
-
933
- // Memoized class names and styles
934
- var _menuPosition$split3 = menuPosition.split(","),
935
- _menuPosition$split4 = (0, _slicedToArray2["default"])(_menuPosition$split3, 2),
936
- verticalPos = _menuPosition$split4[0],
937
- horizontalPos = _menuPosition$split4[1];
938
- var mainMenuClassName = (0, _react.useMemo)(function () {
939
- return (0, _ListItems.buildMenuListClasses)(iconposition, menulayout, horizontalPos, panelPosition, animateitems, menuPosition);
940
- }, [iconposition, menulayout, horizontalPos, panelPosition, animateitems, menuPosition]);
941
- var hoverEventHandlers = showonhover ? {
964
+ const [verticalPos, horizontalPos] = menuPosition.split(",");
965
+ const mainMenuClassName = useMemo(
966
+ () => buildMenuListClasses(
967
+ iconposition,
968
+ menulayout,
969
+ horizontalPos,
970
+ panelPosition,
971
+ animateitems,
972
+ menuPosition
973
+ ),
974
+ [iconposition, menulayout, horizontalPos, panelPosition, animateitems, menuPosition]
975
+ );
976
+ const hoverEventHandlers = showonhover ? {
942
977
  onMouseEnter: handleContainerMouseEnter,
943
978
  onMouseLeave: handleContainerMouseLeave
944
979
  } : {};
945
-
946
- // Render
947
- return __jsx("div", (0, _extends2["default"])({
948
- caption: caption,
949
- ref: menuRef,
950
- className: (0, _clsx["default"])("dropdown", "app-menu", {
951
- open: open
952
- }, className)
953
- }, hoverEventHandlers, {
954
- onKeyDown: handleKeyDown,
955
- role: "menu",
956
- "aria-label": arialabel || "Menu",
957
- "aria-expanded": open,
958
- type: type,
959
- name: name
960
- }), __jsx(_Tooltip["default"], {
961
- title: hint || "",
962
- enterDelay: _constants.TOOLTIP_ENTER_DELAY,
963
- disableHoverListener: !hint
964
- }, type === "anchor" ? __jsx("a", (0, _extends2["default"])({
965
- className: (0, _clsx["default"])("dropdown-toggle app-anchor", isNavItemActive && "active"),
966
- "icon-position": "left",
967
- role: "button",
968
- onClick: handleMenuClick,
969
- "aria-label": arialabel || "Menu",
970
- "aria-expanded": open,
971
- "aria-haspopup": "true",
972
- accessKey: shortcutkey,
973
- tabIndex: props.tabindex,
974
- style: {
975
- width: width !== undefined ? typeof width === "number" ? "".concat(width, "px") : width : undefined,
976
- height: height !== undefined ? typeof height === "number" ? "".concat(height, "px") : height : undefined,
977
- textAlign: menualign
978
- }
979
- }, (0, _attr.removeInvalidAttributes)(restProps)), iconclass && __jsx("i", {
980
- className: (0, _clsx["default"])("app-icon", iconclass),
981
- "aria-hidden": "true"
982
- }), __jsx("span", {
983
- className: "sr-only"
984
- }, "".concat(caption, " ").concat(listener === null || listener === void 0 || (_listener$appLocale = listener.appLocale) === null || _listener$appLocale === void 0 ? void 0 : _listener$appLocale.LABEL_ICON)), __jsx("span", {
985
- className: "anchor-caption"
986
- }, caption || ""), __jsx("span", {
987
- className: (0, _clsx["default"])("pull-right caret fa", menuPosition !== null && menuPosition !== void 0 && menuPosition.startsWith("up") ? _constants.CARET_CLS.UP : _constants.CARET_CLS.DOWN)
988
- })) : __jsx(_Button["default"], (0, _extends2["default"])({
989
- className: (0, _clsx["default"])("btn dropdown-toggle", "icon-position-".concat(iconposition), "app-button", menuclass, "menu-layout-".concat(menulayout), "menu-align-".concat(menualign), open ? "open" : "", menuPosition !== null && menuPosition !== void 0 && menuPosition.startsWith("up") ? "dropup" : "", menuPosition === _constants.POSITION.INLINE ? "dropinline-menu" : ""),
990
- ref: buttonRef,
991
- onClick: handleMenuClick,
992
- "aria-haspopup": "true",
993
- "aria-expanded": open,
994
- "aria-label": arialabel || "Menu",
995
- accessKey: shortcutkey,
996
- tabIndex: props.tabindex,
997
- style: _objectSpread(_objectSpread({
998
- width: width !== undefined ? typeof width === "number" ? "".concat(width, "px") : width : undefined,
999
- height: height !== undefined ? typeof height === "number" ? "".concat(height, "px") : height : undefined
1000
- }, buttonStyles), menuContainerStyles)
1001
- }, (0, _attr.removeInvalidAttributes)(restProps)), iconclass && __jsx("i", {
1002
- className: (0, _clsx["default"])("app-icon", iconclass),
1003
- "aria-hidden": "true"
1004
- }), __jsx("span", {
1005
- className: "btn-caption"
1006
- }, caption), __jsx("span", {
1007
- className: (0, _clsx["default"])("pull-right caret fa", menuPosition !== null && menuPosition !== void 0 && menuPosition.startsWith("up") ? _constants.CARET_CLS.UP : _constants.CARET_CLS.DOWN)
1008
- }))), type !== "anchor" ? __jsx(_ListItems.CollapsibleMenu, (0, _extends2["default"])({
1009
- isOpen: open,
1010
- verticalPos: verticalPos,
1011
- className: mainMenuClassName,
1012
- style: getMenuLayoutStyles()
1013
- }, hoverEventHandlers), renderMenuItems(nodesWithRefs)) : open && __jsx(_ListItems.MenuList, (0, _extends2["default"])({
1014
- iconposition: iconposition,
1015
- className: mainMenuClassName,
1016
- style: getMenuLayoutStyles()
1017
- }, hoverEventHandlers), renderMenuItems(nodesWithRefs)));
980
+ return /* @__PURE__ */ jsxs(
981
+ "div",
982
+ __spreadProps(__spreadValues(__spreadProps(__spreadValues({
983
+ caption,
984
+ ref: menuRef,
985
+ className: clsx("dropdown", "app-menu", { open }, className)
986
+ }, hoverEventHandlers), {
987
+ onKeyDown: handleKeyDown,
988
+ role: "menu",
989
+ "aria-label": arialabel || "Menu",
990
+ "aria-expanded": open
991
+ }), { type, name }), {
992
+ children: [
993
+ /* @__PURE__ */ jsx(Tooltip, { title: hint || "", enterDelay: TOOLTIP_ENTER_DELAY, disableHoverListener: !hint, children: type === "anchor" ? /* @__PURE__ */ jsxs(
994
+ "a",
995
+ __spreadProps(__spreadValues({
996
+ className: clsx("dropdown-toggle app-anchor", isNavItemActive && "active"),
997
+ "icon-position": "left",
998
+ role: "button",
999
+ onClick: handleMenuClick,
1000
+ "aria-label": arialabel || "Menu",
1001
+ "aria-expanded": open,
1002
+ "aria-haspopup": "true",
1003
+ accessKey: shortcutkey,
1004
+ tabIndex: props.tabindex,
1005
+ style: {
1006
+ width: width !== void 0 ? typeof width === "number" ? `${width}px` : width : void 0,
1007
+ height: height !== void 0 ? typeof height === "number" ? `${height}px` : height : void 0,
1008
+ textAlign: menualign
1009
+ }
1010
+ }, removeInvalidAttributes(restProps)), {
1011
+ children: [
1012
+ iconclass && /* @__PURE__ */ jsx("i", { className: clsx("app-icon", iconclass), "aria-hidden": "true" }),
1013
+ /* @__PURE__ */ jsx("span", { className: "sr-only", children: `${caption} ${(_c = listener == null ? void 0 : listener.appLocale) == null ? void 0 : _c.LABEL_ICON}` }),
1014
+ /* @__PURE__ */ jsx("span", { className: "anchor-caption", children: caption || "" }),
1015
+ /* @__PURE__ */ jsx(
1016
+ "span",
1017
+ {
1018
+ className: clsx(
1019
+ "pull-right caret fa",
1020
+ (menuPosition == null ? void 0 : menuPosition.startsWith("up")) ? CARET_CLS.UP : CARET_CLS.DOWN
1021
+ )
1022
+ }
1023
+ )
1024
+ ]
1025
+ })
1026
+ ) : /* @__PURE__ */ jsxs(
1027
+ Button,
1028
+ __spreadProps(__spreadValues({
1029
+ className: clsx(
1030
+ "btn dropdown-toggle",
1031
+ `icon-position-${iconposition}`,
1032
+ "app-button",
1033
+ menuclass,
1034
+ `menu-layout-${menulayout}`,
1035
+ `menu-align-${menualign}`,
1036
+ open ? "open" : "",
1037
+ (menuPosition == null ? void 0 : menuPosition.startsWith("up")) ? "dropup" : "",
1038
+ menuPosition === POSITION.INLINE ? "dropinline-menu" : ""
1039
+ ),
1040
+ ref: buttonRef,
1041
+ onClick: handleMenuClick,
1042
+ "aria-haspopup": "true",
1043
+ "aria-expanded": open,
1044
+ "aria-label": arialabel || "Menu",
1045
+ accessKey: shortcutkey,
1046
+ tabIndex: props.tabindex,
1047
+ style: __spreadValues(__spreadValues({
1048
+ width: width !== void 0 ? typeof width === "number" ? `${width}px` : width : void 0,
1049
+ height: height !== void 0 ? typeof height === "number" ? `${height}px` : height : void 0
1050
+ }, buttonStyles), menuContainerStyles)
1051
+ }, removeInvalidAttributes(restProps)), {
1052
+ children: [
1053
+ iconclass && /* @__PURE__ */ jsx("i", { className: clsx("app-icon", iconclass), "aria-hidden": "true" }),
1054
+ /* @__PURE__ */ jsx("span", { className: "btn-caption", children: caption }),
1055
+ /* @__PURE__ */ jsx(
1056
+ "span",
1057
+ {
1058
+ className: clsx(
1059
+ "pull-right caret fa",
1060
+ (menuPosition == null ? void 0 : menuPosition.startsWith("up")) ? CARET_CLS.UP : CARET_CLS.DOWN
1061
+ )
1062
+ }
1063
+ )
1064
+ ]
1065
+ })
1066
+ ) }),
1067
+ type !== "anchor" ? /* @__PURE__ */ jsx(
1068
+ CollapsibleMenu,
1069
+ __spreadProps(__spreadValues({
1070
+ isOpen: open,
1071
+ verticalPos,
1072
+ className: mainMenuClassName,
1073
+ style: getMenuLayoutStyles()
1074
+ }, hoverEventHandlers), {
1075
+ children: renderMenuItems(nodesWithRefs)
1076
+ })
1077
+ ) : open && /* @__PURE__ */ jsx(
1078
+ MenuList,
1079
+ __spreadProps(__spreadValues({
1080
+ iconposition,
1081
+ className: mainMenuClassName,
1082
+ style: getMenuLayoutStyles()
1083
+ }, hoverEventHandlers), {
1084
+ children: renderMenuItems(nodesWithRefs)
1085
+ })
1086
+ )
1087
+ ]
1088
+ })
1089
+ );
1018
1090
  });
1019
1091
  WmMenu.displayName = "WmMenu";
1020
-
1021
- /**
1022
- * The WmMenu component renders a navigation menu with support for hierarchical items,
1023
- * dataset binding, role-based filtering, and configurable layout/position.
1024
- *
1025
- * - [Playground](https://react-components.wavemaker.ai/?path=/story/navigation-menu--showcase)
1026
- *
1027
- * - [Docs](https://react-components.wavemaker.ai/?path=/story/navigation-menu--docs)
1028
- *
1029
- * @param props - {@link WmMenuExtendedProps}
1030
- */
1031
- var _default = exports["default"] = (0, _withBaseWrapper.withBaseWrapper)(WmMenu);
1092
+ var menu_default = withBaseWrapper(WmMenu);
1093
+ export {
1094
+ WmMenu,
1095
+ menu_default as default
1096
+ };