@wavemaker/react-runtime 11.14.1-rc.236

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 (402) hide show
  1. package/actions/base-action.js +32 -0
  2. package/actions/login-action.js +53 -0
  3. package/actions/logout-action.js +41 -0
  4. package/actions/navigation-action.js +145 -0
  5. package/actions/notification-action.js +147 -0
  6. package/actions/timer-action.js +164 -0
  7. package/actions/toast-provider.js +111 -0
  8. package/actions/toast.js +115 -0
  9. package/actions/toast.service.js +94 -0
  10. package/actions/types/index.js +11 -0
  11. package/components/advanced/carousel/index.js +456 -0
  12. package/components/advanced/carousel/props.js +5 -0
  13. package/components/advanced/carousel/template.js +72 -0
  14. package/components/advanced/login/index.js +307 -0
  15. package/components/advanced/login/props.js +5 -0
  16. package/components/advanced/marquee/index.js +158 -0
  17. package/components/advanced/marquee/props.js +5 -0
  18. package/components/basic/anchor/index.js +239 -0
  19. package/components/basic/anchor/props.js +5 -0
  20. package/components/basic/audio/index.js +61 -0
  21. package/components/basic/html/index.js +158 -0
  22. package/components/basic/icon/index.js +85 -0
  23. package/components/basic/iframe/iframe.utils.js +10 -0
  24. package/components/basic/iframe/index.js +95 -0
  25. package/components/basic/label/index.js +139 -0
  26. package/components/basic/message/index.js +120 -0
  27. package/components/basic/message/props.js +5 -0
  28. package/components/basic/picture/index.js +117 -0
  29. package/components/basic/picture/props.js +5 -0
  30. package/components/basic/progress-bar/index.js +168 -0
  31. package/components/basic/progress-bar/props.js +18 -0
  32. package/components/basic/progress-circle/index.js +196 -0
  33. package/components/basic/progress-circle/props.js +16 -0
  34. package/components/basic/richtexteditor/index.js +533 -0
  35. package/components/basic/richtexteditor/props.js +5 -0
  36. package/components/basic/search/index.js +1023 -0
  37. package/components/basic/search/props.js +5 -0
  38. package/components/basic/search/providers.js +350 -0
  39. package/components/basic/spinner/index.js +202 -0
  40. package/components/basic/spinner/props.js +12 -0
  41. package/components/basic/tile/index.js +91 -0
  42. package/components/basic/tree/Components/TreeNodeComponent.js +142 -0
  43. package/components/basic/tree/index.js +503 -0
  44. package/components/basic/tree/props.js +5 -0
  45. package/components/basic/tree/utils.js +154 -0
  46. package/components/basic/video/index.js +85 -0
  47. package/components/basic/video/props.js +5 -0
  48. package/components/chart/components/barColumnChart/index.js +132 -0
  49. package/components/chart/components/barColumnChart/props.js +5 -0
  50. package/components/chart/components/bubbleChart/index.js +176 -0
  51. package/components/chart/components/bubbleChart/props.js +5 -0
  52. package/components/chart/components/chartLegend/components/ClassicLegendItem.js +39 -0
  53. package/components/chart/components/chartLegend/components/FuriousLegendItem.js +81 -0
  54. package/components/chart/components/chartLegend/index.js +69 -0
  55. package/components/chart/components/chartLegend/props.js +5 -0
  56. package/components/chart/components/chartLegend/utils.js +31 -0
  57. package/components/chart/components/chartTooltip/index.js +53 -0
  58. package/components/chart/components/chartTooltip/styles.js +37 -0
  59. package/components/chart/components/chartTooltip/utils.js +23 -0
  60. package/components/chart/components/cumulativeLineChart/index.js +113 -0
  61. package/components/chart/components/cumulativeLineChart/props.js +5 -0
  62. package/components/chart/components/cumulativeLineChart/utils.js +34 -0
  63. package/components/chart/components/index.js +40 -0
  64. package/components/chart/components/lineAreaChart/index.js +140 -0
  65. package/components/chart/components/lineAreaChart/props.js +5 -0
  66. package/components/chart/components/noDataMessage/index.js +27 -0
  67. package/components/chart/components/pieDonutChart/index.js +171 -0
  68. package/components/chart/components/pieDonutChart/props.js +5 -0
  69. package/components/chart/constant.js +72 -0
  70. package/components/chart/index.js +930 -0
  71. package/components/chart/props.js +5 -0
  72. package/components/chart/utils.js +691 -0
  73. package/components/common/AppSpinner.js +36 -0
  74. package/components/common/app-spinner.js +26 -0
  75. package/components/common/index.js +12 -0
  76. package/components/constants.js +1208 -0
  77. package/components/container/accordion/accordion-pane/index.js +108 -0
  78. package/components/container/accordion/accordion-pane/props.js +11 -0
  79. package/components/container/accordion/index.js +232 -0
  80. package/components/container/accordion/props.js +13 -0
  81. package/components/container/alignment-utils.js +183 -0
  82. package/components/container/index.js +188 -0
  83. package/components/container/layout-grid/grid-column/index.js +34 -0
  84. package/components/container/layout-grid/grid-row/index.js +24 -0
  85. package/components/container/layout-grid/index.js +33 -0
  86. package/components/container/linear-layout/index.js +72 -0
  87. package/components/container/linear-layout/linear-layout-item/index.js +43 -0
  88. package/components/container/panel/components/panel-header/index.js +144 -0
  89. package/components/container/panel/components/panel-header/props.js +5 -0
  90. package/components/container/panel/hooks.js +144 -0
  91. package/components/container/panel/index.js +286 -0
  92. package/components/container/panel/props.js +5 -0
  93. package/components/container/props.js +5 -0
  94. package/components/container/tabs/index.js +379 -0
  95. package/components/container/tabs/props.js +20 -0
  96. package/components/container/tabs/tab-pane/index.js +42 -0
  97. package/components/container/tabs/tab-pane/props.js +5 -0
  98. package/components/container/wizard/WizardContext.js +16 -0
  99. package/components/container/wizard/components/StepComponents.js +100 -0
  100. package/components/container/wizard/components/WizardStep.js +89 -0
  101. package/components/container/wizard/index.js +710 -0
  102. package/components/container/wizard/props.js +5 -0
  103. package/components/container/wizard/utils.js +133 -0
  104. package/components/container/wizard/wizard-action/index.js +22 -0
  105. package/components/container/wizard/wizard-step/index.js +94 -0
  106. package/components/data/card/card-actions/index.js +24 -0
  107. package/components/data/card/card-content/index.js +38 -0
  108. package/components/data/card/card-footer/index.js +24 -0
  109. package/components/data/card/index.js +246 -0
  110. package/components/data/card/props.js +5 -0
  111. package/components/data/form/base-form/constant.js +39 -0
  112. package/components/data/form/base-form/index.js +460 -0
  113. package/components/data/form/base-form/props.js +29 -0
  114. package/components/data/form/base-form/utils.js +42 -0
  115. package/components/data/form/dynamic-fields/index.js +196 -0
  116. package/components/data/form/dynamic-fields/props.js +5 -0
  117. package/components/data/form/dynamic-fields/utils.js +237 -0
  118. package/components/data/form/form-action/index.js +71 -0
  119. package/components/data/form/form-body/index.js +26 -0
  120. package/components/data/form/form-context.js +34 -0
  121. package/components/data/form/form-controller/props.js +19 -0
  122. package/components/data/form/form-controller/validation-contrustor.js +313 -0
  123. package/components/data/form/form-controller/withFormController.js +320 -0
  124. package/components/data/form/form-field/base-field.js +138 -0
  125. package/components/data/form/form-field/index.js +36 -0
  126. package/components/data/form/form-field/props.js +5 -0
  127. package/components/data/form/form-footer/index.js +26 -0
  128. package/components/data/form/form-header/index.js +56 -0
  129. package/components/data/form/index.js +39 -0
  130. package/components/data/form/props.js +5 -0
  131. package/components/data/list/components/GroupHeader.js +35 -0
  132. package/components/data/list/components/GroupedListItems.js +98 -0
  133. package/components/data/list/components/ListContainer.js +27 -0
  134. package/components/data/list/components/ListDND.js +241 -0
  135. package/components/data/list/components/ListHeader.js +59 -0
  136. package/components/data/list/components/ListItem.js +148 -0
  137. package/components/data/list/components/ListItemWithTemplate.js +59 -0
  138. package/components/data/list/components/ListItems.js +231 -0
  139. package/components/data/list/components/ListPagination.js +165 -0
  140. package/components/data/list/components/LoadMoreButton.js +39 -0
  141. package/components/data/list/components/NoDataMessage.js +22 -0
  142. package/components/data/list/components/StandardListItems.js +84 -0
  143. package/components/data/list/components/index.js +119 -0
  144. package/components/data/list/components/props.js +5 -0
  145. package/components/data/list/hooks/index.js +75 -0
  146. package/components/data/list/hooks/props.js +5 -0
  147. package/components/data/list/hooks/useCurrentPageItems.js +48 -0
  148. package/components/data/list/hooks/useGroupedData.js +37 -0
  149. package/components/data/list/hooks/useListData.js +60 -0
  150. package/components/data/list/hooks/useListEffects.js +285 -0
  151. package/components/data/list/hooks/useListEventHandlers.js +291 -0
  152. package/components/data/list/hooks/useListPagination.js +168 -0
  153. package/components/data/list/hooks/useListState.js +98 -0
  154. package/components/data/list/hooks/useListStateManager.js +195 -0
  155. package/components/data/list/hooks/usePaginatedGroupedData.js +121 -0
  156. package/components/data/list/index.js +611 -0
  157. package/components/data/list/props.js +5 -0
  158. package/components/data/list/templates/media-template.js +53 -0
  159. package/components/data/list/utils/constants.js +81 -0
  160. package/components/data/list/utils/list-helpers.js +173 -0
  161. package/components/data/list/utils/list-widget-methods.js +114 -0
  162. package/components/data/live-filter/index.js +279 -0
  163. package/components/data/live-filter/props.js +12 -0
  164. package/components/data/live-form/index.js +93 -0
  165. package/components/data/live-form/props.js +16 -0
  166. package/components/data/pagination/components/BasicPagination.js +77 -0
  167. package/components/data/pagination/components/ClassicPagination.js +191 -0
  168. package/components/data/pagination/components/InlinePagination.js +99 -0
  169. package/components/data/pagination/components/LoadingComponent.js +31 -0
  170. package/components/data/pagination/components/PageSizeSelector.js +175 -0
  171. package/components/data/pagination/components/PagerNavigation.js +105 -0
  172. package/components/data/pagination/components/TotalRecords.js +52 -0
  173. package/components/data/pagination/components/index.js +47 -0
  174. package/components/data/pagination/components/props.js +5 -0
  175. package/components/data/pagination/hooks/index.js +19 -0
  176. package/components/data/pagination/hooks/props.js +5 -0
  177. package/components/data/pagination/hooks/useNavigationSize.js +44 -0
  178. package/components/data/pagination/hooks/usePagination.js +796 -0
  179. package/components/data/pagination/index.js +322 -0
  180. package/components/data/table/components/AddNewRow.js +190 -0
  181. package/components/data/table/components/EditableCell.js +91 -0
  182. package/components/data/table/components/FieldValidationError.js +24 -0
  183. package/components/data/table/components/RowExpansionButton.js +74 -0
  184. package/components/data/table/components/TableBody.js +279 -0
  185. package/components/data/table/components/TableFilters.js +325 -0
  186. package/components/data/table/components/TableFooterActions.js +48 -0
  187. package/components/data/table/components/TableHeader.js +174 -0
  188. package/components/data/table/components/TablePanelHeading.js +68 -0
  189. package/components/data/table/components/index.js +74 -0
  190. package/components/data/table/hooks/index.js +219 -0
  191. package/components/data/table/hooks/useCellState.js +117 -0
  192. package/components/data/table/hooks/useDynamicColumns.js +85 -0
  193. package/components/data/table/hooks/useEditingState.js +47 -0
  194. package/components/data/table/hooks/useFormWidget.js +184 -0
  195. package/components/data/table/hooks/usePaginationState.js +60 -0
  196. package/components/data/table/hooks/usePanelStructure.js +40 -0
  197. package/components/data/table/hooks/useResponsiveColumns.js +34 -0
  198. package/components/data/table/hooks/useRowExpansion.js +110 -0
  199. package/components/data/table/hooks/useRowHandlers.js +38 -0
  200. package/components/data/table/hooks/useRowSelection.js +213 -0
  201. package/components/data/table/hooks/useServerSideSorting.js +165 -0
  202. package/components/data/table/hooks/useTableColumns.js +263 -0
  203. package/components/data/table/hooks/useTableData.js +154 -0
  204. package/components/data/table/hooks/useTableEdit.js +467 -0
  205. package/components/data/table/hooks/useTableEffects.js +139 -0
  206. package/components/data/table/hooks/useTableFilter.js +389 -0
  207. package/components/data/table/hooks/useTableInitialization.js +103 -0
  208. package/components/data/table/hooks/useTableState.js +69 -0
  209. package/components/data/table/hooks/useTableStateManager.js +558 -0
  210. package/components/data/table/index.js +1295 -0
  211. package/components/data/table/live-table/index.js +232 -0
  212. package/components/data/table/props.js +5 -0
  213. package/components/data/table/table-action/index.js +78 -0
  214. package/components/data/table/table-column/index.js +35 -0
  215. package/components/data/table/table-row/index.js +49 -0
  216. package/components/data/table/table-row-action/index.js +74 -0
  217. package/components/data/table/utils/buildSelectionColumns.js +173 -0
  218. package/components/data/table/utils/columnBuilder.js +209 -0
  219. package/components/data/table/utils/columnProxy.js +48 -0
  220. package/components/data/table/utils/columnWidthDistribution.js +98 -0
  221. package/components/data/table/utils/constants.js +80 -0
  222. package/components/data/table/utils/crud-handlers.js +518 -0
  223. package/components/data/table/utils/dynamic-columns.js +118 -0
  224. package/components/data/table/utils/index.js +607 -0
  225. package/components/data/table/utils/renderDisplayCell.js +183 -0
  226. package/components/data/table/utils/selectionUtils.js +166 -0
  227. package/components/data/table/utils/table-helpers.js +100 -0
  228. package/components/data/table/utils/validation.js +124 -0
  229. package/components/data/types.js +113 -0
  230. package/components/data/utils/field-data-utils.js +66 -0
  231. package/components/data/utils/filter-field-util.js +81 -0
  232. package/components/data/utils/index.js +216 -0
  233. package/components/dialogs/alert-dialog/index.js +80 -0
  234. package/components/dialogs/confirm-dialog/index.js +105 -0
  235. package/components/dialogs/dialog/index.js +56 -0
  236. package/components/dialogs/dialog-actions/index.js +18 -0
  237. package/components/dialogs/dialog-body/index.js +21 -0
  238. package/components/dialogs/dialog-content/index.js +30 -0
  239. package/components/dialogs/dialog-header/index.js +93 -0
  240. package/components/dialogs/iframe-dialog/index.js +114 -0
  241. package/components/dialogs/index.js +129 -0
  242. package/components/dialogs/login-dialog/index.js +369 -0
  243. package/components/dialogs/login-dialog/props.js +5 -0
  244. package/components/dialogs/page-dialog/index.js +96 -0
  245. package/components/dialogs/withDialogWrapper.js +108 -0
  246. package/components/form/button/index.js +216 -0
  247. package/components/form/button-group/index.js +60 -0
  248. package/components/input/calendar/index.js +546 -0
  249. package/components/input/calendar/props.js +5 -0
  250. package/components/input/calendar/utils.js +340 -0
  251. package/components/input/chips/SortableChip/index.js +115 -0
  252. package/components/input/chips/SortableChip/props.js +5 -0
  253. package/components/input/chips/index.js +488 -0
  254. package/components/input/chips/props.js +5 -0
  255. package/components/input/chips/utils.js +259 -0
  256. package/components/input/color-picker/index.js +678 -0
  257. package/components/input/color-picker/props.js +5 -0
  258. package/components/input/composite/index.js +137 -0
  259. package/components/input/currency/index.js +263 -0
  260. package/components/input/currency/props.js +5 -0
  261. package/components/input/default/checkbox/index.js +230 -0
  262. package/components/input/default/checkbox/props.js +5 -0
  263. package/components/input/default/checkboxset/index.js +476 -0
  264. package/components/input/default/checkboxset/props.js +5 -0
  265. package/components/input/default/radioset/index.js +379 -0
  266. package/components/input/default/radioset/props.js +5 -0
  267. package/components/input/default/switch/index.js +490 -0
  268. package/components/input/default/switch/prop.js +5 -0
  269. package/components/input/epoch/date/components/DatePickerPopover.js +220 -0
  270. package/components/input/epoch/date/index.js +520 -0
  271. package/components/input/epoch/date/props.js +5 -0
  272. package/components/input/epoch/date/styled.js +70 -0
  273. package/components/input/epoch/date/utils.js +108 -0
  274. package/components/input/epoch/datetime/index.js +656 -0
  275. package/components/input/epoch/datetime/props.js +5 -0
  276. package/components/input/epoch/datetime/styled.js +90 -0
  277. package/components/input/epoch/datetime/utils.js +244 -0
  278. package/components/input/epoch/time/index.js +412 -0
  279. package/components/input/epoch/time/props.js +5 -0
  280. package/components/input/epoch/time/utils.js +209 -0
  281. package/components/input/fileupload/Utils.js +134 -0
  282. package/components/input/fileupload/components/ListItems.js +140 -0
  283. package/components/input/fileupload/components/MultiUpload.js +85 -0
  284. package/components/input/fileupload/components/SingleUpload.js +65 -0
  285. package/components/input/fileupload/index.js +170 -0
  286. package/components/input/fileupload/props.js +5 -0
  287. package/components/input/fileupload/useFileUpload.js +400 -0
  288. package/components/input/number/index.js +295 -0
  289. package/components/input/number/props.js +5 -0
  290. package/components/input/rating/index.js +368 -0
  291. package/components/input/rating/props.js +5 -0
  292. package/components/input/select/index.js +344 -0
  293. package/components/input/select/props.js +5 -0
  294. package/components/input/slider/index.js +167 -0
  295. package/components/input/slider/props.js +5 -0
  296. package/components/input/text/index.js +434 -0
  297. package/components/input/text/props.js +5 -0
  298. package/components/input/text/util.js +179 -0
  299. package/components/input/textarea/index.js +347 -0
  300. package/components/input/textarea/props.js +5 -0
  301. package/components/layout/footer/index.js +30 -0
  302. package/components/layout/header/index.js +30 -0
  303. package/components/layout/leftnav/index.js +44 -0
  304. package/components/layout/rightnav/index.js +32 -0
  305. package/components/layout/topnav/index.js +34 -0
  306. package/components/navbar/index.js +41 -0
  307. package/components/navbar/nav/index.js +102 -0
  308. package/components/navbar/nav/props.js +5 -0
  309. package/components/navbar/nav-item/index.js +44 -0
  310. package/components/navigation/breadcrumb/index.js +56 -0
  311. package/components/navigation/breadcrumb/props.js +5 -0
  312. package/components/navigation/menu/components/ListItems.js +66 -0
  313. package/components/navigation/menu/constants.js +101 -0
  314. package/components/navigation/menu/index.js +807 -0
  315. package/components/navigation/menu/props.js +5 -0
  316. package/components/navigation/popover/index.js +209 -0
  317. package/components/navigation/popover/props.js +15 -0
  318. package/components/page/content/index.js +28 -0
  319. package/components/page/error-boundary/index.js +108 -0
  320. package/components/page/index.js +137 -0
  321. package/components/page/page-content/index.js +23 -0
  322. package/components/page/partial/index.js +36 -0
  323. package/components/page/partial-container/index.js +48 -0
  324. package/components/page/props.js +5 -0
  325. package/components/page/toast-container/index.js +33 -0
  326. package/components/prefab/container/index.js +46 -0
  327. package/components/prefab/index.js +67 -0
  328. package/context/AppContext.js +25 -0
  329. package/context/AppSpinnerProvider.js +43 -0
  330. package/context/LocalizationProvider.js +79 -0
  331. package/context/PrefabContext.js +66 -0
  332. package/context/WidgetProvider.js +187 -0
  333. package/core/app-config.js +1 -0
  334. package/core/app.service.js +357 -0
  335. package/core/appVariablesStore.js +20 -0
  336. package/core/appstore.js +88 -0
  337. package/core/constants/currency-constant.js +1071 -0
  338. package/core/constants/events.js +34 -0
  339. package/core/constants/index.js +27 -0
  340. package/core/dialog.service.js +76 -0
  341. package/core/event-notifier.js +151 -0
  342. package/core/formatter/date-formatters.js +222 -0
  343. package/core/formatter/index.js +131 -0
  344. package/core/formatter/number-formatters.js +142 -0
  345. package/core/formatter/security-formatters.js +323 -0
  346. package/core/formatter/string-formatters.js +52 -0
  347. package/core/formatter/types.js +18 -0
  348. package/core/formatters.js +24 -0
  349. package/core/proxy-service.js +412 -0
  350. package/core/script-registry.js +63 -0
  351. package/core/security.service.js +11 -0
  352. package/core/util/common.js +33 -0
  353. package/core/util/dom.js +107 -0
  354. package/core/util/index.js +136 -0
  355. package/core/util/security.js +184 -0
  356. package/core/util/utils.js +189 -0
  357. package/core/widget-observer.js +98 -0
  358. package/higherOrder/BaseApp.js +430 -0
  359. package/higherOrder/BaseAppProps.js +5 -0
  360. package/higherOrder/BaseDateTime.js +251 -0
  361. package/higherOrder/BasePage.js +715 -0
  362. package/higherOrder/BasePartial.js +124 -0
  363. package/higherOrder/BasePrefab.js +145 -0
  364. package/higherOrder/DataNav.js +377 -0
  365. package/higherOrder/helper.js +43 -0
  366. package/higherOrder/props.js +5 -0
  367. package/higherOrder/withBaseWrapper.js +183 -0
  368. package/hooks/useAccess.js +308 -0
  369. package/hooks/useAppConfig.js +42 -0
  370. package/hooks/useAuth.js +562 -0
  371. package/hooks/useDataSourceSubscription.js +125 -0
  372. package/hooks/useDebounce.js +76 -0
  373. package/hooks/useDeviceVisibility.js +49 -0
  374. package/hooks/useHttp.js +338 -0
  375. package/libs/index.js +20 -0
  376. package/mui-config/theme-provider.js +17 -0
  377. package/mui-config/theme.js +371 -0
  378. package/package-lock.json +10183 -0
  379. package/package.json +95 -0
  380. package/store/index.js +33 -0
  381. package/store/middleware/navigationMiddleware.js +48 -0
  382. package/store/slices/appConfigSlice.js +103 -0
  383. package/store/slices/authSlice.js +508 -0
  384. package/store/slices/i18nSlice.js +206 -0
  385. package/types/index.js +15 -0
  386. package/utils/dataset-util.js +174 -0
  387. package/utils/eval-expression.js +32 -0
  388. package/utils/form-state.util.js +140 -0
  389. package/utils/form-utils.js +187 -0
  390. package/utils/format-util.js +260 -0
  391. package/utils/page-params-util.js +24 -0
  392. package/utils/resource-url.js +27 -0
  393. package/utils/state-persistance.js +343 -0
  394. package/utils/style-utils.js +73 -0
  395. package/utils/transformedDataset-utils.js +633 -0
  396. package/utils/widget-cleanup-util.js +84 -0
  397. package/utils/widgets.js +99 -0
  398. package/variables/base-variable.js +173 -0
  399. package/variables/constants.js +27 -0
  400. package/variables/live-variable.js +166 -0
  401. package/variables/model-variable.js +77 -0
  402. package/variables/service-variable.js +307 -0
@@ -0,0 +1,313 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
+ Object.defineProperty(exports, "__esModule", {
5
+ value: true
6
+ });
7
+ exports.createValidationRules = void 0;
8
+ var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"));
9
+ var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
10
+ var _typeof2 = _interopRequireDefault(require("@babel/runtime/helpers/typeof"));
11
+ var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
12
+ var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
13
+ var _lodashEs = require("lodash-es");
14
+ 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; }
15
+ 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; }
16
+ var validationHandlers = {
17
+ required: function required(config, rules) {
18
+ if (config.validator) {
19
+ rules.required = config.errorMessage;
20
+ }
21
+ rules.validate = _objectSpread(_objectSpread({}, rules.validate), {}, {
22
+ noWhitespaces: function noWhitespaces(value) {
23
+ if (typeof value === "string" && value.length > 0 && value.trim() === "") {
24
+ return config.errorMessage;
25
+ }
26
+ return true;
27
+ }
28
+ });
29
+ return rules;
30
+ },
31
+ maxchars: function maxchars(config, rules) {
32
+ rules.maxLength = {
33
+ value: config.validator,
34
+ message: config.errorMessage
35
+ };
36
+ return rules;
37
+ },
38
+ minvalue: function minvalue(config, rules) {
39
+ rules.min = {
40
+ value: config.validator,
41
+ message: config.errorMessage
42
+ };
43
+ return rules;
44
+ },
45
+ maxvalue: function maxvalue(config, rules) {
46
+ rules.max = {
47
+ value: config.validator,
48
+ message: config.errorMessage
49
+ };
50
+ return rules;
51
+ },
52
+ regexp: function regexp(config, rules) {
53
+ var pattern;
54
+ try {
55
+ pattern = (0, _lodashEs.isString)(config.validator) ? new RegExp(config.validator.replace(/^\/|\/$/g, "")) : config.validator;
56
+ } catch (e) {
57
+ console.warn("Invalid regexp string:", config.validator);
58
+ return rules;
59
+ }
60
+ rules.pattern = {
61
+ value: pattern,
62
+ message: config.errorMessage
63
+ };
64
+ return rules;
65
+ },
66
+ mindate: function mindate(config, rules) {
67
+ rules.validate = _objectSpread(_objectSpread({}, rules.validate), {}, {
68
+ minDate: function minDate(value) {
69
+ if (!value) return true;
70
+ var inputDate = new Date(value);
71
+ var minDate = new Date(config.validator);
72
+ if (isNaN(inputDate.getTime()) || isNaN(minDate.getTime())) {
73
+ return "Invalid date format";
74
+ }
75
+ return inputDate >= minDate || config.errorMessage;
76
+ }
77
+ });
78
+ return rules;
79
+ },
80
+ maxdate: function maxdate(config, rules) {
81
+ rules.validate = _objectSpread(_objectSpread({}, rules.validate), {}, {
82
+ maxDate: function maxDate(value) {
83
+ if (!value) return true;
84
+ var inputDate = new Date(value);
85
+ var maxDate = new Date(config.validator);
86
+ if (isNaN(inputDate.getTime()) || isNaN(maxDate.getTime())) {
87
+ return "Invalid date format";
88
+ }
89
+ return inputDate <= maxDate || config.errorMessage;
90
+ }
91
+ });
92
+ return rules;
93
+ },
94
+ mintime: function mintime(config, rules) {
95
+ rules.validate = _objectSpread(_objectSpread({}, rules.validate), {}, {
96
+ minTime: function minTime(value) {
97
+ if (!value) return true;
98
+ var parseTime = function parseTime(time) {
99
+ var _time$split$map = time.split(":").map(Number),
100
+ _time$split$map2 = (0, _slicedToArray2["default"])(_time$split$map, 2),
101
+ hours = _time$split$map2[0],
102
+ minutes = _time$split$map2[1];
103
+ return hours * 60 + minutes;
104
+ };
105
+ try {
106
+ var inputMinutes = parseTime(value);
107
+ var minMinutes = parseTime(config.validator);
108
+ return inputMinutes >= minMinutes || config.errorMessage;
109
+ } catch (_unused) {
110
+ return "Invalid time format";
111
+ }
112
+ }
113
+ });
114
+ return rules;
115
+ },
116
+ maxtime: function maxtime(config, rules) {
117
+ rules.validate = _objectSpread(_objectSpread({}, rules.validate), {}, {
118
+ maxTime: function maxTime(value) {
119
+ if (!value) return true;
120
+ var parseTime = function parseTime(time) {
121
+ var _time$split$map3 = time.split(":").map(Number),
122
+ _time$split$map4 = (0, _slicedToArray2["default"])(_time$split$map3, 2),
123
+ hours = _time$split$map4[0],
124
+ minutes = _time$split$map4[1];
125
+ return hours * 60 + minutes;
126
+ };
127
+ try {
128
+ var inputMinutes = parseTime(value);
129
+ var maxMinutes = parseTime(config.validator);
130
+ return inputMinutes <= maxMinutes || config.errorMessage;
131
+ } catch (_unused2) {
132
+ return "Invalid time format";
133
+ }
134
+ }
135
+ });
136
+ return rules;
137
+ },
138
+ excludedates: function excludedates(config, rules) {
139
+ rules.validate = _objectSpread(_objectSpread({}, rules.validate), {}, {
140
+ excludeDates: function excludeDates(value) {
141
+ if (!value) return true;
142
+ var inputDate = new Date(value);
143
+ if (isNaN(inputDate.getTime())) return "Invalid date format";
144
+ var formatDate = function formatDate(date) {
145
+ var d = (0, _lodashEs.isDate)(date) ? date : new Date(date);
146
+ return d.toISOString().split("T")[0];
147
+ };
148
+ var inputDateStr = formatDate(value);
149
+ var isExcluded = config.validator.some(function (excludedDate) {
150
+ return formatDate(excludedDate) === inputDateStr;
151
+ });
152
+ return !isExcluded || config.errorMessage;
153
+ }
154
+ });
155
+ return rules;
156
+ },
157
+ excludedays: function excludedays(config, rules) {
158
+ rules.validate = _objectSpread(_objectSpread({}, rules.validate), {}, {
159
+ excludeDays: function excludeDays(value) {
160
+ if (!value) return true;
161
+ var inputDate = new Date(value);
162
+ if (isNaN(inputDate.getTime())) return "Invalid date format";
163
+ var dayOfWeek = inputDate.getDay();
164
+ var isExcluded = config.validator.includes(dayOfWeek);
165
+ return !isExcluded || config.errorMessage;
166
+ }
167
+ });
168
+ return rules;
169
+ }
170
+ };
171
+
172
+ // Type guard functions using lodash
173
+ var isValidatorConfig = function isValidatorConfig(config) {
174
+ return config && (0, _typeof2["default"])(config) === "object" && !Array.isArray(config) && typeof config !== "function" && (0, _lodashEs.isString)(config.type) && (0, _lodashEs.isString)(config.errorMessage) && config.validator !== undefined;
175
+ };
176
+ var isFunctionValidator = function isFunctionValidator(config) {
177
+ return typeof config === "function";
178
+ };
179
+ var validateValidatorConfig = function validateValidatorConfig(config) {
180
+ var type = config.type,
181
+ validator = config.validator;
182
+ switch (type) {
183
+ case "required":
184
+ return (0, _lodashEs.isBoolean)(validator);
185
+ case "maxchars":
186
+ case "minvalue":
187
+ case "maxvalue":
188
+ return (0, _lodashEs.isNumber)(validator);
189
+ case "regexp":
190
+ return (0, _lodashEs.isRegExp)(validator) || (0, _lodashEs.isString)(validator) && function () {
191
+ try {
192
+ new RegExp(validator.replace(/^\/|\/$/g, ""));
193
+ return true;
194
+ } catch (_unused3) {
195
+ return false;
196
+ }
197
+ }();
198
+ case "mindate":
199
+ case "maxdate":
200
+ return (0, _lodashEs.isString)(validator) || (0, _lodashEs.isDate)(validator);
201
+ case "mintime":
202
+ case "maxtime":
203
+ return (0, _lodashEs.isString)(validator) && /^\d{2}:\d{2}$/.test(validator);
204
+ case "excludedates":
205
+ return (0, _lodashEs.isArray)(validator) && validator.every(function (v) {
206
+ return (0, _lodashEs.isString)(v) || (0, _lodashEs.isDate)(v);
207
+ });
208
+ case "excludedays":
209
+ return (0, _lodashEs.isArray)(validator) && validator.every(function (v) {
210
+ return (0, _lodashEs.isNumber)(v) && v >= 0 && v <= 6;
211
+ });
212
+ default:
213
+ return false;
214
+ }
215
+ };
216
+ var createValidationRules = exports.createValidationRules = function createValidationRules(validators) {
217
+ var form = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
218
+ var fieldName = arguments.length > 2 ? arguments[2] : undefined;
219
+ var functionValidators = validators.filter(isFunctionValidator);
220
+ var configValidators = validators.filter(isValidatorConfig);
221
+ var unrecognized = validators.filter(function (v) {
222
+ return !isFunctionValidator(v) && !isValidatorConfig(v);
223
+ });
224
+ if (unrecognized.length > 0) {
225
+ console.warn("Unrecognized validator configurations:", unrecognized);
226
+ }
227
+ var validConfigs = configValidators.filter(function (config) {
228
+ if (!validateValidatorConfig(config)) {
229
+ console.warn("Invalid validator values for type:", config.type, config);
230
+ return false;
231
+ }
232
+ return true;
233
+ });
234
+ var rules = (0, _lodashEs.reduce)(validConfigs, function (acc, config) {
235
+ var handler = validationHandlers[config.type];
236
+ if (handler) return handler(config, acc);
237
+ console.warn("No handler found for validator type: ".concat(config.type));
238
+ return acc;
239
+ }, {});
240
+ if (functionValidators.length > 0) {
241
+ var functionValidateRules = (0, _lodashEs.reduce)(functionValidators, function (acc, validator, index) {
242
+ acc["customValidator".concat(index)] = /*#__PURE__*/function () {
243
+ var _ref = (0, _asyncToGenerator2["default"])(/*#__PURE__*/_regenerator["default"].mark(function _callee(value) {
244
+ var result;
245
+ return _regenerator["default"].wrap(function _callee$(_context) {
246
+ while (1) switch (_context.prev = _context.next) {
247
+ case 0:
248
+ _context.prev = 0;
249
+ if (value) {
250
+ _context.next = 3;
251
+ break;
252
+ }
253
+ return _context.abrupt("return", true);
254
+ case 3:
255
+ _context.next = 5;
256
+ return validator({
257
+ value: value,
258
+ fieldName: fieldName
259
+ }, form);
260
+ case 5:
261
+ result = _context.sent;
262
+ if (!(typeof result === "string")) {
263
+ _context.next = 8;
264
+ break;
265
+ }
266
+ return _context.abrupt("return", result);
267
+ case 8:
268
+ if (!(typeof result === "boolean")) {
269
+ _context.next = 10;
270
+ break;
271
+ }
272
+ return _context.abrupt("return", result || "Validation failed");
273
+ case 10:
274
+ if (!(result !== null && result !== void 0 && result.errorMessage)) {
275
+ _context.next = 12;
276
+ break;
277
+ }
278
+ return _context.abrupt("return", result.errorMessage);
279
+ case 12:
280
+ return _context.abrupt("return", true);
281
+ case 15:
282
+ _context.prev = 15;
283
+ _context.t0 = _context["catch"](0);
284
+ if (!(_context.t0 !== null && _context.t0 !== void 0 && _context.t0.errorMessage)) {
285
+ _context.next = 19;
286
+ break;
287
+ }
288
+ return _context.abrupt("return", _context.t0.errorMessage);
289
+ case 19:
290
+ if (!(typeof _context.t0 === "string")) {
291
+ _context.next = 21;
292
+ break;
293
+ }
294
+ return _context.abrupt("return", _context.t0);
295
+ case 21:
296
+ console.warn("Function validator threw an error:", _context.t0);
297
+ return _context.abrupt("return", "Validation error occurred");
298
+ case 23:
299
+ case "end":
300
+ return _context.stop();
301
+ }
302
+ }, _callee, null, [[0, 15]]);
303
+ }));
304
+ return function (_x) {
305
+ return _ref.apply(this, arguments);
306
+ };
307
+ }();
308
+ return acc;
309
+ }, {});
310
+ rules.validate = _objectSpread(_objectSpread({}, rules.validate), functionValidateRules);
311
+ }
312
+ return rules;
313
+ };
@@ -0,0 +1,320 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
+ var _typeof3 = require("@babel/runtime/helpers/typeof");
5
+ Object.defineProperty(exports, "__esModule", {
6
+ value: true
7
+ });
8
+ exports["default"] = void 0;
9
+ var _react = _interopRequireWildcard(require("react"));
10
+ var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
11
+ var _objectWithoutProperties2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutProperties"));
12
+ var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
13
+ var _typeof2 = _interopRequireDefault(require("@babel/runtime/helpers/typeof"));
14
+ var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
15
+ var _reactHookForm = require("react-hook-form");
16
+ var _clsx = _interopRequireDefault(require("clsx"));
17
+ var _Box = _interopRequireDefault(require("@mui/material/Box"));
18
+ var _validationContrustor = require("@wavemaker/react-runtime/components/data/form/form-controller/validation-contrustor");
19
+ var _WidgetProvider = require("@wavemaker/react-runtime/context/WidgetProvider");
20
+ var _formContext = require("@wavemaker/react-runtime/components/data/form/form-context");
21
+ var _excluded = ["formRef", "formKey", "name", "datavalue", "defaultvalue", "validators", "asyncValidators", "required", "maxchars", "regexp", "validationmessage", "hint", "type", "observe", "onBlur", "fieldName"];
22
+ 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" != _typeof3(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); }
23
+ var __jsx = _react["default"].createElement;
24
+ 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; }
25
+ 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; }
26
+ // Custom hooks for better separation of concerns
27
+ var useFormRegistration = function useFormRegistration(name, fieldProxy, contextFormRef) {
28
+ var hasRegisteredRef = (0, _react.useRef)(false);
29
+ (0, _react.useEffect)(function () {
30
+ if (contextFormRef !== null && contextFormRef !== void 0 && contextFormRef.registerFormWidget && fieldProxy && !hasRegisteredRef.current) {
31
+ contextFormRef.registerFormWidget(name, fieldProxy);
32
+ hasRegisteredRef.current = true;
33
+ }
34
+ }, [fieldProxy, name, contextFormRef]);
35
+ };
36
+ var useExternalDataSync = function useExternalDataSync(datavalue, fieldRef) {
37
+ (0, _react.useEffect)(function () {
38
+ if (fieldRef.current && datavalue !== undefined) {
39
+ var currentValue = fieldRef.current.value;
40
+ if (currentValue !== datavalue) {
41
+ fieldRef.current.onChange(datavalue);
42
+ }
43
+ }
44
+ }, [datavalue]);
45
+ };
46
+ var useValidationRules = function useValidationRules(validationType, validators, asyncValidators, required, maxchars, regexp, validationmessage, form) {
47
+ return (0, _react.useMemo)(function () {
48
+ if (validationType === "none") {
49
+ return {};
50
+ }
51
+ var combinedValidators = [].concat((0, _toConsumableArray2["default"])(validators || []), (0, _toConsumableArray2["default"])(asyncValidators || []));
52
+ if (required) {
53
+ combinedValidators.push({
54
+ type: "required",
55
+ validator: true,
56
+ errorMessage: validationmessage || "This field is required"
57
+ });
58
+ }
59
+ if (maxchars) {
60
+ combinedValidators.push({
61
+ type: "maxchars",
62
+ validator: maxchars,
63
+ errorMessage: "Maximum length is ".concat(maxchars, " characters.")
64
+ });
65
+ }
66
+ if (regexp) {
67
+ combinedValidators.push({
68
+ type: "regexp",
69
+ validator: regexp,
70
+ errorMessage: validationmessage || "Invalid format."
71
+ });
72
+ }
73
+ return (0, _validationContrustor.createValidationRules)(combinedValidators, form);
74
+ }, [validators, asyncValidators, required, maxchars, regexp, validationmessage, form, validationType]);
75
+ };
76
+ var useHTMLValidationProps = function useHTMLValidationProps(validationType, required, maxchars, regexp) {
77
+ return (0, _react.useMemo)(function () {
78
+ if (validationType !== "html") {
79
+ return {};
80
+ }
81
+ var htmlProps = {};
82
+ if (required) {
83
+ htmlProps.required = true;
84
+ }
85
+ if (maxchars) {
86
+ htmlProps.maxLength = maxchars;
87
+ }
88
+ if (regexp) {
89
+ htmlProps.pattern = typeof regexp === "string" ? regexp : regexp.source;
90
+ }
91
+ return htmlProps;
92
+ }, [validationType, required, maxchars, regexp]);
93
+ };
94
+
95
+ // Utility functions
96
+ var processFieldValue = function processFieldValue(fieldValue, type, datafield) {
97
+ // If fieldValue is an object and datafield is specified, extract the value
98
+ if (fieldValue && (0, _typeof2["default"])(fieldValue) === "object" && !Array.isArray(fieldValue) && datafield) {
99
+ fieldValue = fieldValue[datafield];
100
+ }
101
+ if (type === "number") {
102
+ return fieldValue === "" || fieldValue === null || fieldValue === undefined ? "" : fieldValue;
103
+ }
104
+ return fieldValue;
105
+ };
106
+ var getErrorState = function getErrorState(fieldState, validationType, touched) {
107
+ switch (validationType) {
108
+ case "default":
109
+ return {
110
+ error: touched && !!fieldState.error,
111
+ errorMessage: touched && fieldState.error ? fieldState.error.message : undefined,
112
+ fieldState: fieldState
113
+ };
114
+ case "html":
115
+ return {
116
+ error: touched && !!fieldState.error,
117
+ errorMessage: touched && fieldState.error ? fieldState.error.message : undefined,
118
+ fieldState: fieldState
119
+ };
120
+ case "none":
121
+ return {
122
+ error: false,
123
+ errorMessage: undefined,
124
+ fieldState: _objectSpread(_objectSpread({}, fieldState), {}, {
125
+ error: undefined
126
+ })
127
+ };
128
+ default:
129
+ return {
130
+ error: false,
131
+ errorMessage: undefined,
132
+ fieldState: undefined
133
+ };
134
+ }
135
+ };
136
+ var shouldShowErrorMessage = function shouldShowErrorMessage(validationType, fieldState, touched) {
137
+ return validationType !== "none" && (validationType === "default" && touched && fieldState.error || validationType === "html" && touched && fieldState.error);
138
+ };
139
+
140
+ // HOC function
141
+ var withFormController = function withFormController(WrappedComponent) {
142
+ var WithFormControllerComponent = /*#__PURE__*/(0, _react.memo)(function (props) {
143
+ var propsFormRef = props.formRef,
144
+ formKey = props.formKey,
145
+ name = props.name,
146
+ datavalue = props.datavalue,
147
+ defaultvalue = props.defaultvalue,
148
+ validators = props.validators,
149
+ asyncValidators = props.asyncValidators,
150
+ required = props.required,
151
+ maxchars = props.maxchars,
152
+ regexp = props.regexp,
153
+ validationmessage = props.validationmessage,
154
+ hint = props.hint,
155
+ type = props.type,
156
+ observe = props.observe,
157
+ onBlur = props.onBlur,
158
+ fieldName = props.fieldName,
159
+ wrappedComponentProps = (0, _objectWithoutProperties2["default"])(props, _excluded);
160
+
161
+ // State and refs
162
+ var _useState = (0, _react.useState)(false),
163
+ touched = _useState[0],
164
+ setTouched = _useState[1];
165
+ var fieldRef = (0, _react.useRef)(null);
166
+ var observeRef = (0, _react.useRef)(observe);
167
+
168
+ // Context and proxy setup
169
+ var inputFieldName = fieldName || name;
170
+ var contextFormRef = (0, _formContext.useFormContext)();
171
+ var formRef = propsFormRef || contextFormRef;
172
+ var fieldProxy = (0, _WidgetProvider.useWidgetProxy)(name);
173
+ var form = (0, _WidgetProvider.useWidgetProxy)(formRef === null || formRef === void 0 ? void 0 : formRef.name);
174
+
175
+ // Form properties
176
+ var trigger = formRef === null || formRef === void 0 ? void 0 : formRef.trigger;
177
+ var validationType = (form === null || form === void 0 ? void 0 : form.validationtype) || (formRef === null || formRef === void 0 ? void 0 : formRef.validationtype) || "default";
178
+
179
+ // Custom hooks
180
+ useFormRegistration(name, fieldProxy, contextFormRef);
181
+ useExternalDataSync(datavalue, fieldRef);
182
+ var validationRules = useValidationRules(validationType, validators, asyncValidators, required, maxchars, regexp, validationmessage, form);
183
+ var htmlValidationProps = useHTMLValidationProps(validationType, required, maxchars, regexp);
184
+
185
+ // Update observeRef when observe changes
186
+ (0, _react.useEffect)(function () {
187
+ observeRef.current = observe;
188
+ }, [observe]);
189
+
190
+ // Event handlers
191
+ var createOnChangeHandler = (0, _react.useCallback)(function (field) {
192
+ return function (e, componentProps, newValue) {
193
+ var _props$onChange;
194
+ var valueToSet;
195
+ if (newValue !== undefined) {
196
+ valueToSet = newValue;
197
+ } else if (e && e.target) {
198
+ valueToSet = e.target.value;
199
+ } else if (e !== undefined) {
200
+ valueToSet = e;
201
+ }
202
+
203
+ // If the incoming value is an object and we have a datafield, extract the value
204
+ if (valueToSet && (0, _typeof2["default"])(valueToSet) === "object" && !Array.isArray(valueToSet) && props.datafield) {
205
+ valueToSet = valueToSet[props.datafield];
206
+ }
207
+ if (type === "number") {
208
+ field.onChange(valueToSet === "" || valueToSet === null ? "" : valueToSet);
209
+ } else {
210
+ field.onChange(valueToSet);
211
+ }
212
+ (_props$onChange = props.onChange) === null || _props$onChange === void 0 || _props$onChange.call(props, e, field, newValue, valueToSet);
213
+ };
214
+ }, [type, props.datafield]);
215
+ var createOnBlurHandler = (0, _react.useCallback)(function (field, fieldState) {
216
+ return function (e) {
217
+ var _observeRef$current;
218
+ setTouched(true);
219
+ field.onBlur();
220
+ var shouldTriggerValidation = validationType === "html" && trigger && !!fieldState.error || validationType !== "none" && ((_observeRef$current = observeRef.current) === null || _observeRef$current === void 0 ? void 0 : _observeRef$current.length) && trigger;
221
+ if (shouldTriggerValidation) {
222
+ setTimeout(function () {
223
+ trigger(formKey || inputFieldName);
224
+ });
225
+ }
226
+ onBlur === null || onBlur === void 0 || onBlur(e);
227
+ };
228
+ }, [trigger, formKey, inputFieldName, onBlur, validationType]);
229
+
230
+ // Render without Controller if no formRef
231
+ if (!(formRef !== null && formRef !== void 0 && formRef.control)) {
232
+ return __jsx(WrappedComponent, props);
233
+ }
234
+ return __jsx(_reactHookForm.Controller, {
235
+ control: formRef.control,
236
+ name: formKey || inputFieldName,
237
+ rules: validationRules,
238
+ defaultValue: datavalue !== undefined ? datavalue : defaultvalue,
239
+ render: function render(_ref) {
240
+ var _fieldState$error;
241
+ var field = _ref.field,
242
+ fieldState = _ref.fieldState;
243
+ // Store field reference for external updates
244
+ fieldRef.current = field;
245
+
246
+ // Process field value and get error state
247
+ var processedValue = processFieldValue(field.value, type, props.datafield);
248
+ var errorState = getErrorState(fieldState, validationType, touched);
249
+
250
+ // Build controlled props
251
+ var controlledProps = _objectSpread(_objectSpread(_objectSpread(_objectSpread({}, props), validationType === "html" ? htmlValidationProps : {}), {}, {
252
+ value: processedValue !== undefined ? processedValue : defaultvalue,
253
+ datavalue: processedValue !== undefined ? processedValue : defaultvalue,
254
+ onChange: createOnChangeHandler(field),
255
+ onBlur: createOnBlurHandler(field, fieldState),
256
+ ref: field.ref
257
+ }, errorState), {}, {
258
+ required: validationType === "html" || !propsFormRef ? required : undefined,
259
+ isControlled: true,
260
+ formfield: true,
261
+ fieldName: inputFieldName,
262
+ name: name,
263
+ isRequiredLabel: required,
264
+ maxchars: maxchars,
265
+ regexp: regexp,
266
+ className: (0, _clsx["default"])(wrappedComponentProps.className, {
267
+ hidden: contextFormRef === null || contextFormRef === void 0 ? void 0 : contextFormRef.isViewMode
268
+ })
269
+ });
270
+ return __jsx(_Box["default"], {
271
+ sx: {
272
+ width: "inherit"
273
+ }
274
+ }, __jsx(WrappedComponent, (0, _extends2["default"])({}, controlledProps, {
275
+ dataset: props.dataset,
276
+ displayfield: props.displayfield
277
+ })), __jsx("span", {
278
+ style: {
279
+ alignSelf: "flex-start"
280
+ },
281
+ className: "form-control-static app-label",
282
+ hidden: !(contextFormRef !== null && contextFormRef !== void 0 && contextFormRef.isViewMode)
283
+ }, function () {
284
+ var value = controlledProps.datavalue;
285
+ if (value && (0, _typeof2["default"])(value) === "object") {
286
+ if (props.datafield || props.displayfield) {
287
+ value = value[props.datafield || props.displayfield];
288
+ } else {
289
+ value = JSON.stringify(value);
290
+ }
291
+ }
292
+ return value;
293
+ }()), hint && !shouldShowErrorMessage(validationType, fieldState, touched) && __jsx(_Box["default"], {
294
+ component: "p",
295
+ className: "help-block",
296
+ "aria-hidden": "true",
297
+ role: "alert",
298
+ "aria-live": "polite",
299
+ sx: {
300
+ textAlign: "start",
301
+ width: "100%"
302
+ }
303
+ }, hint), shouldShowErrorMessage(validationType, fieldState, touched) && __jsx(_Box["default"], {
304
+ component: "p",
305
+ className: "help-block text-danger",
306
+ "aria-hidden": "false",
307
+ role: "alert",
308
+ "aria-live": "assertive",
309
+ sx: {
310
+ textAlign: "start",
311
+ width: "100%"
312
+ }
313
+ }, (_fieldState$error = fieldState.error) === null || _fieldState$error === void 0 ? void 0 : _fieldState$error.message));
314
+ }
315
+ });
316
+ });
317
+ WithFormControllerComponent.displayName = "withFormController(".concat(WrappedComponent.displayName || WrappedComponent.name || "Component", ")");
318
+ return WithFormControllerComponent;
319
+ };
320
+ var _default = exports["default"] = withFormController;