@wavemaker-ai/react-runtime 1.0.0-rc.312 → 1.0.0-rc.317

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 (593) 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.d.ts +1 -0
  6. package/actions/navigation-action.js +275 -345
  7. package/actions/notification-action.js +121 -149
  8. package/actions/timer-action.js +95 -151
  9. package/actions/toast-provider.js +62 -76
  10. package/actions/toast.js +95 -91
  11. package/actions/toast.service.js +59 -79
  12. package/actions/types/index.js +6 -9
  13. package/components/advanced/carousel/index.js +358 -366
  14. package/components/advanced/carousel/props.js +0 -5
  15. package/components/advanced/carousel/template.js +102 -80
  16. package/components/advanced/login/index.js +227 -285
  17. package/components/advanced/login/props.js +0 -5
  18. package/components/advanced/marquee/index.js +169 -163
  19. package/components/advanced/marquee/props.js +0 -5
  20. package/components/auth/RoleAuthGuard.d.ts +6 -0
  21. package/components/auth/RoleAuthGuard.js +65 -0
  22. package/components/basic/anchor/index.js +207 -187
  23. package/components/basic/anchor/props.js +0 -5
  24. package/components/basic/audio/index.js +110 -72
  25. package/components/basic/audio/props.js +0 -5
  26. package/components/basic/html/index.js +163 -203
  27. package/components/basic/html/props.js +0 -5
  28. package/components/basic/html/utils.js +30 -28
  29. package/components/basic/icon/index.js +98 -84
  30. package/components/basic/icon/props.js +0 -5
  31. package/components/basic/iframe/iframe.utils.js +7 -16
  32. package/components/basic/iframe/index.js +97 -103
  33. package/components/basic/iframe/props.js +0 -5
  34. package/components/basic/label/index.js +156 -134
  35. package/components/basic/label/props.js +0 -5
  36. package/components/basic/message/index.js +129 -113
  37. package/components/basic/message/props.js +0 -5
  38. package/components/basic/picture/index.js +156 -127
  39. package/components/basic/picture/props.js +0 -5
  40. package/components/basic/progress-bar/index.js +240 -176
  41. package/components/basic/progress-bar/props.js +5 -31
  42. package/components/basic/progress-circle/index.js +166 -183
  43. package/components/basic/progress-circle/props.js +14 -34
  44. package/components/basic/richtexteditor/index.js +430 -396
  45. package/components/basic/richtexteditor/props.js +0 -5
  46. package/components/basic/search/index.js +813 -931
  47. package/components/basic/search/props.js +0 -5
  48. package/components/basic/search/providers.js +233 -380
  49. package/components/basic/spinner/index.js +210 -200
  50. package/components/basic/spinner/props.js +4 -22
  51. package/components/basic/tile/index.js +73 -81
  52. package/components/basic/tile/props.js +0 -5
  53. package/components/basic/tree/Components/TreeNodeComponent.d.ts +1 -1
  54. package/components/basic/tree/Components/TreeNodeComponent.js +244 -170
  55. package/components/basic/tree/hooks/useTreePartialNodeApi.js +143 -135
  56. package/components/basic/tree/hooks/useTreePersistedState.d.ts +3 -0
  57. package/components/basic/tree/hooks/useTreePersistedState.js +38 -0
  58. package/components/basic/tree/index.d.ts +1 -0
  59. package/components/basic/tree/index.js +453 -454
  60. package/components/basic/tree/props.d.ts +18 -1
  61. package/components/basic/tree/props.js +0 -5
  62. package/components/basic/tree/utils.d.ts +16 -1
  63. package/components/basic/tree/utils.js +240 -185
  64. package/components/basic/video/index.js +161 -107
  65. package/components/basic/video/props.js +0 -5
  66. package/components/chart/index.js +42 -50
  67. package/components/chart/props.js +31 -37
  68. package/components/chart/src/ChartRenderer.js +172 -154
  69. package/components/chart/src/chart.js +391 -213
  70. package/components/chart/src/chartStyles.generated.js +6 -14
  71. package/components/chart/src/chartUtils.js +228 -272
  72. package/components/chart/src/constants.d.ts +13 -0
  73. package/components/chart/src/constants.js +316 -90
  74. package/components/chart/src/d3Setup.js +11 -30
  75. package/components/chart/src/dataUtils.js +363 -447
  76. package/components/chart/src/formatUtils.js +47 -38
  77. package/components/chart/src/index.js +11 -19
  78. package/components/chart/src/nvd3Source.generated.js +5 -13
  79. package/components/chart/src/pieDonutResponsiveLayout.d.ts +5 -0
  80. package/components/chart/src/pieDonutResponsiveLayout.js +76 -96
  81. package/components/chart/src/types.js +0 -5
  82. package/components/common/AppSpinner.js +17 -33
  83. package/components/common/app-spinner.js +11 -22
  84. package/components/common/customTemplate/index.d.ts +3 -0
  85. package/components/common/customTemplate/index.js +6 -0
  86. package/components/common/customTemplate/props.d.ts +20 -0
  87. package/components/common/customTemplate/props.js +0 -0
  88. package/components/common/customTemplate/template.d.ts +3 -0
  89. package/components/common/customTemplate/template.js +27 -0
  90. package/components/common/customTemplate/useCustomTemplate.d.ts +8 -0
  91. package/components/common/customTemplate/useCustomTemplate.js +17 -0
  92. package/components/common/customTemplate/utils.d.ts +6 -0
  93. package/components/common/customTemplate/utils.js +12 -0
  94. package/components/common/index.js +4 -12
  95. package/components/constants.js +81 -77
  96. package/components/container/accordion/accordion-pane/index.js +105 -118
  97. package/components/container/accordion/accordion-pane/props.js +5 -21
  98. package/components/container/accordion/index.js +225 -243
  99. package/components/container/accordion/props.js +5 -16
  100. package/components/container/index.js +210 -155
  101. package/components/container/layout-grid/grid-column/index.js +69 -43
  102. package/components/container/layout-grid/grid-column/props.js +0 -5
  103. package/components/container/layout-grid/grid-row/index.js +12 -29
  104. package/components/container/layout-grid/grid-row/props.js +0 -5
  105. package/components/container/layout-grid/index.js +53 -38
  106. package/components/container/layout-grid/props.js +0 -5
  107. package/components/container/linear-layout/index.js +56 -60
  108. package/components/container/linear-layout/linear-layout-item/index.js +43 -47
  109. package/components/container/linear-layout/linear-layout-item/props.js +0 -5
  110. package/components/container/linear-layout/props.js +0 -5
  111. package/components/container/panel/components/panel-content/index.js +7 -16
  112. package/components/container/panel/components/panel-header/index.js +166 -146
  113. package/components/container/panel/components/panel-header/props.js +0 -5
  114. package/components/container/panel/hooks.js +76 -102
  115. package/components/container/panel/index.js +289 -252
  116. package/components/container/panel/props.js +0 -5
  117. package/components/container/props.js +0 -5
  118. package/components/container/repeat-template/index.js +65 -44
  119. package/components/container/repeat-template/props.js +0 -5
  120. package/components/container/tabs/index.js +517 -526
  121. package/components/container/tabs/props.js +5 -28
  122. package/components/container/tabs/tab-pane/index.js +105 -100
  123. package/components/container/tabs/tab-pane/props.js +0 -5
  124. package/components/container/tabs/utils.js +30 -35
  125. package/components/container/wizard/WizardContext.js +9 -11
  126. package/components/container/wizard/components/StepComponents.js +76 -99
  127. package/components/container/wizard/components/WizardStep.js +107 -85
  128. package/components/container/wizard/index.js +791 -921
  129. package/components/container/wizard/props.js +0 -5
  130. package/components/container/wizard/utils.js +97 -131
  131. package/components/container/wizard/wizard-action/index.js +41 -81
  132. package/components/container/wizard/wizard-step/index.js +140 -120
  133. package/components/data/card/card-actions/index.js +13 -31
  134. package/components/data/card/card-content/index.js +27 -36
  135. package/components/data/card/card-footer/index.js +13 -31
  136. package/components/data/card/index.js +192 -199
  137. package/components/data/card/props.js +0 -5
  138. package/components/data/form/base-form/constant.js +5 -8
  139. package/components/data/form/base-form/hooks/index.js +26 -77
  140. package/components/data/form/base-form/hooks/useFormDataSync.js +106 -212
  141. package/components/data/form/base-form/hooks/useFormOperations.js +109 -161
  142. package/components/data/form/base-form/hooks/useFormSubmission.js +220 -280
  143. package/components/data/form/base-form/hooks/useFormValidation.js +119 -168
  144. package/components/data/form/base-form/hooks/useParentFormRelationship.js +67 -103
  145. package/components/data/form/base-form/index.js +534 -647
  146. package/components/data/form/base-form/props.js +74 -151
  147. package/components/data/form/base-form/utils.js +210 -323
  148. package/components/data/form/dynamic-fields/constant.js +43 -53
  149. package/components/data/form/dynamic-fields/index.js +135 -144
  150. package/components/data/form/dynamic-fields/props.js +0 -5
  151. package/components/data/form/dynamic-fields/utils.js +99 -158
  152. package/components/data/form/form-action/index.js +107 -85
  153. package/components/data/form/form-body/index.js +52 -26
  154. package/components/data/form/form-context.js +43 -59
  155. package/components/data/form/form-controller/hooks/index.js +43 -57
  156. package/components/data/form/form-controller/props.js +5 -8
  157. package/components/data/form/form-controller/utils.js +54 -49
  158. package/components/data/form/form-controller/validation-contrustor.js +203 -426
  159. package/components/data/form/form-controller/withFormController.js +320 -274
  160. package/components/data/form/form-dynamic-section/index.js +47 -41
  161. package/components/data/form/form-dynamic-section/props.js +0 -5
  162. package/components/data/form/form-field/base-field.js +97 -109
  163. package/components/data/form/form-field/index.js +91 -82
  164. package/components/data/form/form-field/props.js +0 -5
  165. package/components/data/form/form-footer/index.js +52 -25
  166. package/components/data/form/form-header/index.js +61 -58
  167. package/components/data/form/index.js +95 -74
  168. package/components/data/form/props.js +0 -5
  169. package/components/data/list/components/GroupHeader.js +34 -33
  170. package/components/data/list/components/GroupedListItems.js +108 -104
  171. package/components/data/list/components/ListContainer.js +22 -27
  172. package/components/data/list/components/ListDND.js +193 -185
  173. package/components/data/list/components/ListHeader.js +32 -49
  174. package/components/data/list/components/ListItem.js +153 -146
  175. package/components/data/list/components/ListItemWithTemplate.js +87 -105
  176. package/components/data/list/components/ListItems.js +180 -194
  177. package/components/data/list/components/ListPagination.js +127 -153
  178. package/components/data/list/components/LoadMoreButton.js +25 -33
  179. package/components/data/list/components/NoDataMessage.js +9 -22
  180. package/components/data/list/components/StandardListItems.js +79 -85
  181. package/components/data/list/components/index.js +31 -119
  182. package/components/data/list/components/props.js +0 -5
  183. package/components/data/list/hooks/index.js +22 -75
  184. package/components/data/list/hooks/props.js +0 -5
  185. package/components/data/list/hooks/useCurrentPageItems.js +20 -38
  186. package/components/data/list/hooks/useGroupedData.js +19 -33
  187. package/components/data/list/hooks/useListData.js +17 -47
  188. package/components/data/list/hooks/useListEffects.js +168 -237
  189. package/components/data/list/hooks/useListEventHandlers.js +301 -285
  190. package/components/data/list/hooks/useListPagination.js +90 -136
  191. package/components/data/list/hooks/useListState.js +49 -91
  192. package/components/data/list/hooks/useListStateManager.js +104 -159
  193. package/components/data/list/hooks/usePaginatedGroupedData.js +74 -110
  194. package/components/data/list/index.d.ts +1 -0
  195. package/components/data/list/index.js +579 -621
  196. package/components/data/list/props.d.ts +4 -0
  197. package/components/data/list/props.js +0 -5
  198. package/components/data/list/templates/media-template.js +29 -50
  199. package/components/data/list/utils/constants.js +20 -32
  200. package/components/data/list/utils/list-helpers.d.ts +2 -1
  201. package/components/data/list/utils/list-helpers.js +71 -115
  202. package/components/data/list/utils/list-widget-methods.js +56 -76
  203. package/components/data/list/utils/widget-instance-utils.js +20 -57
  204. package/components/data/live-filter/index.js +219 -271
  205. package/components/data/live-filter/props.js +5 -12
  206. package/components/data/live-form/index.js +68 -91
  207. package/components/data/live-form/props.js +5 -12
  208. package/components/data/pagination/components/BasicPagination.js +124 -104
  209. package/components/data/pagination/components/ClassicPagination.js +167 -190
  210. package/components/data/pagination/components/InlinePagination.js +97 -98
  211. package/components/data/pagination/components/LoadingComponent.js +17 -30
  212. package/components/data/pagination/components/PageSizeSelector.js +176 -169
  213. package/components/data/pagination/components/PagerNavigation.js +84 -105
  214. package/components/data/pagination/components/TotalRecords.js +48 -47
  215. package/components/data/pagination/components/index.js +14 -47
  216. package/components/data/pagination/components/props.js +0 -5
  217. package/components/data/pagination/hooks/index.js +6 -19
  218. package/components/data/pagination/hooks/props.js +0 -5
  219. package/components/data/pagination/hooks/useNavigationSize.js +12 -21
  220. package/components/data/pagination/hooks/usePagination.js +701 -905
  221. package/components/data/pagination/index.js +336 -389
  222. package/components/data/table/components/AddNewRow.js +122 -154
  223. package/components/data/table/components/EditableCell.js +68 -75
  224. package/components/data/table/components/FieldValidationError.js +19 -20
  225. package/components/data/table/components/RowCells.js +97 -80
  226. package/components/data/table/components/RowExpansionButton.js +43 -39
  227. package/components/data/table/components/SummaryCell.js +54 -88
  228. package/components/data/table/components/SummaryRow.js +45 -52
  229. package/components/data/table/components/SummaryRowFooter.js +35 -42
  230. package/components/data/table/components/TableBody.js +222 -218
  231. package/components/data/table/components/TableDataRow.js +113 -106
  232. package/components/data/table/components/TableFilters.js +391 -390
  233. package/components/data/table/components/TableFooterActions.js +25 -32
  234. package/components/data/table/components/TableHeader.js +460 -435
  235. package/components/data/table/components/TablePanelHeading.js +157 -181
  236. package/components/data/table/components/index.js +27 -95
  237. package/components/data/table/hooks/index.js +21 -230
  238. package/components/data/table/hooks/use-edited-rows.js +59 -94
  239. package/components/data/table/hooks/useCellState.js +58 -83
  240. package/components/data/table/hooks/useCustomExpressionColumns.js +65 -86
  241. package/components/data/table/hooks/useDynamicColumns.js +59 -92
  242. package/components/data/table/hooks/useEditingState.js +30 -41
  243. package/components/data/table/hooks/useFormWidget.js +163 -172
  244. package/components/data/table/hooks/usePaginationState.js +67 -77
  245. package/components/data/table/hooks/usePanelStructure.js +47 -41
  246. package/components/data/table/hooks/useResponsiveColumns.js +14 -20
  247. package/components/data/table/hooks/useRowExpansion.js +131 -127
  248. package/components/data/table/hooks/useRowHandlers.js +56 -69
  249. package/components/data/table/hooks/useRowSelection.js +249 -329
  250. package/components/data/table/hooks/useServerSideSorting.js +109 -175
  251. package/components/data/table/hooks/useTableColumns.js +322 -331
  252. package/components/data/table/hooks/useTableData.js +111 -166
  253. package/components/data/table/hooks/useTableEdit.js +526 -564
  254. package/components/data/table/hooks/useTableEffects.js +60 -107
  255. package/components/data/table/hooks/useTableFilter.js +244 -237
  256. package/components/data/table/hooks/useTableInitialization.js +44 -76
  257. package/components/data/table/hooks/useTableState.js +39 -61
  258. package/components/data/table/hooks/useTableStateManager.js +295 -468
  259. package/components/data/table/index.js +1556 -1713
  260. package/components/data/table/live-table/index.js +157 -219
  261. package/components/data/table/props.js +0 -5
  262. package/components/data/table/table-action/index.js +97 -75
  263. package/components/data/table/table-column/index.js +48 -42
  264. package/components/data/table/table-group/index.js +7 -25
  265. package/components/data/table/table-row/index.js +63 -55
  266. package/components/data/table/table-row-action/index.js +102 -77
  267. package/components/data/table/utils/buildSelectionColumns.js +86 -137
  268. package/components/data/table/utils/columnBuilder.d.ts +1 -1
  269. package/components/data/table/utils/columnBuilder.js +121 -160
  270. package/components/data/table/utils/columnProxy.js +48 -66
  271. package/components/data/table/utils/columnWidthDistribution.js +40 -64
  272. package/components/data/table/utils/constants.js +92 -40
  273. package/components/data/table/utils/crud-handlers.js +292 -473
  274. package/components/data/table/utils/dynamic-columns.js +99 -144
  275. package/components/data/table/utils/groupHeaderUtils.js +36 -61
  276. package/components/data/table/utils/index.d.ts +17 -13
  277. package/components/data/table/utils/index.js +483 -639
  278. package/components/data/table/utils/renderDisplayCell.js +127 -169
  279. package/components/data/table/utils/script-page-size-broadcast.js +17 -29
  280. package/components/data/table/utils/selectionUtils.js +59 -113
  281. package/components/data/table/utils/table-helpers.js +38 -74
  282. package/components/data/table/utils/validation.js +35 -78
  283. package/components/data/table/utils/widgetMapping.d.ts +5 -0
  284. package/components/data/table/utils/widgetMapping.js +41 -0
  285. package/components/data/types.js +112 -112
  286. package/components/data/utils/field-data-utils.js +38 -42
  287. package/components/data/utils/filter-field-util.js +42 -44
  288. package/components/data/utils/index.js +112 -111
  289. package/components/dialogs/alert-dialog/index.js +83 -78
  290. package/components/dialogs/alert-dialog/props.js +0 -5
  291. package/components/dialogs/confirm-dialog/index.js +102 -92
  292. package/components/dialogs/confirm-dialog/props.js +0 -5
  293. package/components/dialogs/dialog/index.js +93 -69
  294. package/components/dialogs/dialog/props.js +0 -5
  295. package/components/dialogs/dialog-actions/index.js +12 -26
  296. package/components/dialogs/dialog-actions/props.js +0 -5
  297. package/components/dialogs/dialog-body/index.js +13 -30
  298. package/components/dialogs/dialog-body/props.js +0 -5
  299. package/components/dialogs/dialog-content/index.js +48 -41
  300. package/components/dialogs/dialog-content/props.js +0 -5
  301. package/components/dialogs/dialog-header/index.js +88 -101
  302. package/components/dialogs/dialog-header/props.js +0 -5
  303. package/components/dialogs/iframe-dialog/index.js +136 -128
  304. package/components/dialogs/iframe-dialog/props.js +0 -5
  305. package/components/dialogs/index.js +104 -101
  306. package/components/dialogs/login-dialog/index.js +285 -347
  307. package/components/dialogs/login-dialog/props.js +0 -5
  308. package/components/dialogs/page-dialog/index.js +95 -86
  309. package/components/dialogs/page-dialog/props.js +0 -5
  310. package/components/dialogs/props.js +0 -5
  311. package/components/dialogs/withDialogWrapper.js +110 -83
  312. package/components/form/button/index.js +296 -245
  313. package/components/form/button/props.js +0 -5
  314. package/components/form/button-group/index.js +80 -69
  315. package/components/form/button-group/props.js +0 -5
  316. package/components/input/calendar/index.js +409 -362
  317. package/components/input/calendar/props.js +0 -5
  318. package/components/input/calendar/utils.js +164 -172
  319. package/components/input/chips/SortableChip/index.js +109 -100
  320. package/components/input/chips/SortableChip/props.js +0 -5
  321. package/components/input/chips/index.js +663 -570
  322. package/components/input/chips/props.js +0 -5
  323. package/components/input/chips/utils.js +131 -122
  324. package/components/input/color-picker/index.js +536 -594
  325. package/components/input/color-picker/props.js +0 -5
  326. package/components/input/composite/index.js +71 -110
  327. package/components/input/composite/props.js +0 -5
  328. package/components/input/currency/index.js +277 -224
  329. package/components/input/currency/props.js +0 -5
  330. package/components/input/default/checkbox/index.js +329 -250
  331. package/components/input/default/checkbox/props.js +0 -5
  332. package/components/input/default/checkboxset/index.d.ts +2 -0
  333. package/components/input/default/checkboxset/index.js +529 -446
  334. package/components/input/default/checkboxset/props.d.ts +4 -0
  335. package/components/input/default/checkboxset/props.js +0 -5
  336. package/components/input/default/checkboxset/utils.js +15 -25
  337. package/components/input/default/radioset/index.d.ts +2 -0
  338. package/components/input/default/radioset/index.js +409 -350
  339. package/components/input/default/radioset/props.d.ts +6 -0
  340. package/components/input/default/radioset/props.js +0 -5
  341. package/components/input/default/switch/index.js +494 -458
  342. package/components/input/default/switch/prop.js +0 -5
  343. package/components/input/epoch/date/components/DatePickerPopover.js +242 -193
  344. package/components/input/epoch/date/index.js +638 -518
  345. package/components/input/epoch/date/props.js +0 -5
  346. package/components/input/epoch/date/styled.js +61 -70
  347. package/components/input/epoch/date/utils.js +67 -115
  348. package/components/input/epoch/datetime/index.js +758 -695
  349. package/components/input/epoch/datetime/props.js +0 -5
  350. package/components/input/epoch/datetime/utils.js +121 -186
  351. package/components/input/epoch/time/index.js +441 -415
  352. package/components/input/epoch/time/props.js +0 -5
  353. package/components/input/epoch/time/utils.js +101 -112
  354. package/components/input/fileupload/Utils.js +70 -97
  355. package/components/input/fileupload/components/ListItems.js +132 -130
  356. package/components/input/fileupload/components/MultiUpload.js +80 -77
  357. package/components/input/fileupload/components/SingleUpload.js +57 -57
  358. package/components/input/fileupload/index.js +253 -178
  359. package/components/input/fileupload/props.js +0 -5
  360. package/components/input/fileupload/useFileUpload.js +209 -258
  361. package/components/input/number/index.js +434 -393
  362. package/components/input/number/props.js +0 -5
  363. package/components/input/rating/index.js +401 -394
  364. package/components/input/rating/props.js +0 -5
  365. package/components/input/select/index.js +408 -463
  366. package/components/input/select/props.js +0 -5
  367. package/components/input/slider/index.js +339 -332
  368. package/components/input/slider/props.js +0 -5
  369. package/components/input/text/index.d.ts +3 -3
  370. package/components/input/text/index.js +438 -475
  371. package/components/input/text/props.d.ts +1 -1
  372. package/components/input/text/props.js +0 -5
  373. package/components/input/text/util.js +82 -222
  374. package/components/input/textarea/index.js +322 -358
  375. package/components/input/textarea/props.js +0 -5
  376. package/components/input/upload/index.js +135 -131
  377. package/components/input/upload/props.js +0 -5
  378. package/components/input/util/index.js +9 -11
  379. package/components/layout/footer/index.js +12 -35
  380. package/components/layout/footer/props.js +0 -5
  381. package/components/layout/header/index.js +12 -38
  382. package/components/layout/header/props.js +0 -5
  383. package/components/layout/leftnav/index.js +57 -44
  384. package/components/layout/leftnav/props.d.ts +9 -0
  385. package/components/layout/leftnav/props.js +0 -5
  386. package/components/layout/leftnav/utils/page-class-util.d.ts +9 -0
  387. package/components/layout/leftnav/utils/page-class-util.js +28 -0
  388. package/components/layout/rightnav/index.js +12 -36
  389. package/components/layout/rightnav/props.js +0 -5
  390. package/components/layout/topnav/index.js +24 -38
  391. package/components/layout/topnav/props.js +0 -5
  392. package/components/navbar/index.js +119 -98
  393. package/components/navbar/nav/index.js +236 -232
  394. package/components/navbar/nav/props.js +0 -5
  395. package/components/navbar/nav-item/index.js +74 -65
  396. package/components/navbar/nav-item/props.js +0 -5
  397. package/components/navigation/breadcrumb/index.js +38 -61
  398. package/components/navigation/breadcrumb/props.js +0 -5
  399. package/components/navigation/menu/components/ListItems.js +76 -67
  400. package/components/navigation/menu/constants.js +27 -42
  401. package/components/navigation/menu/hooks/useHoverState.hook.js +20 -47
  402. package/components/navigation/menu/hooks/useKeyboardMovements.hook.js +34 -28
  403. package/components/navigation/menu/hooks/useTransformedDataset.hook.js +21 -14
  404. package/components/navigation/menu/index.js +911 -846
  405. package/components/navigation/menu/props.js +0 -5
  406. package/components/navigation/menu/utils/action-task.js +6 -9
  407. package/components/navigation/menu/utils/role-filter.js +41 -56
  408. package/components/navigation/popover/index.js +192 -205
  409. package/components/navigation/popover/props.js +5 -8
  410. package/components/page/content/index.js +9 -31
  411. package/components/page/content/props.js +0 -5
  412. package/components/page/error-boundary/index.js +115 -105
  413. package/components/page/error-boundary/props.js +0 -5
  414. package/components/page/index.js +100 -102
  415. package/components/page/page-content/index.js +21 -30
  416. package/components/page/page-content/props.js +0 -5
  417. package/components/page/page-context.d.ts +4 -0
  418. package/components/page/page-context.js +5 -0
  419. package/components/page/partial/index.js +50 -45
  420. package/components/page/partial/props.js +0 -5
  421. package/components/page/partial-container/index.js +78 -107
  422. package/components/page/partial-container/props.d.ts +1 -1
  423. package/components/page/partial-container/props.js +0 -5
  424. package/components/page/props.js +0 -5
  425. package/components/page/toast-container/index.js +20 -41
  426. package/components/page/toast-container/props.js +0 -5
  427. package/components/prefab/container/index.js +60 -53
  428. package/components/prefab/container/props.js +0 -5
  429. package/components/prefab/index.js +76 -61
  430. package/components/prefab/props.js +0 -5
  431. package/context/AppContext.d.ts +1 -1
  432. package/context/AppContext.js +17 -18
  433. package/context/AppSpinnerProvider.js +19 -34
  434. package/context/LayoutProvider.js +54 -57
  435. package/context/LocalizationProvider.js +34 -49
  436. package/context/PrefabContext.js +68 -119
  437. package/context/WidgetProvider.js +160 -166
  438. package/core/app-config.js +0 -1
  439. package/core/app.service.js +200 -327
  440. package/core/appVariablesStore.js +10 -15
  441. package/core/appstore.js +37 -53
  442. package/core/constants/currency-constant.js +81 -83
  443. package/core/constants/events.js +34 -44
  444. package/core/constants/index.js +21 -31
  445. package/core/dialog.service.js +52 -72
  446. package/core/event-notifier.js +94 -131
  447. package/core/formatter/array-formatters.js +18 -32
  448. package/core/formatter/date-formatters.js +140 -204
  449. package/core/formatter/index.js +64 -117
  450. package/core/formatter/number-formatters.js +115 -159
  451. package/core/formatter/security-formatters.js +233 -283
  452. package/core/formatter/string-formatters.js +23 -45
  453. package/core/formatter/types.js +12 -18
  454. package/core/formatters.js +6 -24
  455. package/core/proxy-service.js +242 -306
  456. package/core/script-registry.js +87 -134
  457. package/core/security.service.js +8 -11
  458. package/core/util/compare.js +13 -25
  459. package/core/util/dom.js +32 -63
  460. package/core/util/index.js +92 -98
  461. package/core/util/safe-is-equal.js +42 -94
  462. package/core/util/security.js +114 -153
  463. package/core/util/utils.d.ts +4 -1
  464. package/core/util/utils.js +88 -159
  465. package/core/widget-observer.js +34 -61
  466. package/higherOrder/BaseApp.js +328 -502
  467. package/higherOrder/BaseAppProps.d.ts +1 -0
  468. package/higherOrder/BaseAppProps.js +0 -5
  469. package/higherOrder/BaseDateTime.js +277 -231
  470. package/higherOrder/BasePage.js +474 -740
  471. package/higherOrder/BasePartial.js +87 -114
  472. package/higherOrder/BasePrefab.js +190 -206
  473. package/higherOrder/DataNav.js +287 -302
  474. package/higherOrder/helper.js +62 -48
  475. package/higherOrder/props.js +0 -5
  476. package/higherOrder/withBaseWrapper.js +123 -168
  477. package/higherOrder/withStandalone.js +28 -26
  478. package/hooks/useAccess.js +113 -289
  479. package/hooks/useAppConfig.js +15 -40
  480. package/hooks/useAuth.js +256 -495
  481. package/hooks/useDataSourceSubscription.d.ts +3 -3
  482. package/hooks/useDataSourceSubscription.js +99 -109
  483. package/hooks/useDebounce.js +28 -56
  484. package/hooks/useDeviceVisibility.js +14 -23
  485. package/hooks/useHttp.d.ts +1 -0
  486. package/hooks/useHttp.js +314 -493
  487. package/libs/index.js +4 -13
  488. package/libs/prefab/index.js +6 -20
  489. package/mui-config/theme-provider.js +9 -17
  490. package/mui-config/theme.js +6 -9
  491. package/package-lock.json +816 -3207
  492. package/package.json +3 -19
  493. package/providers/AppProviders.js +21 -24
  494. package/runtime-dynamic/App.js +65 -93
  495. package/runtime-dynamic/app-initializer.js +193 -411
  496. package/runtime-dynamic/components/ErrorBoundary.js +59 -76
  497. package/runtime-dynamic/components/PageWrapper.js +23 -35
  498. package/runtime-dynamic/components/PrefabPreview.js +40 -69
  499. package/runtime-dynamic/components/partial-content.d.ts +2 -3
  500. package/runtime-dynamic/components/partial-content.js +66 -45
  501. package/runtime-dynamic/components/prefab-content.js +37 -30
  502. package/runtime-dynamic/components/use-dynamic-component.js +55 -157
  503. package/runtime-dynamic/factories/build-base-page-like-component.d.ts +1 -1
  504. package/runtime-dynamic/factories/build-base-page-like-component.js +44 -58
  505. package/runtime-dynamic/factories/dynamic-component.d.ts +9 -0
  506. package/runtime-dynamic/factories/dynamic-component.js +91 -0
  507. package/runtime-dynamic/factories/prefab-factory.d.ts +1 -1
  508. package/runtime-dynamic/factories/prefab-factory.js +60 -81
  509. package/runtime-dynamic/factories/startup-info.js +12 -25
  510. package/runtime-dynamic/factories/utils.d.ts +2 -10
  511. package/runtime-dynamic/factories/utils.js +47 -129
  512. package/runtime-dynamic/index.js +56 -191
  513. package/runtime-dynamic/main.js +42 -70
  514. package/runtime-dynamic/preview-mode.js +14 -29
  515. package/runtime-dynamic/preview-navigation.js +21 -30
  516. package/runtime-dynamic/preview-path.d.ts +5 -0
  517. package/runtime-dynamic/preview-path.js +13 -0
  518. package/runtime-dynamic/preview-resource-base.js +15 -31
  519. package/runtime-dynamic/registry/component-registry.js +269 -334
  520. package/runtime-dynamic/registry/custom-widget-registry.js +11 -15
  521. package/runtime-dynamic/registry/index.js +24 -63
  522. package/runtime-dynamic/registry/store.d.ts +1 -0
  523. package/runtime-dynamic/registry/store.js +18 -23
  524. package/runtime-dynamic/routes.js +53 -81
  525. package/runtime-dynamic/services/app-extension-provider.js +17 -44
  526. package/runtime-dynamic/services/autolayout-inject.d.ts +4 -0
  527. package/runtime-dynamic/services/autolayout-inject.js +27 -0
  528. package/runtime-dynamic/services/compile-render.d.ts +9 -0
  529. package/runtime-dynamic/services/compile-render.js +142 -0
  530. package/runtime-dynamic/services/component-ref-provider.d.ts +18 -3
  531. package/runtime-dynamic/services/component-ref-provider.js +52 -129
  532. package/runtime-dynamic/services/css-scoping.js +23 -28
  533. package/runtime-dynamic/services/fragment-url.js +37 -50
  534. package/runtime-dynamic/services/index.d.ts +2 -3
  535. package/runtime-dynamic/services/index.js +31 -152
  536. package/runtime-dynamic/services/markup-transpiler.d.ts +2 -2
  537. package/runtime-dynamic/services/markup-transpiler.js +39 -231
  538. package/runtime-dynamic/services/prefab-resources.js +40 -118
  539. package/runtime-dynamic/services/resource-manager.d.ts +2 -2
  540. package/runtime-dynamic/services/resource-manager.js +24 -65
  541. package/runtime-dynamic/services/script-executor.js +46 -63
  542. package/runtime-dynamic/services/variable-factory.js +141 -184
  543. package/runtime-dynamic/services/variable-registry.js +65 -115
  544. package/runtime-dynamic/services/variable-transpiler.js +73 -103
  545. package/runtime-dynamic/shims/next-image.js +79 -50
  546. package/runtime-dynamic/shims/next-link.js +58 -32
  547. package/runtime-dynamic/shims/next-navigation.js +17 -34
  548. package/runtime-dynamic/utils/index.js +15 -30
  549. package/store/bindActions/i18nActions.js +16 -18
  550. package/store/index.js +29 -35
  551. package/store/middleware/navigationMiddleware.js +25 -45
  552. package/store/middleware/pendingTabNavigationIntentMiddleware.js +20 -25
  553. package/store/slices/appConfigSlice.js +65 -94
  554. package/store/slices/authSlice.js +317 -471
  555. package/store/slices/i18nSlice.js +169 -168
  556. package/store/slices/navigationSlice.js +22 -20
  557. package/store/util/resolve-path.d.ts +1 -0
  558. package/store/util/resolve-path.js +7 -0
  559. package/store/viewport.service.js +150 -194
  560. package/types/index.js +10 -15
  561. package/utils/attr.js +191 -41
  562. package/utils/custom-expression/index.js +58 -151
  563. package/utils/custom-expression/parser.js +108 -182
  564. package/utils/dataset-util.js +113 -154
  565. package/utils/eval-expression.js +10 -19
  566. package/utils/form-state.util.js +60 -118
  567. package/utils/form-utils.js +49 -190
  568. package/utils/format-util.js +113 -184
  569. package/utils/layoutsize-util.js +11 -17
  570. package/utils/lib-error-skipper.js +54 -52
  571. package/utils/page-params-util.js +50 -40
  572. package/utils/pending-tab-navigation-intent.js +7 -17
  573. package/utils/resource-url.js +8 -19
  574. package/utils/state-persistance.d.ts +1 -1
  575. package/utils/state-persistance.js +136 -253
  576. package/utils/style-utils.js +24 -78
  577. package/utils/transformedDataset-utils.js +353 -381
  578. package/utils/widget-cleanup-util.js +42 -74
  579. package/utils/widgets.js +19 -31
  580. package/variables/base-variable.js +117 -166
  581. package/variables/constants.js +5 -8
  582. package/variables/crud-variable.js +150 -181
  583. package/variables/live-variable.d.ts +1 -1
  584. package/variables/live-variable.js +140 -174
  585. package/variables/metadata.service.js +74 -116
  586. package/variables/model-variable.js +68 -78
  587. package/variables/service-variable.js +171 -285
  588. package/wm-namespace.js +11 -14
  589. package/components/chart/src/css.d.js +0 -1
  590. package/runtime-dynamic/services/cache.d.ts +0 -29
  591. package/runtime-dynamic/services/cache.js +0 -57
  592. package/tsconfig.declaration.tsbuildinfo +0 -1
  593. package/types/global.d.js +0 -3
@@ -1,304 +1,238 @@
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.WmWizard = void 0;
9
- var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"));
10
- var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
11
- var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
12
- var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
13
- var _react = _interopRequireWildcard(require("react"));
14
- var _material = require("@mui/material");
15
- var _clsx = _interopRequireDefault(require("clsx"));
16
- var _withBaseWrapper = require("@wavemaker-ai/react-runtime/higherOrder/withBaseWrapper");
17
- var _utils = require("./utils");
18
- var _WizardContext = _interopRequireDefault(require("./WizardContext"));
19
- var _wizardStep = require("./wizard-step");
20
- var _WizardStep = require("./components/WizardStep");
21
- var _form = _interopRequireDefault(require("@wavemaker-ai/react-runtime/components/data/form"));
22
- var _formUtils = require("@wavemaker-ai/react-runtime/utils/form-utils");
23
- var _formContext = require("@wavemaker-ai/react-runtime/components/data/form/form-context");
24
- var _isEqual = _interopRequireDefault(require("lodash-es/isEqual"));
25
- var _withStandalone = _interopRequireDefault(require("@wavemaker-ai/react-runtime/higherOrder/withStandalone"));
26
- 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); }
27
- var __jsx = _react["default"].createElement;
28
- function _createForOfIteratorHelper(r, e) { var t = "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (!t) { if (Array.isArray(r) || (t = _unsupportedIterableToArray(r)) || e && r && "number" == typeof r.length) { t && (r = t); var _n = 0, F = function F() {}; return { s: F, n: function n() { return _n >= r.length ? { done: !0 } : { done: !1, value: r[_n++] }; }, e: function e(r) { throw r; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var o, a = !0, u = !1; return { s: function s() { t = t.call(r); }, n: function n() { var r = t.next(); return a = r.done, r; }, e: function e(r) { u = !0, o = r; }, f: function f() { try { a || null == t["return"] || t["return"](); } finally { if (u) throw o; } } }; }
29
- function _unsupportedIterableToArray(r, a) { if (r) { if ("string" == typeof r) return _arrayLikeToArray(r, a); var t = {}.toString.call(r).slice(8, -1); return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0; } }
30
- function _arrayLikeToArray(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; }
31
- 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; }
32
- 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; }
33
- var DEFAULT_CLS = "app-wizard panel clearfix";
34
- var BODY_CLASS = "app-wizard-body panel-body";
35
-
36
- // Main Wizard Component
37
- var WmWizard = /*#__PURE__*/(0, _react.memo)(function (props) {
38
- var listener = props.listener,
39
- _props$stepstyle = props.stepstyle,
40
- stepstyle = _props$stepstyle === void 0 ? "auto" : _props$stepstyle,
41
- _props$actionsalignme = props.actionsalignment,
42
- actionsalignment = _props$actionsalignme === void 0 ? "right" : _props$actionsalignme,
43
- _props$defaultstep = props.defaultstep,
44
- defaultstep = _props$defaultstep === void 0 ? "none" : _props$defaultstep,
45
- _props$defaultstepind = props.defaultstepindex,
46
- defaultstepindex = _props$defaultstepind === void 0 ? 0 : _props$defaultstepind,
47
- _props$cancelable = props.cancelable,
48
- cancelable = _props$cancelable === void 0 ? true : _props$cancelable,
49
- _props$enablenext = props.enablenext,
50
- enablenext = _props$enablenext === void 0 ? false : _props$enablenext,
51
- _props$nextbtnlabel = props.nextbtnlabel,
52
- nextbtnlabel = _props$nextbtnlabel === void 0 ? "Next" : _props$nextbtnlabel,
53
- _props$previousbtnlab = props.previousbtnlabel,
54
- previousbtnlabel = _props$previousbtnlab === void 0 ? "Previous" : _props$previousbtnlab,
55
- _props$donebtnlabel = props.donebtnlabel,
56
- donebtnlabel = _props$donebtnlabel === void 0 ? "Done" : _props$donebtnlabel,
57
- _props$cancelbtnlabel = props.cancelbtnlabel,
58
- cancelbtnlabel = _props$cancelbtnlabel === void 0 ? "Cancel" : _props$cancelbtnlabel,
59
- _props$type = props.type,
60
- type = _props$type === void 0 ? "static" : _props$type,
61
- _props$dataset = props.dataset,
62
- dataset = _props$dataset === void 0 ? [] : _props$dataset,
63
- _props$nodatamessage = props.nodatamessage,
64
- nodatamessage = _props$nodatamessage === void 0 ? "No Data Found" : _props$nodatamessage,
65
- children = props.children,
66
- _props$className = props.className,
67
- className = _props$className === void 0 ? "classic" : _props$className,
68
- styles = props.styles,
69
- _props$name = props.name,
70
- name = _props$name === void 0 ? "" : _props$name,
71
- onCancel = props.onCancel,
72
- onDone = props.onDone,
73
- message = props.message,
74
- _props$orientation = props.orientation,
75
- orientation = _props$orientation === void 0 ? "horizontal" : _props$orientation,
76
- _props$alternativeLab = props.alternativeLabel,
77
- alternativeLabel = _props$alternativeLab === void 0 ? false : _props$alternativeLab,
78
- _props$nonLinear = props.nonLinear,
79
- nonLinear = _props$nonLinear === void 0 ? true : _props$nonLinear,
80
- connector = props.connector,
81
- width = props.width,
82
- height = props.height,
83
- render = props.render,
84
- _props$standalone = props.standalone,
85
- standalone = _props$standalone === void 0 ? false : _props$standalone;
86
- var _useState = (0, _react.useState)([]),
87
- steps = _useState[0],
88
- setSteps = _useState[1];
89
- var _useState2 = (0, _react.useState)(message || {
90
- caption: "",
91
- type: ""
92
- }),
93
- wizardMessage = _useState2[0],
94
- setWizardMessage = _useState2[1];
95
- var _useState3 = (0, _react.useState)(false),
96
- isInitialized = _useState3[0],
97
- setIsInitialized = _useState3[1];
98
- var formRefs = (0, _react.useRef)({});
99
- var stepContainerRefs = (0, _react.useRef)({});
100
- var navIndexRef = (0, _react.useRef)(-1);
101
- var _useState4 = (0, _react.useState)(false),
102
- formReady = _useState4[0],
103
- setFormReady = _useState4[1];
104
-
105
- // Detect if wizard is inside an outer form
106
- var parentFormContext = (0, _formContext.useParentFormData)();
107
- var isInsideOuterForm = !!parentFormContext && Object.keys(parentFormContext).length > 0;
108
-
109
- // Create dynamic steps callback
110
- var createDynamicSteps = (0, _react.useCallback)(function (datasetItems, startIndex) {
111
- return datasetItems.map(function (item, index) {
112
- index = startIndex || index;
113
- var stepData = render ? render(item, index, datasetItems) : item;
114
- var stepProps = (stepData === null || stepData === void 0 ? void 0 : stepData.props) || {};
115
- if (/*#__PURE__*/(0, _react.isValidElement)(stepData)) {
116
- var _stepData$props;
117
- if (stepData.type === _wizardStep.WmWizardstep) {
118
- stepProps = stepData.props || {};
119
- } else if ((_stepData$props = stepData.props) !== null && _stepData$props !== void 0 && _stepData$props.children) {
120
- var _stepData$props2;
121
- var childrenArray = _react.Children.toArray((_stepData$props2 = stepData.props) === null || _stepData$props2 === void 0 ? void 0 : _stepData$props2.children);
122
- var firstWizardStep = childrenArray.find(function (child) {
123
- return /*#__PURE__*/(0, _react.isValidElement)(child) && child.type === _wizardStep.WmWizardstep;
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
+ import { jsx, jsxs } from "react/jsx-runtime";
21
+ import React, {
22
+ memo,
23
+ useState,
24
+ useEffect,
25
+ useCallback,
26
+ useMemo,
27
+ isValidElement,
28
+ cloneElement,
29
+ useRef,
30
+ Children
31
+ } from "react";
32
+ import { Box, Typography, Stepper } from "@mui/material";
33
+ import clsx from "clsx";
34
+ import { withBaseWrapper } from "../../../higherOrder/withBaseWrapper";
35
+ import {
36
+ getNextValidStep,
37
+ getStepByName,
38
+ getStepByIndex,
39
+ handleNavigation,
40
+ extendNextFn,
41
+ extendPrevFn,
42
+ getPrevValidStep,
43
+ appendDatasetSteps,
44
+ trimStepsToLength
45
+ } from "./utils";
46
+ import WizardContext from "./WizardContext";
47
+ import { WmWizardstep } from "./wizard-step";
48
+ import { WizardStep } from "./components/WizardStep";
49
+ import WmForm from "../../data/form";
50
+ import { getFormData } from "../../../utils/form-utils";
51
+ import { useParentFormData } from "../../data/form/form-context";
52
+ import isEqual from "lodash-es/isEqual";
53
+ import withStandalone from "../../../higherOrder/withStandalone";
54
+ const DEFAULT_CLS = "app-wizard panel clearfix";
55
+ const BODY_CLASS = "app-wizard-body panel-body";
56
+ const WmWizard = memo(
57
+ (props) => {
58
+ const {
59
+ listener,
60
+ stepstyle = "auto",
61
+ actionsalignment = "right",
62
+ defaultstep = "none",
63
+ defaultstepindex = 0,
64
+ cancelable = true,
65
+ enablenext = false,
66
+ nextbtnlabel = "Next",
67
+ previousbtnlabel = "Previous",
68
+ donebtnlabel = "Done",
69
+ cancelbtnlabel = "Cancel",
70
+ type = "static",
71
+ dataset = [],
72
+ nodatamessage = "No Data Found",
73
+ children,
74
+ className = "classic",
75
+ styles,
76
+ name = "",
77
+ onCancel,
78
+ onDone,
79
+ message,
80
+ orientation = "horizontal",
81
+ alternativeLabel = false,
82
+ nonLinear = true,
83
+ connector,
84
+ width,
85
+ height,
86
+ render,
87
+ standalone = false
88
+ } = props;
89
+ const [steps, setSteps] = useState([]);
90
+ const [wizardMessage, setWizardMessage] = useState(message || { caption: "", type: "" });
91
+ const [isInitialized, setIsInitialized] = useState(false);
92
+ const formRefs = useRef({});
93
+ const stepContainerRefs = useRef({});
94
+ const navIndexRef = useRef(-1);
95
+ const [formReady, setFormReady] = useState(false);
96
+ const parentFormContext = useParentFormData();
97
+ const isInsideOuterForm = !!parentFormContext && Object.keys(parentFormContext).length > 0;
98
+ const createDynamicSteps = useCallback(
99
+ (datasetItems, startIndex) => {
100
+ return datasetItems.map((item, index) => {
101
+ var _a, _b;
102
+ index = startIndex || index;
103
+ const stepData = render ? render(item, index, datasetItems) : item;
104
+ let stepProps = (stepData == null ? void 0 : stepData.props) || {};
105
+ if (isValidElement(stepData)) {
106
+ if (stepData.type === WmWizardstep) {
107
+ stepProps = stepData.props || {};
108
+ } else if ((_a = stepData.props) == null ? void 0 : _a.children) {
109
+ const childrenArray = Children.toArray(
110
+ (_b = stepData.props) == null ? void 0 : _b.children
111
+ );
112
+ const firstWizardStep = childrenArray.find(
113
+ (child) => isValidElement(child) && child.type === WmWizardstep
114
+ );
115
+ if (isValidElement(firstWizardStep)) {
116
+ stepProps = firstWizardStep.props || {};
117
+ }
118
+ }
119
+ }
120
+ return __spreadProps(__spreadValues({}, stepProps), {
121
+ name: `step_${index}`,
122
+ title: stepProps.title || `Step ${index + 1}`,
123
+ show: stepProps.show !== false,
124
+ enableskip: stepData.enableskip || false,
125
+ enableNext: stepData.enableNext !== false,
126
+ enablePrev: stepData.enablePrev !== false,
127
+ enableDone: stepData.enableDone !== false,
128
+ isDone: false,
129
+ done: false,
130
+ active: index === defaultstepindex,
131
+ disabled: false,
132
+ isValid: true,
133
+ isInitialized: false,
134
+ isdynamic: true,
135
+ dynamicStepIndex: index,
136
+ render: stepProps.render
124
137
  });
125
- if (/*#__PURE__*/(0, _react.isValidElement)(firstWizardStep)) {
126
- stepProps = firstWizardStep.props || {};
138
+ });
139
+ },
140
+ [defaultstepindex]
141
+ );
142
+ const currentStep = useMemo(() => steps.find((step) => step.active) || null, [steps]);
143
+ const visibleSteps = useMemo(() => steps.filter((step) => step.show), [steps]);
144
+ const currentStepIndex = useMemo(() => {
145
+ if (!currentStep) return -1;
146
+ return visibleSteps.findIndex((step) => step.name === currentStep.name);
147
+ }, [currentStep, visibleSteps]);
148
+ useEffect(() => {
149
+ navIndexRef.current = currentStepIndex;
150
+ }, [currentStepIndex]);
151
+ const hasNextStep = useMemo(
152
+ () => currentStepIndex < visibleSteps.length - 1,
153
+ [currentStepIndex, visibleSteps]
154
+ );
155
+ const hasPrevStep = useMemo(() => currentStepIndex > 0, [currentStepIndex]);
156
+ const showDoneBtn = useMemo(
157
+ () => !hasNextStep && (currentStep == null ? void 0 : currentStep.enableDone) !== false,
158
+ [hasNextStep, currentStep]
159
+ );
160
+ const [isStepValid, setIsStepValid] = useState(true);
161
+ const [formValiditySignature, setFormValiditySignature] = useState("");
162
+ const formValidityMapRef = useRef(/* @__PURE__ */ new Map());
163
+ const getStepForms = useCallback((stepName) => {
164
+ var _a, _b;
165
+ const formElOrList = (_a = formRefs.current) == null ? void 0 : _a[stepName];
166
+ if (formElOrList) {
167
+ const cachedForms = Array.isArray(formElOrList) ? formElOrList : [formElOrList];
168
+ const stepContainer = (_b = cachedForms[0]) == null ? void 0 : _b.closest(".app-wizard-step-container");
169
+ if (stepContainer) {
170
+ const allForms = Array.from(stepContainer.querySelectorAll("form"));
171
+ if (allForms.length > 0) {
172
+ formRefs.current[stepName] = allForms.length === 1 ? allForms[0] : allForms;
173
+ return allForms;
127
174
  }
128
175
  }
176
+ return cachedForms;
129
177
  }
130
- return _objectSpread(_objectSpread({}, stepProps), {}, {
131
- name: "step_".concat(index),
132
- title: stepProps.title || "Step ".concat(index + 1),
133
- show: stepProps.show !== false,
134
- enableskip: stepData.enableskip || false,
135
- enableNext: stepData.enableNext !== false,
136
- enablePrev: stepData.enablePrev !== false,
137
- enableDone: stepData.enableDone !== false,
138
- isDone: false,
139
- done: false,
140
- active: index === defaultstepindex,
141
- disabled: false,
142
- isValid: true,
143
- isInitialized: false,
144
- isdynamic: true,
145
- dynamicStepIndex: index,
146
- render: stepProps.render
147
- });
148
- });
149
- }, [defaultstepindex]);
150
-
151
- // Computed properties
152
- var currentStep = (0, _react.useMemo)(function () {
153
- return steps.find(function (step) {
154
- return step.active;
155
- }) || null;
156
- }, [steps]);
157
- var visibleSteps = (0, _react.useMemo)(function () {
158
- return steps.filter(function (step) {
159
- return step.show;
160
- });
161
- }, [steps]);
162
- var currentStepIndex = (0, _react.useMemo)(function () {
163
- if (!currentStep) return -1;
164
- return visibleSteps.findIndex(function (step) {
165
- return step.name === currentStep.name;
166
- });
167
- }, [currentStep, visibleSteps]);
168
-
169
- // Sync navigation ref whenever the visible current index changes
170
- (0, _react.useEffect)(function () {
171
- navIndexRef.current = currentStepIndex;
172
- }, [currentStepIndex]);
173
- var _hasNextStep = (0, _react.useMemo)(function () {
174
- return currentStepIndex < visibleSteps.length - 1;
175
- }, [currentStepIndex, visibleSteps]);
176
- var hasPrevStep = (0, _react.useMemo)(function () {
177
- return currentStepIndex > 0;
178
- }, [currentStepIndex]);
179
- var showDoneBtn = (0, _react.useMemo)(function () {
180
- return !_hasNextStep && (currentStep === null || currentStep === void 0 ? void 0 : currentStep.enableDone) !== false;
181
- }, [_hasNextStep, currentStep]);
182
- var _useState5 = (0, _react.useState)(true),
183
- isStepValid = _useState5[0],
184
- setIsStepValid = _useState5[1];
185
- var _useState6 = (0, _react.useState)(""),
186
- formValiditySignature = _useState6[0],
187
- setFormValiditySignature = _useState6[1];
188
- var formValidityMapRef = (0, _react.useRef)(new Map());
189
-
190
- // Helper to get all forms in the current step container
191
- var getStepForms = (0, _react.useCallback)(function (stepName) {
192
- var _formRefs$current;
193
- // First try cached formRefs
194
- var formElOrList = (_formRefs$current = formRefs.current) === null || _formRefs$current === void 0 ? void 0 : _formRefs$current[stepName];
195
- if (formElOrList) {
196
- var _cachedForms$;
197
- var cachedForms = Array.isArray(formElOrList) ? formElOrList : [formElOrList];
198
- // Re-query the DOM to get ALL forms (list items may have rendered after initial cache)
199
- var stepContainer = (_cachedForms$ = cachedForms[0]) === null || _cachedForms$ === void 0 ? void 0 : _cachedForms$.closest(".app-wizard-step-container");
200
- if (stepContainer) {
201
- var allForms = Array.from(stepContainer.querySelectorAll("form"));
202
- if (allForms.length > 0) {
203
- // Update cache with all forms
204
- formRefs.current[stepName] = allForms.length === 1 ? allForms[0] : allForms;
205
- return allForms;
178
+ return [];
179
+ }, []);
180
+ useEffect(() => {
181
+ const stepName = currentStep == null ? void 0 : currentStep.name;
182
+ if (!stepName) return;
183
+ const stepContainer = stepContainerRefs.current[stepName];
184
+ if (!stepContainer) return;
185
+ formValidityMapRef.current.clear();
186
+ setFormValiditySignature("");
187
+ const initialForms = getStepForms(stepName);
188
+ if (initialForms.length === 0) return;
189
+ const onValidity = (e) => {
190
+ const form = e.target.closest("form");
191
+ if (!form) return;
192
+ const detail = e.detail;
193
+ const isValid = (detail == null ? void 0 : detail.isValid) !== false;
194
+ const currentForms = getStepForms(stepName);
195
+ formValidityMapRef.current.set(form, isValid);
196
+ const allFormsValid = currentForms.every((f) => {
197
+ const validity = formValidityMapRef.current.get(f);
198
+ return validity === void 0 || validity === true;
199
+ });
200
+ setFormValiditySignature(allFormsValid ? "1" : "0");
201
+ };
202
+ stepContainer.addEventListener("wm:form-validity", onValidity);
203
+ return () => {
204
+ stepContainer.removeEventListener("wm:form-validity", onValidity);
205
+ };
206
+ }, [currentStep, formReady, getStepForms]);
207
+ const parentFormIsValid = parentFormContext == null ? void 0 : parentFormContext.isValid;
208
+ useEffect(() => {
209
+ const validateStep = () => {
210
+ var _a;
211
+ if (!currentStep) return;
212
+ const forms = getStepForms(currentStep.name);
213
+ if (forms.length === 0) {
214
+ if (isInsideOuterForm && parentFormContext) {
215
+ setIsStepValid(parentFormContext.isValid === true);
216
+ return;
217
+ }
218
+ setIsStepValid(true);
219
+ return;
206
220
  }
207
- }
208
- return cachedForms;
209
- }
210
- return [];
211
- }, []);
212
- (0, _react.useEffect)(function () {
213
- var stepName = currentStep === null || currentStep === void 0 ? void 0 : currentStep.name;
214
- if (!stepName) return;
215
-
216
- // Get step container for event delegation
217
- var stepContainer = stepContainerRefs.current[stepName];
218
- if (!stepContainer) return;
219
-
220
- // Reset validity state for new step
221
- formValidityMapRef.current.clear();
222
- setFormValiditySignature("");
223
-
224
- // Only set up form validity tracking if forms are present inside the step
225
- var initialForms = getStepForms(stepName);
226
-
227
- // When inside outer form with no embedded forms, validity comes from context
228
- // No DOM event listener needed - parentFormContext.isValid is reactive
229
- if (initialForms.length === 0) return;
230
-
231
- // Use event delegation - listen on container, forms bubble their events up
232
- var onValidity = function onValidity(e) {
233
- // Find the form that emitted this event (could be e.target or closest form)
234
- var form = e.target.closest("form");
235
- if (!form) return;
236
- var detail = e.detail;
237
- var isValid = (detail === null || detail === void 0 ? void 0 : detail.isValid) !== false;
238
-
239
- // Re-query forms to get current list (handles dynamically added forms from lists)
240
- var currentForms = getStepForms(stepName);
241
-
242
- // Track validity per form element
243
- formValidityMapRef.current.set(form, isValid);
244
-
245
- // Check if ALL current forms are valid
246
- var allFormsValid = currentForms.every(function (f) {
247
- var validity = formValidityMapRef.current.get(f);
248
- // If we haven't received an event for this form yet, assume valid
249
- return validity === undefined || validity === true;
250
- });
251
- setFormValiditySignature(allFormsValid ? "1" : "0");
252
- };
253
-
254
- // Listen on container - captures events from all forms, including dynamically added ones
255
- stepContainer.addEventListener("wm:form-validity", onValidity);
256
- return function () {
257
- stepContainer.removeEventListener("wm:form-validity", onValidity);
258
- };
259
- }, [currentStep, formReady, getStepForms]);
260
- var parentFormIsValid = parentFormContext === null || parentFormContext === void 0 ? void 0 : parentFormContext.isValid;
261
- (0, _react.useEffect)(function () {
262
- var validateStep = function validateStep() {
263
- if (!currentStep) return;
264
-
265
- // Dynamically query for all forms (handles list items that render after initial mount)
266
- var forms = getStepForms(currentStep.name);
267
- if (forms.length === 0) {
268
- // When inside outer form with no embedded forms, use context-based validity
269
- if (isInsideOuterForm && parentFormContext) {
270
- setIsStepValid(parentFormContext.isValid === true);
221
+ const allFormsHidden = forms.every((form) => {
222
+ var _a2;
223
+ return form.hidden || ((_a2 = form.parentElement) == null ? void 0 : _a2.hidden);
224
+ });
225
+ if (allFormsHidden) {
226
+ setIsStepValid(true);
271
227
  return;
272
228
  }
273
- setIsStepValid(true);
274
- return;
275
- }
276
-
277
- // Check if all forms are hidden
278
- var allFormsHidden = forms.every(function (form) {
279
- var _form$parentElement;
280
- return form.hidden || ((_form$parentElement = form.parentElement) === null || _form$parentElement === void 0 ? void 0 : _form$parentElement.hidden);
281
- });
282
- if (allFormsHidden) {
283
- setIsStepValid(true);
284
- return;
285
- }
286
-
287
- // Check if any form has fields and collect validity
288
- var hasAnyFields = false;
289
- var allFormsValid = true;
290
- var _iterator = _createForOfIteratorHelper(forms),
291
- _step;
292
- try {
293
- for (_iterator.s(); !(_step = _iterator.n()).done;) {
294
- var _form$parentElement2;
295
- var form = _step.value;
296
- if (form.hidden || (_form$parentElement2 = form.parentElement) !== null && _form$parentElement2 !== void 0 && _form$parentElement2.hidden) continue;
297
- var formdata = (0, _formUtils.getFormData)({
298
- current: form
299
- });
229
+ let hasAnyFields = false;
230
+ let allFormsValid = true;
231
+ for (const form of forms) {
232
+ if (form.hidden || ((_a = form.parentElement) == null ? void 0 : _a.hidden)) continue;
233
+ const formdata = getFormData({ current: form });
300
234
  if (!formdata) continue;
301
- var hasFields = Object.keys(formdata.values || {}).length > 0;
235
+ const hasFields = Object.keys(formdata.values || {}).length > 0;
302
236
  if (hasFields) {
303
237
  hasAnyFields = true;
304
238
  if (formdata.isValid === false) {
@@ -306,662 +240,598 @@ var WmWizard = /*#__PURE__*/(0, _react.memo)(function (props) {
306
240
  }
307
241
  }
308
242
  }
309
- } catch (err) {
310
- _iterator.e(err);
311
- } finally {
312
- _iterator.f();
313
- }
314
- if (!hasAnyFields) {
315
- setIsStepValid(true);
316
- return;
317
- }
318
-
319
- // Use formValiditySignature which comes from the wm:form-validity event
320
- // This reflects the most up-to-date validity state from the form
321
- // "1" = valid, "0" = invalid, "" = no event received yet
322
- if (formValiditySignature === "") {
323
- // No validity event received yet - use collected validity from forms
324
- setIsStepValid(allFormsValid);
325
- } else {
326
- // Use the validity from the event
327
- setIsStepValid(formValiditySignature === "1");
328
- }
329
- };
330
- validateStep();
331
- }, [currentStep, formValiditySignature, formReady, getStepForms, isInsideOuterForm, parentFormContext, parentFormIsValid]);
332
- var enableNext = (0, _react.useMemo)(function () {
333
- var enablenextBool = typeof enablenext === "string" ? enablenext.toLowerCase() === "true" || enablenext === "1" : Boolean(enablenext);
334
- return enablenextBool || (currentStep === null || currentStep === void 0 ? void 0 : currentStep.enableNext) !== false && (currentStep === null || currentStep === void 0 ? void 0 : currentStep.isValid) !== false && isStepValid;
335
- }, [enablenext, currentStep, isStepValid]);
336
- var enablePrev = (0, _react.useMemo)(function () {
337
- return (currentStep === null || currentStep === void 0 ? void 0 : currentStep.enablePrev) !== false;
338
- }, [currentStep]);
339
- var enableDone = (0, _react.useMemo)(function () {
340
- return (currentStep === null || currentStep === void 0 ? void 0 : currentStep.enableDone) !== false && (currentStep === null || currentStep === void 0 ? void 0 : currentStep.isValid) !== false && isStepValid;
341
- }, [currentStep, isStepValid]);
342
- var isFirstStep = (0, _react.useMemo)(function () {
343
- return currentStepIndex === 0;
344
- }, [currentStepIndex]);
345
- var isLastStep = (0, _react.useMemo)(function () {
346
- return currentStepIndex === visibleSteps.length - 1;
347
- }, [currentStepIndex, visibleSteps]);
348
- var computedStepClass = (0, _react.useMemo)(function () {
349
- return stepstyle === "justified" ? "justified" : "auto";
350
- }, [stepstyle]);
351
-
352
- // Step click handler
353
- var onStepHeaderClick = (0, _react.useCallback)(function (event, step) {
354
- if ((step.done || step.isDone || nonLinear && type === "dynamic") && step.show && !step.disabled) {
355
- setSteps(function (prevSteps) {
356
- return prevSteps.map(function (s) {
357
- var stepIndex = prevSteps.findIndex(function (ps) {
358
- return ps.name === s.name;
359
- });
360
- var targetIndex = prevSteps.findIndex(function (ps) {
361
- return ps.name === step.name;
362
- });
363
- return _objectSpread(_objectSpread({}, s), {}, {
364
- active: s.name === step.name,
365
- isDone: type === "dynamic" ? stepIndex < targetIndex : stepIndex < targetIndex,
366
- done: type === "dynamic" ? stepIndex < targetIndex : stepIndex < targetIndex || s.name === step.name && targetIndex > 0,
367
- disabled: false,
368
- // Ensure enableNext and isValid are preserved when activating a step
369
- enableNext: s.name === step.name ? true : s.enableNext,
370
- isValid: s.name === step.name ? true : s.isValid
371
- });
372
- });
373
- });
374
- }
375
- }, [nonLinear, type]);
376
- var handleStepClick = (0, _react.useCallback)(function (index) {
377
- var step = visibleSteps[index];
378
- if (step && step.show && !step.disabled) {
379
- if (step.done || step.isDone) {
380
- onStepHeaderClick({}, step);
381
- }
382
- }
383
- }, [visibleSteps, nonLinear, onStepHeaderClick, type]);
384
-
385
- // Step management functions
386
- var updateStep = (0, _react.useCallback)(function (stepName, updates) {
387
- setSteps(function (prevSteps) {
388
- var stepIndex = prevSteps.findIndex(function (step) {
389
- return step.name === stepName;
390
- });
391
- if (stepIndex === -1) return prevSteps;
392
- var existing = prevSteps[stepIndex];
393
- var hasChanges = Object.keys(updates).some(function (key) {
394
- return existing[key] !== updates[key];
395
- });
396
- if (!hasChanges) return prevSteps;
397
- var newSteps = (0, _toConsumableArray2["default"])(prevSteps);
398
- newSteps[stepIndex] = _objectSpread(_objectSpread({}, existing), updates);
399
- return newSteps;
400
- });
401
- }, []);
402
-
403
- // Navigation functions
404
- var _next = (0, _react.useCallback)(/*#__PURE__*/(0, _asyncToGenerator2["default"])(/*#__PURE__*/_regenerator["default"].mark(function _callee() {
405
- var eventName,
406
- fromIndex,
407
- fromStep,
408
- nextStep,
409
- nextIndex,
410
- _fromStep$onSkip,
411
- response,
412
- _fromStep$onNext,
413
- _response,
414
- _args = arguments;
415
- return _regenerator["default"].wrap(function _callee$(_context) {
416
- while (1) switch (_context.prev = _context.next) {
417
- case 0:
418
- eventName = _args.length > 0 && _args[0] !== undefined ? _args[0] : "next";
419
- fromIndex = navIndexRef.current >= 0 ? navIndexRef.current : currentStepIndex;
420
- fromStep = (0, _utils.getStepByIndex)(fromIndex, visibleSteps);
421
- if (fromStep) {
422
- _context.next = 5;
423
- break;
424
- }
425
- return _context.abrupt("return");
426
- case 5:
427
- nextStep = (0, _utils.getNextValidStep)(fromIndex + 1, visibleSteps);
428
- if (nextStep) {
429
- _context.next = 8;
430
- break;
431
- }
432
- return _context.abrupt("return");
433
- case 8:
434
- nextIndex = visibleSteps.findIndex(function (s) {
435
- return s.name === nextStep.name;
436
- });
437
- if (!(eventName === "skip")) {
438
- _context.next = 19;
439
- break;
440
- }
441
- response = (_fromStep$onSkip = fromStep.onSkip) === null || _fromStep$onSkip === void 0 ? void 0 : _fromStep$onSkip.call(fromStep, fromStep, fromStep, fromIndex);
442
- if (!(response !== undefined)) {
443
- _context.next = 16;
444
- break;
445
- }
446
- _context.next = 14;
447
- return (0, _utils.handleNavigation)(response, function () {
448
- return (0, _utils.extendNextFn)(fromStep, fromIndex, visibleSteps, setSteps);
449
- });
450
- case 14:
451
- _context.next = 17;
452
- break;
453
- case 16:
454
- (0, _utils.extendNextFn)(fromStep, fromIndex, visibleSteps, setSteps);
455
- case 17:
456
- _context.next = 30;
457
- break;
458
- case 19:
459
- if (!(fromStep.isValid && eventName === "next")) {
460
- _context.next = 29;
461
- break;
243
+ if (!hasAnyFields) {
244
+ setIsStepValid(true);
245
+ return;
246
+ }
247
+ if (formValiditySignature === "") {
248
+ setIsStepValid(allFormsValid);
249
+ } else {
250
+ setIsStepValid(formValiditySignature === "1");
251
+ }
252
+ };
253
+ validateStep();
254
+ }, [
255
+ currentStep,
256
+ formValiditySignature,
257
+ formReady,
258
+ getStepForms,
259
+ isInsideOuterForm,
260
+ parentFormContext,
261
+ parentFormIsValid
262
+ ]);
263
+ const enableNext = useMemo(() => {
264
+ const enablenextBool = typeof enablenext === "string" ? enablenext.toLowerCase() === "true" || enablenext === "1" : Boolean(enablenext);
265
+ return enablenextBool || (currentStep == null ? void 0 : currentStep.enableNext) !== false && (currentStep == null ? void 0 : currentStep.isValid) !== false && isStepValid;
266
+ }, [enablenext, currentStep, isStepValid]);
267
+ const enablePrev = useMemo(() => (currentStep == null ? void 0 : currentStep.enablePrev) !== false, [currentStep]);
268
+ const enableDone = useMemo(
269
+ () => (currentStep == null ? void 0 : currentStep.enableDone) !== false && (currentStep == null ? void 0 : currentStep.isValid) !== false && isStepValid,
270
+ [currentStep, isStepValid]
271
+ );
272
+ const isFirstStep = useMemo(() => currentStepIndex === 0, [currentStepIndex]);
273
+ const isLastStep = useMemo(
274
+ () => currentStepIndex === visibleSteps.length - 1,
275
+ [currentStepIndex, visibleSteps]
276
+ );
277
+ const computedStepClass = useMemo(
278
+ () => stepstyle === "justified" ? "justified" : "auto",
279
+ [stepstyle]
280
+ );
281
+ const onStepHeaderClick = useCallback(
282
+ (event, step) => {
283
+ if ((step.done || step.isDone || nonLinear && type === "dynamic") && step.show && !step.disabled) {
284
+ setSteps(
285
+ (prevSteps) => prevSteps.map((s) => {
286
+ const stepIndex = prevSteps.findIndex((ps) => ps.name === s.name);
287
+ const targetIndex = prevSteps.findIndex((ps) => ps.name === step.name);
288
+ return __spreadProps(__spreadValues({}, s), {
289
+ active: s.name === step.name,
290
+ isDone: type === "dynamic" ? stepIndex < targetIndex : stepIndex < targetIndex,
291
+ done: type === "dynamic" ? stepIndex < targetIndex : stepIndex < targetIndex || s.name === step.name && targetIndex > 0,
292
+ disabled: false,
293
+ // Ensure enableNext and isValid are preserved when activating a step
294
+ enableNext: s.name === step.name ? true : s.enableNext,
295
+ isValid: s.name === step.name ? true : s.isValid
296
+ });
297
+ })
298
+ );
299
+ }
300
+ },
301
+ [nonLinear, type]
302
+ );
303
+ const handleStepClick = useCallback(
304
+ (index) => {
305
+ const step = visibleSteps[index];
306
+ if (step && step.show && !step.disabled) {
307
+ if (step.done || step.isDone) {
308
+ onStepHeaderClick({}, step);
462
309
  }
463
- _response = (_fromStep$onNext = fromStep.onNext) === null || _fromStep$onNext === void 0 ? void 0 : _fromStep$onNext.call(fromStep, fromStep, fromStep, fromIndex);
464
- if (!(_response !== undefined)) {
465
- _context.next = 26;
466
- break;
310
+ }
311
+ },
312
+ [visibleSteps, nonLinear, onStepHeaderClick, type]
313
+ );
314
+ const updateStep = useCallback((stepName, updates) => {
315
+ setSteps((prevSteps) => {
316
+ const stepIndex = prevSteps.findIndex((step) => step.name === stepName);
317
+ if (stepIndex === -1) return prevSteps;
318
+ const existing = prevSteps[stepIndex];
319
+ const hasChanges = Object.keys(updates).some(
320
+ (key) => existing[key] !== updates[key]
321
+ );
322
+ if (!hasChanges) return prevSteps;
323
+ const newSteps = [...prevSteps];
324
+ newSteps[stepIndex] = __spreadValues(__spreadValues({}, existing), updates);
325
+ return newSteps;
326
+ });
327
+ }, []);
328
+ const next = useCallback(
329
+ async (eventName = "next") => {
330
+ var _a, _b;
331
+ const fromIndex = navIndexRef.current >= 0 ? navIndexRef.current : currentStepIndex;
332
+ const fromStep = getStepByIndex(fromIndex, visibleSteps);
333
+ if (!fromStep) return;
334
+ const nextStep = getNextValidStep(fromIndex + 1, visibleSteps);
335
+ if (!nextStep) return;
336
+ const nextIndex = visibleSteps.findIndex((s) => s.name === nextStep.name);
337
+ if (eventName === "skip") {
338
+ const response = (_a = fromStep.onSkip) == null ? void 0 : _a.call(fromStep, fromStep, fromStep, fromIndex);
339
+ if (response !== void 0) {
340
+ await handleNavigation(
341
+ response,
342
+ () => extendNextFn(fromStep, fromIndex, visibleSteps, setSteps)
343
+ );
344
+ } else {
345
+ extendNextFn(fromStep, fromIndex, visibleSteps, setSteps);
467
346
  }
468
- _context.next = 24;
469
- return (0, _utils.handleNavigation)(_response, function () {
470
- return (0, _utils.extendNextFn)(fromStep, fromIndex, visibleSteps, setSteps);
471
- });
472
- case 24:
473
- _context.next = 27;
474
- break;
475
- case 26:
476
- (0, _utils.extendNextFn)(fromStep, fromIndex, visibleSteps, setSteps);
477
- case 27:
478
- _context.next = 30;
479
- break;
480
- case 29:
481
- if (enablenext && !fromStep.isValid) {
482
- console.warn("Cannot proceed: current step is invalid");
347
+ } else if (fromStep.isValid && eventName === "next") {
348
+ const response = (_b = fromStep.onNext) == null ? void 0 : _b.call(fromStep, fromStep, fromStep, fromIndex);
349
+ if (response !== void 0) {
350
+ await handleNavigation(
351
+ response,
352
+ () => extendNextFn(fromStep, fromIndex, visibleSteps, setSteps)
353
+ );
483
354
  } else {
484
- (0, _utils.extendNextFn)(fromStep, fromIndex, visibleSteps, setSteps);
355
+ extendNextFn(fromStep, fromIndex, visibleSteps, setSteps);
485
356
  }
486
- case 30:
487
- // update ref to reflect the logical next position immediately
488
- navIndexRef.current = nextIndex;
489
- setFormReady(false);
490
- case 32:
491
- case "end":
492
- return _context.stop();
357
+ } else if (enablenext && !fromStep.isValid) {
358
+ console.warn("Cannot proceed: current step is invalid");
359
+ } else {
360
+ extendNextFn(fromStep, fromIndex, visibleSteps, setSteps);
361
+ }
362
+ navIndexRef.current = nextIndex;
363
+ setFormReady(false);
364
+ },
365
+ [currentStepIndex, visibleSteps, enablenext]
366
+ );
367
+ const prev = useCallback(async () => {
368
+ var _a;
369
+ const fromIndex = navIndexRef.current >= 0 ? navIndexRef.current : currentStepIndex;
370
+ const fromStep = getStepByIndex(fromIndex, visibleSteps);
371
+ if (!fromStep) return;
372
+ const targetStep = getPrevValidStep(fromIndex - 1, visibleSteps);
373
+ if (!targetStep) return;
374
+ const prevIndex = visibleSteps.findIndex((s) => s.name === targetStep.name);
375
+ const response = (_a = fromStep.onPrev) == null ? void 0 : _a.call(fromStep, fromStep, fromStep, fromIndex);
376
+ if (response !== void 0) {
377
+ await handleNavigation(
378
+ response,
379
+ () => extendPrevFn(fromStep, fromIndex, visibleSteps, setSteps)
380
+ );
381
+ } else {
382
+ extendPrevFn(fromStep, fromIndex, visibleSteps, setSteps);
493
383
  }
494
- }, _callee);
495
- })), [currentStepIndex, visibleSteps, enablenext]);
496
- var prev = (0, _react.useCallback)(/*#__PURE__*/(0, _asyncToGenerator2["default"])(/*#__PURE__*/_regenerator["default"].mark(function _callee2() {
497
- var _fromStep$onPrev;
498
- var fromIndex, fromStep, targetStep, prevIndex, response;
499
- return _regenerator["default"].wrap(function _callee2$(_context2) {
500
- while (1) switch (_context2.prev = _context2.next) {
501
- case 0:
502
- fromIndex = navIndexRef.current >= 0 ? navIndexRef.current : currentStepIndex;
503
- fromStep = (0, _utils.getStepByIndex)(fromIndex, visibleSteps);
504
- if (fromStep) {
505
- _context2.next = 4;
506
- break;
507
- }
508
- return _context2.abrupt("return");
509
- case 4:
510
- targetStep = (0, _utils.getPrevValidStep)(fromIndex - 1, visibleSteps);
511
- if (targetStep) {
512
- _context2.next = 7;
513
- break;
514
- }
515
- return _context2.abrupt("return");
516
- case 7:
517
- prevIndex = visibleSteps.findIndex(function (s) {
518
- return s.name === targetStep.name;
519
- });
520
- response = (_fromStep$onPrev = fromStep.onPrev) === null || _fromStep$onPrev === void 0 ? void 0 : _fromStep$onPrev.call(fromStep, fromStep, fromStep, fromIndex);
521
- if (!(response !== undefined)) {
522
- _context2.next = 14;
523
- break;
384
+ navIndexRef.current = prevIndex;
385
+ setFormReady(false);
386
+ }, [currentStepIndex, visibleSteps]);
387
+ const registerStep = useCallback((stepData) => {
388
+ setSteps((prevSteps) => {
389
+ const existingIndex = prevSteps.findIndex((step) => step.name === stepData.name);
390
+ if (existingIndex >= 0) {
391
+ const existing = prevSteps[existingIndex];
392
+ const hasChanges = Object.keys(stepData).some(
393
+ (key) => existing[key] !== stepData[key]
394
+ );
395
+ if (hasChanges) {
396
+ const newSteps = [...prevSteps];
397
+ newSteps[existingIndex] = __spreadValues(__spreadValues({}, existing), stepData);
398
+ return newSteps;
524
399
  }
525
- _context2.next = 12;
526
- return (0, _utils.handleNavigation)(response, function () {
527
- return (0, _utils.extendPrevFn)(fromStep, fromIndex, visibleSteps, setSteps);
528
- });
529
- case 12:
530
- _context2.next = 15;
531
- break;
532
- case 14:
533
- (0, _utils.extendPrevFn)(fromStep, fromIndex, visibleSteps, setSteps);
534
- case 15:
535
- navIndexRef.current = prevIndex;
536
- setFormReady(false);
537
- case 17:
538
- case "end":
539
- return _context2.stop();
540
- }
541
- }, _callee2);
542
- })), [currentStepIndex, visibleSteps]);
543
- var registerStep = (0, _react.useCallback)(function (stepData) {
544
- setSteps(function (prevSteps) {
545
- var existingIndex = prevSteps.findIndex(function (step) {
546
- return step.name === stepData.name;
400
+ return prevSteps;
401
+ }
402
+ return [...prevSteps, stepData];
547
403
  });
548
- if (existingIndex >= 0) {
549
- var existing = prevSteps[existingIndex];
550
- var hasChanges = Object.keys(stepData).some(function (key) {
551
- return existing[key] !== stepData[key];
552
- });
553
- if (hasChanges) {
554
- var newSteps = (0, _toConsumableArray2["default"])(prevSteps);
555
- newSteps[existingIndex] = _objectSpread(_objectSpread({}, existing), stepData);
556
- return newSteps;
404
+ }, []);
405
+ const skip = useCallback(() => {
406
+ next("skip");
407
+ }, [next]);
408
+ const done = useCallback(() => {
409
+ if (currentStep) {
410
+ updateStep(currentStep.name, { isDone: true, done: true });
411
+ if (onDone) {
412
+ onDone(currentStep, steps);
557
413
  }
558
- return prevSteps;
559
414
  }
560
- return [].concat((0, _toConsumableArray2["default"])(prevSteps), [stepData]);
561
- });
562
- }, []);
563
- var _skip = (0, _react.useCallback)(function () {
564
- _next("skip");
565
- }, [_next]);
566
- var _done = (0, _react.useCallback)(function () {
567
- if (currentStep) {
568
- updateStep(currentStep.name, {
569
- isDone: true,
570
- done: true
571
- });
572
- if (onDone) {
573
- onDone(currentStep, steps);
415
+ }, [currentStep, updateStep, onDone, steps]);
416
+ const cancel = useCallback(() => {
417
+ if (onCancel) {
418
+ onCancel(currentStep, steps);
574
419
  }
575
- }
576
- }, [currentStep, updateStep, onDone, steps]);
577
- var _cancel = (0, _react.useCallback)(function () {
578
- if (onCancel) {
579
- onCancel(currentStep, steps);
580
- }
581
- }, [onCancel, steps]);
582
- var _gotoStep = (0, _react.useCallback)(function (step) {
583
- var _targetStep;
584
- var gotoStepIndex;
585
- var targetStep = null;
586
- if (typeof step === "string") {
587
- gotoStepIndex = steps.map(function (s) {
588
- return s.name;
589
- }).indexOf(step);
590
- if (gotoStepIndex === -1) {
591
- console.error("Could not find step '".concat(step, "'"));
592
- return;
420
+ }, [onCancel, steps]);
421
+ const gotoStep = useCallback(
422
+ (step) => {
423
+ let gotoStepIndex;
424
+ let targetStep = null;
425
+ if (typeof step === "string") {
426
+ gotoStepIndex = steps.map((s) => s.name).indexOf(step);
427
+ if (gotoStepIndex === -1) {
428
+ console.error(`Could not find step '${step}'`);
429
+ return;
430
+ }
431
+ targetStep = steps[gotoStepIndex];
432
+ } else if (typeof step === "number" && step >= 0) {
433
+ gotoStepIndex = step;
434
+ targetStep = getStepByIndex(step, visibleSteps);
435
+ } else {
436
+ console.error("Invalid step name or index provided");
437
+ return;
438
+ }
439
+ if (targetStep == null ? void 0 : targetStep.show) {
440
+ const visIndex = visibleSteps.findIndex((s) => s.name === (targetStep == null ? void 0 : targetStep.name));
441
+ if (visIndex >= 0) navIndexRef.current = visIndex;
442
+ onStepHeaderClick({}, targetStep);
443
+ } else {
444
+ console.error("The gotoStep function cannot navigate to hidden steps");
445
+ }
446
+ },
447
+ [steps, visibleSteps, onStepHeaderClick]
448
+ );
449
+ const setDefaultStep = useCallback(
450
+ (step) => {
451
+ if (step && step.show) {
452
+ setSteps(
453
+ (prevSteps) => prevSteps.map((s, index) => {
454
+ const stepIndex = prevSteps.findIndex((ps) => ps.name === s.name);
455
+ const defaultIndex = prevSteps.findIndex((ps) => ps.name === step.name);
456
+ return __spreadProps(__spreadValues({}, s), {
457
+ active: s.name === step.name,
458
+ isDone: false,
459
+ done: stepIndex < defaultIndex,
460
+ isInitialized: s.name === step.name ? true : s.isInitialized,
461
+ // Ensure enableNext and isValid are preserved for the active step
462
+ enableNext: s.name === step.name ? true : s.enableNext,
463
+ isValid: s.name === step.name ? true : s.isValid
464
+ });
465
+ })
466
+ );
467
+ setTimeout(() => {
468
+ if (step.onLoad) {
469
+ const stepIndex = visibleSteps.findIndex((s) => s.name === step.name);
470
+ step.onLoad(step, stepIndex);
471
+ }
472
+ }, 100);
473
+ } else {
474
+ const nextValidStep = getNextValidStep(0, visibleSteps);
475
+ if (nextValidStep) {
476
+ setDefaultStep(nextValidStep);
477
+ }
478
+ }
479
+ },
480
+ [visibleSteps]
481
+ );
482
+ const showSignature = steps.map(
483
+ (s) => {
484
+ var _a, _b, _c, _d;
485
+ return ((_b = (_a = listener == null ? void 0 : listener.Widgets) == null ? void 0 : _a[s.name]) == null ? void 0 : _b.show) === false || ((_d = (_c = listener == null ? void 0 : listener.Widgets) == null ? void 0 : _c[s.name]) == null ? void 0 : _d.show) === "false" ? "0" : "1";
593
486
  }
594
- targetStep = steps[gotoStepIndex];
595
- } else if (typeof step === "number" && step >= 0) {
596
- gotoStepIndex = step;
597
- targetStep = (0, _utils.getStepByIndex)(step, visibleSteps);
598
- } else {
599
- console.error("Invalid step name or index provided");
600
- return;
601
- }
602
- if ((_targetStep = targetStep) !== null && _targetStep !== void 0 && _targetStep.show) {
603
- var visIndex = visibleSteps.findIndex(function (s) {
604
- var _targetStep2;
605
- return s.name === ((_targetStep2 = targetStep) === null || _targetStep2 === void 0 ? void 0 : _targetStep2.name);
487
+ ).join("|");
488
+ useEffect(() => {
489
+ if (!(listener == null ? void 0 : listener.Widgets)) return;
490
+ steps.forEach((step, index) => {
491
+ var _a;
492
+ const widgetShow = (_a = listener.Widgets[step.name]) == null ? void 0 : _a.show;
493
+ if ((widgetShow === false || widgetShow === "false") && step.show !== false) {
494
+ updateStep(step.name, { show: false, enableskip: false });
495
+ const prevStep = steps[index - 1];
496
+ if (prevStep && step.active) {
497
+ updateStep(prevStep.name, { active: true });
498
+ navIndexRef.current = index - 1;
499
+ }
500
+ }
606
501
  });
607
- if (visIndex >= 0) navIndexRef.current = visIndex;
608
- onStepHeaderClick({}, targetStep);
609
- } else {
610
- console.error("The gotoStep function cannot navigate to hidden steps");
611
- }
612
- }, [steps, visibleSteps, onStepHeaderClick]);
613
-
614
- // Initialize default step
615
- var setDefaultStep = (0, _react.useCallback)(function (step) {
616
- if (step && step.show) {
617
- setSteps(function (prevSteps) {
618
- return prevSteps.map(function (s, index) {
619
- var stepIndex = prevSteps.findIndex(function (ps) {
620
- return ps.name === s.name;
621
- });
622
- var defaultIndex = prevSteps.findIndex(function (ps) {
623
- return ps.name === step.name;
624
- });
625
- return _objectSpread(_objectSpread({}, s), {}, {
626
- active: s.name === step.name,
627
- isDone: false,
628
- done: stepIndex < defaultIndex,
629
- isInitialized: s.name === step.name ? true : s.isInitialized,
630
- // Ensure enableNext and isValid are preserved for the active step
631
- enableNext: s.name === step.name ? true : s.enableNext,
632
- isValid: s.name === step.name ? true : s.isValid
633
- });
502
+ }, [showSignature]);
503
+ const updateListener = React.useCallback(() => {
504
+ if (listener && typeof listener.onChange === "function") {
505
+ listener.onChange(name, {
506
+ hasNextStep: () => hasNextStep,
507
+ hasPreviousStep: () => hasPrevStep,
508
+ hasNoNextStep: () => showDoneBtn,
509
+ next: () => next("next"),
510
+ previous: () => prev(),
511
+ done: () => done(),
512
+ cancel: () => cancel(),
513
+ skip: () => skip(),
514
+ disableNext: () => !enableNext,
515
+ disablePrevious: () => !enablePrev,
516
+ disableDone: () => !enableDone,
517
+ prev,
518
+ cancelable,
519
+ nextbtnlabel,
520
+ previousbtnlabel,
521
+ donebtnlabel,
522
+ cancelbtnlabel,
523
+ actionsalignment,
524
+ skippable: currentStep == null ? void 0 : currentStep.enableskip,
525
+ getCurrentStepIndex: () => currentStepIndex,
526
+ gotoStep: (step) => gotoStep(step),
527
+ isFirstStep,
528
+ isLastStep,
529
+ currentStepIndex,
530
+ currentStep
634
531
  });
635
- });
636
- setTimeout(function () {
637
- if (step.onLoad) {
638
- var stepIndex = visibleSteps.findIndex(function (s) {
639
- return s.name === step.name;
640
- });
641
- step.onLoad(step, stepIndex);
642
- }
643
- }, 100);
644
- } else {
645
- var nextValidStep = (0, _utils.getNextValidStep)(0, visibleSteps);
646
- if (nextValidStep) {
647
- setDefaultStep(nextValidStep);
648
532
  }
649
- }
650
- }, [visibleSteps]);
651
- var showSignature = steps.map(function (s) {
652
- var _listener$Widgets, _listener$Widgets2;
653
- return (listener === null || listener === void 0 || (_listener$Widgets = listener.Widgets) === null || _listener$Widgets === void 0 || (_listener$Widgets = _listener$Widgets[s.name]) === null || _listener$Widgets === void 0 ? void 0 : _listener$Widgets.show) === false || (listener === null || listener === void 0 || (_listener$Widgets2 = listener.Widgets) === null || _listener$Widgets2 === void 0 || (_listener$Widgets2 = _listener$Widgets2[s.name]) === null || _listener$Widgets2 === void 0 ? void 0 : _listener$Widgets2.show) === "false" ? "0" : "1";
654
- }).join("|");
655
- (0, _react.useEffect)(function () {
656
- if (!(listener !== null && listener !== void 0 && listener.Widgets)) return;
657
- steps.forEach(function (step, index) {
658
- var _listener$Widgets$ste;
659
- var widgetShow = (_listener$Widgets$ste = listener.Widgets[step.name]) === null || _listener$Widgets$ste === void 0 ? void 0 : _listener$Widgets$ste.show;
660
- if ((widgetShow === false || widgetShow === "false") && step.show !== false) {
661
- updateStep(step.name, {
662
- show: false,
663
- enableskip: false
664
- });
665
- var prevStep = steps[index - 1];
666
- if (prevStep && step.active) {
667
- updateStep(prevStep.name, {
668
- active: true
669
- });
670
- navIndexRef.current = index - 1;
533
+ }, [
534
+ hasNextStep,
535
+ hasPrevStep,
536
+ showDoneBtn,
537
+ enableNext,
538
+ enablePrev,
539
+ enableDone,
540
+ cancelable,
541
+ currentStep == null ? void 0 : currentStep.enableskip,
542
+ nextbtnlabel,
543
+ previousbtnlabel,
544
+ donebtnlabel,
545
+ cancelbtnlabel,
546
+ actionsalignment,
547
+ currentStepIndex,
548
+ isFirstStep,
549
+ isLastStep,
550
+ visibleSteps
551
+ ]);
552
+ useEffect(() => {
553
+ updateListener();
554
+ }, [updateListener]);
555
+ useEffect(() => {
556
+ if (steps.length > 0 && !isInitialized && visibleSteps.length > 0 && type !== "dynamic") {
557
+ let defaultStepRef = null;
558
+ if (defaultstep !== "none") {
559
+ defaultStepRef = getStepByName(defaultstep, steps);
560
+ } else if (defaultstepindex >= 0 && defaultstepindex < visibleSteps.length) {
561
+ defaultStepRef = getStepByIndex(defaultstepindex, visibleSteps);
562
+ } else {
563
+ defaultStepRef = getNextValidStep(0, visibleSteps);
564
+ }
565
+ if (defaultStepRef) {
566
+ setDefaultStep(defaultStepRef);
567
+ setIsInitialized(true);
671
568
  }
672
569
  }
673
- });
674
- }, [showSignature]);
675
- var updateListener = _react["default"].useCallback(function () {
676
- if (listener && typeof listener.onChange === "function") {
677
- listener.onChange(name, {
678
- hasNextStep: function hasNextStep() {
679
- return _hasNextStep;
680
- },
681
- hasPreviousStep: function hasPreviousStep() {
682
- return hasPrevStep;
683
- },
684
- hasNoNextStep: function hasNoNextStep() {
685
- return showDoneBtn;
686
- },
687
- next: function next() {
688
- return _next("next");
689
- },
690
- previous: function previous() {
691
- return prev();
692
- },
693
- done: function done() {
694
- return _done();
695
- },
696
- cancel: function cancel() {
697
- return _cancel();
698
- },
699
- skip: function skip() {
700
- return _skip();
701
- },
702
- disableNext: function disableNext() {
703
- return !enableNext;
704
- },
705
- disablePrevious: function disablePrevious() {
706
- return !enablePrev;
707
- },
708
- disableDone: function disableDone() {
709
- return !enableDone;
710
- },
711
- prev: prev,
712
- cancelable: cancelable,
713
- nextbtnlabel: nextbtnlabel,
714
- previousbtnlabel: previousbtnlabel,
715
- donebtnlabel: donebtnlabel,
716
- cancelbtnlabel: cancelbtnlabel,
717
- actionsalignment: actionsalignment,
718
- skippable: currentStep === null || currentStep === void 0 ? void 0 : currentStep.enableskip,
719
- getCurrentStepIndex: function getCurrentStepIndex() {
720
- return currentStepIndex;
721
- },
722
- gotoStep: function gotoStep(step) {
723
- return _gotoStep(step);
724
- },
725
- isFirstStep: isFirstStep,
726
- isLastStep: isLastStep,
727
- currentStepIndex: currentStepIndex,
728
- currentStep: currentStep
729
- });
730
- }
731
- }, [_hasNextStep, hasPrevStep, showDoneBtn, enableNext, enablePrev, enableDone, cancelable, currentStep === null || currentStep === void 0 ? void 0 : currentStep.enableskip, nextbtnlabel, previousbtnlabel, donebtnlabel, cancelbtnlabel, actionsalignment, currentStepIndex, isFirstStep, isLastStep, visibleSteps]);
732
- (0, _react.useEffect)(function () {
733
- updateListener();
734
- }, [updateListener]);
735
-
736
- // Initialize default step for STATIC wizards only
737
- (0, _react.useEffect)(function () {
738
- if (steps.length > 0 && !isInitialized && visibleSteps.length > 0 && type !== "dynamic") {
739
- var defaultStepRef = null;
740
- if (defaultstep !== "none") {
741
- defaultStepRef = (0, _utils.getStepByName)(defaultstep, steps);
742
- } else if (defaultstepindex >= 0 && defaultstepindex < visibleSteps.length) {
743
- // CHANGED: Removed type === "dynamic" check and added bounds checking
744
- // REASON: This effect only runs for static wizards, and bounds checking prevents runtime errors
745
- defaultStepRef = (0, _utils.getStepByIndex)(defaultstepindex, visibleSteps);
746
- } else {
747
- defaultStepRef = (0, _utils.getNextValidStep)(0, visibleSteps);
748
- }
749
- if (defaultStepRef) {
750
- setDefaultStep(defaultStepRef);
751
- setIsInitialized(true);
570
+ }, [
571
+ steps.length,
572
+ visibleSteps.length,
573
+ defaultstep,
574
+ defaultstepindex,
575
+ type,
576
+ isInitialized,
577
+ setDefaultStep,
578
+ visibleSteps
579
+ ]);
580
+ useEffect(() => {
581
+ if (currentStep == null ? void 0 : currentStep.onLoad) {
582
+ currentStep == null ? void 0 : currentStep.onLoad(currentStep, currentStepIndex);
752
583
  }
753
- }
754
- }, [steps.length, visibleSteps.length, defaultstep, defaultstepindex, type, isInitialized, setDefaultStep, visibleSteps]);
755
- (0, _react.useEffect)(function () {
756
- if (currentStep !== null && currentStep !== void 0 && currentStep.onLoad) {
757
- currentStep === null || currentStep === void 0 || currentStep.onLoad(currentStep, currentStepIndex);
758
- }
759
- }, [currentStep === null || currentStep === void 0 ? void 0 : currentStep.onLoad]);
760
-
761
- // Handle dataset changes for dynamic wizard
762
- (0, _react.useEffect)(function () {
763
- if (type === "dynamic" && dataset.length > 0 && steps.length === 0) {
764
- var dynamicSteps = createDynamicSteps(dataset);
765
- if (defaultstepindex >= 0 && defaultstepindex < dynamicSteps.length) {
766
- var defaultStep = dynamicSteps[defaultstepindex];
767
- if (defaultStep && defaultStep.show) {
768
- var stepsWithDefault = dynamicSteps.map(function (step) {
769
- return _objectSpread(_objectSpread({}, step), {}, {
584
+ }, [currentStep == null ? void 0 : currentStep.onLoad]);
585
+ useEffect(() => {
586
+ if (type === "dynamic" && dataset.length > 0 && steps.length === 0) {
587
+ const dynamicSteps = createDynamicSteps(dataset);
588
+ if (defaultstepindex >= 0 && defaultstepindex < dynamicSteps.length) {
589
+ const defaultStep = dynamicSteps[defaultstepindex];
590
+ if (defaultStep && defaultStep.show) {
591
+ const stepsWithDefault = dynamicSteps.map((step) => __spreadProps(__spreadValues({}, step), {
770
592
  active: step.name === defaultStep.name,
771
593
  isDone: false,
772
- done: step.dynamicStepIndex !== undefined ? step.dynamicStepIndex < defaultstepindex : false
773
- });
774
- });
775
- setSteps(stepsWithDefault);
776
- setIsInitialized(true); // CHANGED: Mark as initialized immediately
594
+ done: step.dynamicStepIndex !== void 0 ? step.dynamicStepIndex < defaultstepindex : false
595
+ }));
596
+ setSteps(stepsWithDefault);
597
+ setIsInitialized(true);
598
+ } else {
599
+ setSteps(dynamicSteps);
600
+ }
777
601
  } else {
778
602
  setSteps(dynamicSteps);
779
603
  }
780
- } else {
781
- setSteps(dynamicSteps);
782
- }
783
- return;
784
- }
785
- if (type === "dynamic" && dataset.length > 0) {
786
- // Append new steps if dataset grew
787
- if (steps.length > 0 && dataset.length > steps.length) {
788
- var newItems = dataset.slice(steps.length);
789
- var newSteps = createDynamicSteps(newItems, steps.length);
790
- if (newSteps.length) {
791
- setSteps(function (prev) {
792
- return (0, _utils.appendDatasetSteps)(prev, newSteps);
793
- });
794
- }
795
604
  return;
796
605
  }
797
- // Remove steps if dataset shrank
798
- if (steps.length > 0 && dataset.length < steps.length) {
799
- setSteps(function (prev) {
800
- return (0, _utils.trimStepsToLength)(prev, dataset.length);
801
- });
802
- return;
606
+ if (type === "dynamic" && dataset.length > 0) {
607
+ if (steps.length > 0 && dataset.length > steps.length) {
608
+ const newItems = dataset.slice(steps.length);
609
+ const newSteps = createDynamicSteps(newItems, steps.length);
610
+ if (newSteps.length) {
611
+ setSteps((prev2) => appendDatasetSteps(prev2, newSteps));
612
+ }
613
+ return;
614
+ }
615
+ if (steps.length > 0 && dataset.length < steps.length) {
616
+ setSteps((prev2) => trimStepsToLength(prev2, dataset.length));
617
+ return;
618
+ }
803
619
  }
804
- }
805
- }, [type, dataset, createDynamicSteps, defaultstepindex, dataset.length]);
806
-
807
- // Context value
808
- var contextValue = (0, _react.useMemo)(function () {
809
- return {
810
- steps: steps,
811
- currentStep: currentStep,
812
- currentStepIndex: currentStepIndex,
813
- hasNextStep: _hasNextStep,
814
- hasPrevStep: hasPrevStep,
815
- showDoneBtn: showDoneBtn || false,
816
- enableNext: enableNext || false,
817
- enablePrev: enablePrev || false,
818
- enableDone: enableDone || false,
819
- isFirstStep: isFirstStep,
820
- isLastStep: isLastStep,
821
- registerStep: registerStep,
822
- updateStep: updateStep,
823
- next: _next,
824
- prev: prev,
825
- skip: _skip,
826
- done: _done,
827
- cancel: _cancel,
828
- gotoStep: _gotoStep,
829
- onStepHeaderClick: onStepHeaderClick,
830
- addStep: function addStep() {
831
- return [];
620
+ }, [type, dataset, createDynamicSteps, defaultstepindex, dataset.length]);
621
+ const contextValue = useMemo(
622
+ () => ({
623
+ steps,
624
+ currentStep,
625
+ currentStepIndex,
626
+ hasNextStep,
627
+ hasPrevStep,
628
+ showDoneBtn: showDoneBtn || false,
629
+ enableNext: enableNext || false,
630
+ enablePrev: enablePrev || false,
631
+ enableDone: enableDone || false,
632
+ isFirstStep,
633
+ isLastStep,
634
+ registerStep,
635
+ updateStep,
636
+ next,
637
+ prev,
638
+ skip,
639
+ done,
640
+ cancel,
641
+ gotoStep,
642
+ onStepHeaderClick,
643
+ addStep: () => []
644
+ }),
645
+ [
646
+ steps,
647
+ currentStep,
648
+ currentStepIndex,
649
+ hasNextStep,
650
+ hasPrevStep,
651
+ showDoneBtn,
652
+ enableNext,
653
+ enablePrev,
654
+ enableDone,
655
+ isFirstStep,
656
+ isLastStep,
657
+ registerStep,
658
+ updateStep,
659
+ next,
660
+ prev,
661
+ skip,
662
+ done,
663
+ cancel,
664
+ gotoStep,
665
+ onStepHeaderClick
666
+ ]
667
+ );
668
+ const wizardSteps = [];
669
+ React.Children.forEach(children, (child) => {
670
+ if (isValidElement(child) && child.type === WmWizardstep) {
671
+ wizardSteps.push(child);
832
672
  }
833
- };
834
- }, [steps, currentStep, currentStepIndex, _hasNextStep, hasPrevStep, showDoneBtn, enableNext, enablePrev, enableDone, isFirstStep, isLastStep, registerStep, updateStep, _next, prev, _skip, _done, _cancel, _gotoStep, onStepHeaderClick]);
835
-
836
- // Extract wizard steps from children
837
- var wizardSteps = [];
838
- _react["default"].Children.forEach(children, function (child) {
839
- if (/*#__PURE__*/(0, _react.isValidElement)(child) && child.type === _wizardStep.WmWizardstep) {
840
- wizardSteps.push(child);
841
- }
842
- });
843
-
844
- // If no data in dynamic mode, show no data message
845
- if (type === "dynamic" && (!dataset || dataset.length === 0)) {
846
- return __jsx("div", null, nodatamessage);
847
- }
848
- var classValue = className && className.trim() !== "" ? className : "classic";
849
- return __jsx(_WizardContext["default"].Provider, {
850
- value: contextValue
851
- }, __jsx(_material.Box, {
852
- className: (0, _clsx["default"])(DEFAULT_CLS, classValue, computedStepClass, {
853
- classic: classValue === null || classValue === void 0 ? void 0 : classValue.includes("classic"),
854
- number: classValue === null || classValue === void 0 ? void 0 : classValue.includes("number"),
855
- dottedstepper: classValue === null || classValue === void 0 ? void 0 : classValue.includes("dottedstepper"),
856
- "text-inline": classValue === null || classValue === void 0 ? void 0 : classValue.includes("text-inline"),
857
- iconstepper: classValue === null || classValue === void 0 ? void 0 : classValue.includes("iconstepper")
858
- }),
859
- style: _objectSpread(_objectSpread({}, styles), {}, {
860
- width: width,
861
- height: height
862
- }),
863
- hidden: props.hidden,
864
- name: name
865
- }, __jsx(_material.Box, {
866
- className: "app-wizard-heading"
867
- }, __jsx(_material.Stepper, {
868
- activeStep: currentStepIndex,
869
- orientation: orientation,
870
- alternativeLabel: alternativeLabel,
871
- nonLinear: nonLinear,
872
- connector: connector,
873
- className: (0, _clsx["default"])("app-wizard-steps", computedStepClass, stepstyle === "justified" ? "nav-justified" : "")
874
- }, steps.map(function (step, index) {
875
- // Calculate the visible index by counting only visible steps before this one
876
- var visibleIndex = steps.slice(0, index).filter(function (s) {
877
- return s.show !== false && s.show !== "false";
878
- }).length;
879
- var isCurrentStep = currentStepIndex === visibleIndex && step.show !== false && step.show !== "false";
880
- return __jsx(_WizardStep.WizardStep, {
881
- key: step.name,
882
- step: step,
883
- index: index,
884
- className: classValue,
885
- nonLinear: nonLinear,
886
- orientation: orientation,
887
- onStepClick: handleStepClick,
888
- current: isCurrentStep
889
673
  });
890
- }))), (orientation === "horizontal" || type === "dynamic") && __jsx(_material.Box, {
891
- className: BODY_CLASS
892
- }, wizardMessage.caption && __jsx(_material.Box, {
893
- component: "p"
894
- }, __jsx(_material.Typography, {
895
- variant: "body2",
896
- color: wizardMessage.type === "error" ? "error" : "textSecondary"
897
- }, wizardMessage.caption)), steps.map(function (step, index) {
898
- return __jsx("div", {
899
- key: step.name,
900
- ref: function ref(el) {
901
- if (el) {
902
- // Store the step container element for event delegation
903
- stepContainerRefs.current[step.name] = el;
904
- // Get all forms inside the step (handles lists with multiple forms)
905
- var formElements = el.querySelectorAll("form");
906
- if (formElements.length > 0) {
907
- // Store as array if multiple forms, single element if one form
908
- formRefs.current[step.name] = formElements.length === 1 ? formElements[0] : Array.from(formElements);
909
- if (formElements[0].classList.contains("app-form")) {
910
- setFormReady(true);
674
+ if (type === "dynamic" && (!dataset || dataset.length === 0)) {
675
+ return /* @__PURE__ */ jsx("div", { children: nodatamessage });
676
+ }
677
+ const classValue = className && className.trim() !== "" ? className : "classic";
678
+ return /* @__PURE__ */ jsx(WizardContext.Provider, { value: contextValue, children: /* @__PURE__ */ jsxs(
679
+ Box,
680
+ __spreadProps(__spreadValues({
681
+ className: clsx(DEFAULT_CLS, classValue, computedStepClass, {
682
+ classic: classValue == null ? void 0 : classValue.includes("classic"),
683
+ number: classValue == null ? void 0 : classValue.includes("number"),
684
+ dottedstepper: classValue == null ? void 0 : classValue.includes("dottedstepper"),
685
+ "text-inline": classValue == null ? void 0 : classValue.includes("text-inline"),
686
+ iconstepper: classValue == null ? void 0 : classValue.includes("iconstepper")
687
+ }),
688
+ style: __spreadProps(__spreadValues({}, styles), { width, height }),
689
+ hidden: props.hidden
690
+ }, { name }), {
691
+ children: [
692
+ /* @__PURE__ */ jsx(Box, { className: "app-wizard-heading", children: /* @__PURE__ */ jsx(
693
+ Stepper,
694
+ {
695
+ activeStep: currentStepIndex,
696
+ orientation,
697
+ alternativeLabel,
698
+ nonLinear,
699
+ connector,
700
+ className: clsx(
701
+ "app-wizard-steps",
702
+ computedStepClass,
703
+ stepstyle === "justified" ? "nav-justified" : ""
704
+ ),
705
+ children: steps.map((step, index) => {
706
+ const visibleIndex = steps.slice(0, index).filter((s) => s.show !== false && s.show !== "false").length;
707
+ const isCurrentStep = currentStepIndex === visibleIndex && step.show !== false && step.show !== "false";
708
+ return /* @__PURE__ */ jsx(
709
+ WizardStep,
710
+ {
711
+ step,
712
+ index,
713
+ className: classValue,
714
+ nonLinear,
715
+ orientation,
716
+ onStepClick: handleStepClick,
717
+ current: isCurrentStep
718
+ },
719
+ step.name
720
+ );
721
+ })
911
722
  }
912
- }
913
- }
914
- },
915
- className: (0, _clsx["default"])("app-wizard-step-container", {
916
- active: step.active
917
- }),
918
- hidden: !step.active,
919
- name: step.name
920
- }, isInsideOuterForm ?
921
- // Inside outer form - use div, fields/forms pass through to outer form context
922
- __jsx("div", {
923
- className: (0, _clsx["default"])("app-wizard-step-content", {
924
- active: step.active
723
+ ) }),
724
+ (orientation === "horizontal" || type === "dynamic") && /* @__PURE__ */ jsxs(Box, { className: BODY_CLASS, children: [
725
+ wizardMessage.caption && /* @__PURE__ */ jsx(Box, { component: "p", children: /* @__PURE__ */ jsx(
726
+ Typography,
727
+ {
728
+ variant: "body2",
729
+ color: wizardMessage.type === "error" ? "error" : "textSecondary",
730
+ children: wizardMessage.caption
731
+ }
732
+ ) }),
733
+ steps.map((step, index) => /* @__PURE__ */ jsx(
734
+ "div",
735
+ {
736
+ ref: (el) => {
737
+ if (el) {
738
+ stepContainerRefs.current[step.name] = el;
739
+ const formElements = el.querySelectorAll("form");
740
+ if (formElements.length > 0) {
741
+ formRefs.current[step.name] = formElements.length === 1 ? formElements[0] : Array.from(formElements);
742
+ if (formElements[0].classList.contains("app-form")) {
743
+ setFormReady(true);
744
+ }
745
+ }
746
+ }
747
+ },
748
+ className: clsx("app-wizard-step-container", {
749
+ active: step.active
750
+ }),
751
+ hidden: !step.active,
752
+ name: step.name,
753
+ children: isInsideOuterForm ? (
754
+ // Inside outer form - use div, fields/forms pass through to outer form context
755
+ /* @__PURE__ */ jsx(
756
+ "div",
757
+ {
758
+ className: clsx("app-wizard-step-content", {
759
+ active: step.active
760
+ }),
761
+ children: (currentStep == null ? void 0 : currentStep.name) && step.active && currentStep.render ? currentStep.render(step, index) : step.children
762
+ }
763
+ )
764
+ ) : (
765
+ // @ts-ignore Standalone wizard without inner form - wizard provides form context
766
+ /* @__PURE__ */ jsx(
767
+ WmForm,
768
+ {
769
+ standalone,
770
+ show: step.active,
771
+ name: step.name + `_form`,
772
+ className: clsx("app-wizard-step-content", {
773
+ active: step.active
774
+ }),
775
+ listener,
776
+ isInsideWizard: true,
777
+ children: (currentStep == null ? void 0 : currentStep.name) && step.active && currentStep.render ? currentStep.render(step, index) : step.children
778
+ }
779
+ )
780
+ )
781
+ },
782
+ step.name
783
+ ))
784
+ ] }),
785
+ children,
786
+ type === "static" && wizardSteps.map(
787
+ (step, index) => {
788
+ var _a;
789
+ return cloneElement(step, {
790
+ key: ((_a = step.props) == null ? void 0 : _a.name) || index
791
+ });
792
+ }
793
+ )
794
+ ]
925
795
  })
926
- }, currentStep !== null && currentStep !== void 0 && currentStep.name && step.active && currentStep.render ? currentStep.render(step, index) : step.children) :
927
- // @ts-ignore Standalone wizard without inner form - wizard provides form context
928
- __jsx(_form["default"], {
929
- standalone: standalone,
930
- show: step.active,
931
- name: step.name + "_form",
932
- className: (0, _clsx["default"])("app-wizard-step-content", {
933
- active: step.active
934
- }),
935
- listener: listener,
936
- isInsideWizard: true
937
- }, currentStep !== null && currentStep !== void 0 && currentStep.name && step.active && currentStep.render ? currentStep.render(step, index) : step.children));
938
- })), children, type === "static" && wizardSteps.map(function (step, index) {
939
- var _step$props;
940
- return /*#__PURE__*/(0, _react.cloneElement)(step, {
941
- key: ((_step$props = step.props) === null || _step$props === void 0 ? void 0 : _step$props.name) || index
796
+ ) });
797
+ },
798
+ (prev, next) => {
799
+ const keys = [
800
+ "render",
801
+ "dataset",
802
+ "className",
803
+ "styles",
804
+ "width",
805
+ "height",
806
+ "type",
807
+ "stepstyle",
808
+ "orientation",
809
+ "alternativeLabel",
810
+ "nonLinear",
811
+ "defaultstep",
812
+ "defaultstepindex",
813
+ "message",
814
+ "cancelable",
815
+ "enablenext",
816
+ "nextbtnlabel",
817
+ "previousbtnlabel",
818
+ "donebtnlabel",
819
+ "cancelbtnlabel",
820
+ "children",
821
+ "hidden"
822
+ ];
823
+ return keys.every((key) => {
824
+ if (key === "children") {
825
+ return prev[key] === next[key];
826
+ }
827
+ return isEqual(prev[key], next[key]);
942
828
  });
943
- })));
944
- }, function (prev, next) {
945
- var keys = ["render", "dataset", "className", "styles", "width", "height", "type", "stepstyle", "orientation", "alternativeLabel", "nonLinear", "defaultstep", "defaultstepindex", "message", "cancelable", "enablenext", "nextbtnlabel", "previousbtnlabel", "donebtnlabel", "cancelbtnlabel", "children", "hidden"];
946
- return keys.every(function (key) {
947
- // Never deep-compare children; treat as referential
948
- if (key === "children") {
949
- return prev[key] === next[key];
950
- }
951
- return (0, _isEqual["default"])(prev[key], next[key]);
952
- });
953
- });
954
- var WmWizardStandalone = exports.WmWizard = (0, _withStandalone["default"])(WmWizard);
829
+ }
830
+ );
831
+ const WmWizardStandalone = withStandalone(WmWizard);
955
832
  WmWizard.displayName = "WmWizard";
956
-
957
- /**
958
- * The WmWizard component renders a multi-step wizard flow with navigation,
959
- * validation, and configurable step content.
960
- *
961
- * - [Playground](https://react-components.wavemaker.ai/?path=/story/containers-wizard--showcase)
962
- *
963
- * - [Docs](https://react-components.wavemaker.ai/?path=/story/containers-wizard--docs)
964
- *
965
- * @param props - {@link WmWizardProps}
966
- */
967
- var _default = exports["default"] = (0, _withBaseWrapper.withBaseWrapper)(WmWizard);
833
+ var wizard_default = withBaseWrapper(WmWizard);
834
+ export {
835
+ WmWizardStandalone as WmWizard,
836
+ wizard_default as default
837
+ };