@wavemaker/react-runtime 11.14.3-rc.6401 → 11.15.0-2.247

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 (245) hide show
  1. package/actions/base-action.js +5 -7
  2. package/actions/login-action.js +7 -8
  3. package/actions/logout-action.js +5 -7
  4. package/actions/navigation-action.js +73 -18
  5. package/actions/notification-action.js +22 -8
  6. package/actions/timer-action.js +13 -15
  7. package/actions/toast.js +4 -2
  8. package/actions/toast.service.js +1 -2
  9. package/components/advanced/carousel/index.js +1 -1
  10. package/components/advanced/carousel/template.js +1 -1
  11. package/components/basic/anchor/index.js +31 -11
  12. package/components/basic/html/index.js +115 -24
  13. package/components/basic/icon/index.js +2 -1
  14. package/components/basic/iframe/index.js +2 -1
  15. package/components/basic/label/index.js +12 -9
  16. package/components/basic/message/index.js +12 -3
  17. package/components/basic/picture/index.js +11 -4
  18. package/components/basic/progress-bar/index.js +4 -1
  19. package/components/basic/progress-circle/index.js +34 -28
  20. package/components/basic/progress-circle/props.js +10 -2
  21. package/components/basic/richtexteditor/index.js +95 -94
  22. package/components/basic/search/index.js +401 -156
  23. package/components/basic/search/providers.js +126 -61
  24. package/components/basic/spinner/index.js +2 -1
  25. package/components/basic/tree/index.js +34 -34
  26. package/components/basic/tree/utils.js +10 -4
  27. package/components/chart/components/barColumnChart/index.js +36 -33
  28. package/components/chart/components/bubbleChart/index.js +35 -25
  29. package/components/chart/components/chartLegend/utils.js +2 -1
  30. package/components/chart/components/cumulativeLineChart/index.js +30 -26
  31. package/components/chart/components/lineAreaChart/index.js +50 -32
  32. package/components/chart/components/pieDonutChart/index.js +13 -4
  33. package/components/chart/hooks/useXAxisConfig.js +15 -8
  34. package/components/chart/index.js +223 -53
  35. package/components/chart/utils.js +12 -1
  36. package/components/constants.js +5 -2
  37. package/components/container/accordion/accordion-pane/index.js +17 -12
  38. package/components/container/accordion/index.js +9 -4
  39. package/components/container/alignment-utils.js +56 -1
  40. package/components/container/index.js +49 -20
  41. package/components/container/panel/components/panel-header/index.js +3 -4
  42. package/components/container/panel/index.js +15 -10
  43. package/components/container/repeat-template/index.js +33 -0
  44. package/components/container/tabs/index.js +83 -14
  45. package/components/container/tabs/tab-pane/index.js +33 -10
  46. package/components/container/tabs/utils.js +51 -0
  47. package/components/container/wizard/components/StepComponents.js +2 -1
  48. package/components/container/wizard/components/WizardStep.js +2 -1
  49. package/components/container/wizard/index.js +64 -35
  50. package/components/container/wizard/utils.js +46 -1
  51. package/components/container/wizard/wizard-step/index.js +11 -1
  52. package/components/data/card/card-content/index.js +1 -1
  53. package/components/data/form/base-form/index.js +985 -183
  54. package/components/data/form/base-form/props.js +3 -1
  55. package/components/data/form/base-form/utils.js +159 -1
  56. package/components/data/form/dynamic-fields/constant.js +53 -0
  57. package/components/data/form/dynamic-fields/index.js +10 -45
  58. package/components/data/form/dynamic-fields/utils.js +37 -2
  59. package/components/data/form/form-action/index.js +5 -4
  60. package/components/data/form/form-context.js +5 -1
  61. package/components/data/form/form-controller/utils.js +84 -0
  62. package/components/data/form/form-controller/validation-contrustor.js +402 -189
  63. package/components/data/form/form-controller/withFormController.js +191 -52
  64. package/components/data/form/form-field/base-field.js +67 -45
  65. package/components/data/form/form-field/index.js +28 -5
  66. package/components/data/form/form-header/index.js +3 -4
  67. package/components/data/form/index.js +20 -1
  68. package/components/data/list/components/ListDND.js +2 -1
  69. package/components/data/list/components/ListItem.js +6 -2
  70. package/components/data/list/components/ListItemWithTemplate.js +46 -2
  71. package/components/data/list/components/ListItems.js +17 -26
  72. package/components/data/list/components/ListPagination.js +3 -3
  73. package/components/data/list/components/StandardListItems.js +3 -4
  74. package/components/data/list/hooks/useListEffects.js +55 -14
  75. package/components/data/list/hooks/useListEventHandlers.js +3 -1
  76. package/components/data/list/hooks/useListState.js +3 -1
  77. package/components/data/list/hooks/usePaginatedGroupedData.js +18 -5
  78. package/components/data/list/index.js +74 -55
  79. package/components/data/list/utils/list-helpers.js +73 -35
  80. package/components/data/list/utils/list-widget-methods.js +138 -95
  81. package/components/data/live-filter/index.js +26 -15
  82. package/components/data/live-form/index.js +51 -18
  83. package/components/data/live-form/props.js +1 -1
  84. package/components/data/pagination/components/BasicPagination.js +71 -16
  85. package/components/data/pagination/components/PageSizeSelector.js +8 -3
  86. package/components/data/pagination/components/TotalRecords.js +1 -5
  87. package/components/data/pagination/hooks/usePagination.js +349 -66
  88. package/components/data/pagination/index.js +137 -19
  89. package/components/data/table/components/AddNewRow.js +5 -1
  90. package/components/data/table/components/EditableCell.js +2 -2
  91. package/components/data/table/components/RowCells.js +64 -0
  92. package/components/data/table/components/RowExpansionButton.js +2 -2
  93. package/components/data/table/components/SummaryCell.js +111 -0
  94. package/components/data/table/components/SummaryRow.js +54 -0
  95. package/components/data/table/components/SummaryRowFooter.js +46 -0
  96. package/components/data/table/components/TableBody.js +61 -59
  97. package/components/data/table/components/TableDataRow.js +109 -0
  98. package/components/data/table/components/TableFilters.js +225 -121
  99. package/components/data/table/components/TableHeader.js +291 -23
  100. package/components/data/table/components/TablePanelHeading.js +139 -8
  101. package/components/data/table/components/index.js +22 -1
  102. package/components/data/table/hooks/use-edited-rows.js +141 -0
  103. package/components/data/table/hooks/useCellState.js +5 -12
  104. package/components/data/table/hooks/useFormWidget.js +58 -52
  105. package/components/data/table/hooks/usePaginationState.js +45 -24
  106. package/components/data/table/hooks/usePanelStructure.js +4 -4
  107. package/components/data/table/hooks/useRowHandlers.js +39 -5
  108. package/components/data/table/hooks/useRowSelection.js +244 -50
  109. package/components/data/table/hooks/useServerSideSorting.js +81 -37
  110. package/components/data/table/hooks/useTableColumns.js +211 -118
  111. package/components/data/table/hooks/useTableData.js +54 -9
  112. package/components/data/table/hooks/useTableEdit.js +272 -97
  113. package/components/data/table/hooks/useTableEffects.js +31 -13
  114. package/components/data/table/hooks/useTableFilter.js +1 -1
  115. package/components/data/table/hooks/useTableInitialization.js +23 -22
  116. package/components/data/table/hooks/useTableState.js +11 -5
  117. package/components/data/table/hooks/useTableStateManager.js +140 -65
  118. package/components/data/table/index.js +637 -274
  119. package/components/data/table/live-table/index.js +54 -22
  120. package/components/data/table/table-action/index.js +1 -1
  121. package/components/data/table/table-group/index.js +26 -0
  122. package/components/data/table/table-row-action/index.js +32 -18
  123. package/components/data/table/utils/buildSelectionColumns.js +12 -21
  124. package/components/data/table/utils/columnBuilder.js +29 -14
  125. package/components/data/table/utils/columnProxy.js +68 -1
  126. package/components/data/table/utils/constants.js +6 -2
  127. package/components/data/table/utils/crud-handlers.js +68 -63
  128. package/components/data/table/utils/groupHeaderUtils.js +102 -0
  129. package/components/data/table/utils/index.js +210 -21
  130. package/components/data/table/utils/renderDisplayCell.js +6 -6
  131. package/components/data/table/utils/selectionUtils.js +25 -26
  132. package/components/data/table/utils/validation.js +1 -0
  133. package/components/data/utils/filter-field-util.js +3 -3
  134. package/components/dialogs/alert-dialog/index.js +1 -1
  135. package/components/dialogs/confirm-dialog/index.js +1 -1
  136. package/components/dialogs/dialog/index.js +4 -1
  137. package/components/dialogs/dialog-content/index.js +3 -1
  138. package/components/dialogs/dialog-header/index.js +2 -2
  139. package/components/dialogs/iframe-dialog/index.js +11 -5
  140. package/components/dialogs/index.js +1 -1
  141. package/components/dialogs/login-dialog/index.js +1 -1
  142. package/components/dialogs/page-dialog/index.js +1 -1
  143. package/components/form/button/index.js +33 -7
  144. package/components/input/calendar/index.js +18 -6
  145. package/components/input/chips/index.js +99 -28
  146. package/components/input/chips/utils.js +34 -4
  147. package/components/input/color-picker/index.js +74 -25
  148. package/components/input/composite/index.js +3 -3
  149. package/components/input/currency/index.js +35 -49
  150. package/components/input/default/checkbox/index.js +23 -28
  151. package/components/input/default/checkboxset/index.js +38 -18
  152. package/components/input/default/checkboxset/utils.js +30 -0
  153. package/components/input/default/radioset/index.js +36 -39
  154. package/components/input/default/switch/index.js +30 -13
  155. package/components/input/epoch/date/index.js +130 -69
  156. package/components/input/epoch/date/utils.js +94 -1
  157. package/components/input/epoch/datetime/index.js +72 -22
  158. package/components/input/epoch/datetime/utils.js +49 -10
  159. package/components/input/epoch/time/index.js +68 -19
  160. package/components/input/epoch/time/utils.js +62 -14
  161. package/components/input/fileupload/Utils.js +12 -7
  162. package/components/input/fileupload/components/MultiUpload.js +2 -6
  163. package/components/input/fileupload/components/SingleUpload.js +3 -7
  164. package/components/input/fileupload/index.js +6 -10
  165. package/components/input/fileupload/useFileUpload.js +16 -5
  166. package/components/input/number/index.js +158 -43
  167. package/components/input/rating/index.js +90 -7
  168. package/components/input/select/index.js +209 -72
  169. package/components/input/slider/index.js +84 -26
  170. package/components/input/text/index.js +38 -18
  171. package/components/input/text/util.js +283 -130
  172. package/components/input/textarea/index.js +13 -10
  173. package/components/input/upload/index.js +124 -0
  174. package/components/input/upload/props.js +5 -0
  175. package/components/input/util/index.js +11 -0
  176. package/components/navbar/index.js +51 -3
  177. package/components/navbar/nav/index.js +46 -16
  178. package/components/navbar/nav-item/index.js +11 -5
  179. package/components/navigation/menu/components/ListItems.js +3 -0
  180. package/components/navigation/menu/constants.js +2 -1
  181. package/components/navigation/menu/hooks/useHoverState.hook.js +48 -0
  182. package/components/navigation/menu/hooks/useKeyboardMovements.hook.js +37 -0
  183. package/components/navigation/menu/hooks/useTransformedDataset.hook.js +15 -0
  184. package/components/navigation/menu/index.js +326 -188
  185. package/components/navigation/menu/utils/action-task.js +14 -0
  186. package/components/navigation/menu/utils/role-filter.js +76 -0
  187. package/components/navigation/popover/index.js +105 -32
  188. package/components/page/partial-container/index.js +34 -5
  189. package/components/prefab/index.js +2 -4
  190. package/context/PrefabContext.js +10 -6
  191. package/context/WidgetProvider.js +30 -31
  192. package/core/app.service.js +1 -1
  193. package/core/constants/events.js +57 -1
  194. package/core/dialog.service.js +1 -2
  195. package/core/event-notifier.js +1 -2
  196. package/core/formatter/array-formatters.js +33 -0
  197. package/core/formatter/date-formatters.js +2 -4
  198. package/core/formatter/index.js +2 -1
  199. package/core/formatter/number-formatters.js +5 -10
  200. package/core/formatter/security-formatters.js +2 -4
  201. package/core/formatter/string-formatters.js +3 -6
  202. package/core/proxy-service.js +85 -13
  203. package/core/script-registry.js +108 -48
  204. package/core/util/common.js +4 -4
  205. package/core/util/compare.js +30 -0
  206. package/core/util/dom.js +8 -8
  207. package/core/util/index.js +16 -6
  208. package/core/util/safe-is-equal.js +156 -0
  209. package/core/util/security.js +1 -2
  210. package/core/util/utils.js +16 -7
  211. package/higherOrder/BaseApp.js +108 -65
  212. package/higherOrder/BaseDateTime.js +31 -13
  213. package/higherOrder/BasePage.js +268 -144
  214. package/higherOrder/BasePartial.js +1 -1
  215. package/higherOrder/BasePrefab.js +33 -15
  216. package/higherOrder/DataNav.js +99 -16
  217. package/higherOrder/helper.js +41 -3
  218. package/higherOrder/withBaseWrapper.js +41 -28
  219. package/hooks/useAuth.js +11 -5
  220. package/hooks/useHttp.js +280 -94
  221. package/mui-config/theme-provider.js +1 -1
  222. package/mui-config/theme.js +1 -1
  223. package/package-lock.json +423 -331
  224. package/package.json +8 -8
  225. package/store/bindActions/i18nActions.js +18 -0
  226. package/store/index.js +3 -1
  227. package/store/slices/appConfigSlice.js +2 -2
  228. package/store/slices/authSlice.js +31 -28
  229. package/store/slices/i18nSlice.js +2 -2
  230. package/store/slices/navigationSlice.js +35 -0
  231. package/store/viewport.service.js +255 -0
  232. package/utils/attr.js +35 -0
  233. package/utils/dataset-util.js +1 -2
  234. package/utils/form-state.util.js +43 -12
  235. package/utils/form-utils.js +47 -2
  236. package/utils/format-util.js +28 -13
  237. package/utils/page-params-util.js +33 -1
  238. package/utils/state-persistance.js +72 -13
  239. package/utils/transformedDataset-utils.js +35 -24
  240. package/variables/base-variable.js +12 -14
  241. package/variables/crud-variable.js +225 -0
  242. package/variables/live-variable.js +56 -20
  243. package/variables/metadata.service.js +123 -0
  244. package/variables/model-variable.js +21 -15
  245. package/variables/service-variable.js +88 -83
@@ -6,50 +6,241 @@ Object.defineProperty(exports, "__esModule", {
6
6
  });
7
7
  exports.createValidationRules = void 0;
8
8
  var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"));
9
- var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
10
9
  var _typeof2 = _interopRequireDefault(require("@babel/runtime/helpers/typeof"));
11
- var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
12
10
  var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
11
+ var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
12
+ var _momentTimezone = _interopRequireDefault(require("moment-timezone"));
13
13
  var _lodashEs = require("lodash-es");
14
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
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
+ // Helper function to resolve error message (string or function)
17
+ var resolveErrorMessage = /*#__PURE__*/function () {
18
+ var _ref = (0, _asyncToGenerator2["default"])(/*#__PURE__*/_regenerator["default"].mark(function _callee(errorMessage, value, fieldName, form) {
19
+ var result;
20
+ return _regenerator["default"].wrap(function _callee$(_context) {
21
+ while (1) switch (_context.prev = _context.next) {
22
+ case 0:
23
+ if (!(0, _lodashEs.isFunction)(errorMessage)) {
24
+ _context.next = 12;
25
+ break;
26
+ }
27
+ _context.prev = 1;
28
+ _context.next = 4;
29
+ return errorMessage({
30
+ value: value
31
+ }, form);
32
+ case 4:
33
+ result = _context.sent;
34
+ return _context.abrupt("return", result || "Validation failed");
35
+ case 8:
36
+ _context.prev = 8;
37
+ _context.t0 = _context["catch"](1);
38
+ console.warn("Error message function threw an error:", _context.t0);
39
+ return _context.abrupt("return", "Validation error occurred");
40
+ case 12:
41
+ return _context.abrupt("return", errorMessage);
42
+ case 13:
43
+ case "end":
44
+ return _context.stop();
45
+ }
46
+ }, _callee, null, [[1, 8]]);
47
+ }));
48
+ return function resolveErrorMessage(_x, _x2, _x3, _x4) {
49
+ return _ref.apply(this, arguments);
50
+ };
51
+ }();
52
+
53
+ // function to parse time string into minutes
54
+ var parseTime = function parseTime(time) {
55
+ if (!time || typeof time !== "string") return null;
56
+ var timeFormats = ["HH:mm:ss", "HH:mm", "H:mm:ss", "H:mm", "hh:mm:ss a", "hh:mm a", "h:mm:ss a", "h:mm a"];
57
+ var parsedMoment = (0, _momentTimezone["default"])(time, timeFormats, true);
58
+ if (parsedMoment.isValid()) {
59
+ return parsedMoment.hours() * 60 + parsedMoment.minutes();
60
+ }
61
+ return null;
62
+ };
16
63
  var validationHandlers = {
17
- required: function required(config, rules) {
64
+ required: function required(config, rules, form, fieldName) {
18
65
  if (config.validator) {
19
- rules.required = config.errorMessage;
66
+ if ((0, _lodashEs.isFunction)(config.errorMessage)) {
67
+ rules.validate = _objectSpread(_objectSpread({}, rules.validate), {}, {
68
+ required: function () {
69
+ var _required = (0, _asyncToGenerator2["default"])(/*#__PURE__*/_regenerator["default"].mark(function _callee2(value) {
70
+ return _regenerator["default"].wrap(function _callee2$(_context2) {
71
+ while (1) switch (_context2.prev = _context2.next) {
72
+ case 0:
73
+ if (!(value != null && value !== "")) {
74
+ _context2.next = 2;
75
+ break;
76
+ }
77
+ return _context2.abrupt("return", true);
78
+ case 2:
79
+ _context2.next = 4;
80
+ return resolveErrorMessage(config.errorMessage, value, fieldName, form);
81
+ case 4:
82
+ return _context2.abrupt("return", _context2.sent);
83
+ case 5:
84
+ case "end":
85
+ return _context2.stop();
86
+ }
87
+ }, _callee2);
88
+ }));
89
+ function required(_x5) {
90
+ return _required.apply(this, arguments);
91
+ }
92
+ return required;
93
+ }()
94
+ });
95
+ } else {
96
+ rules.required = config.errorMessage;
97
+ }
20
98
  }
21
99
  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;
100
+ noWhitespaces: function () {
101
+ var _noWhitespaces = (0, _asyncToGenerator2["default"])(/*#__PURE__*/_regenerator["default"].mark(function _callee3(value) {
102
+ return _regenerator["default"].wrap(function _callee3$(_context3) {
103
+ while (1) switch (_context3.prev = _context3.next) {
104
+ case 0:
105
+ if (!(typeof value === "string" && value.length > 0 && value.trim() === "")) {
106
+ _context3.next = 4;
107
+ break;
108
+ }
109
+ _context3.next = 3;
110
+ return resolveErrorMessage(config.errorMessage, value, fieldName, form);
111
+ case 3:
112
+ return _context3.abrupt("return", _context3.sent);
113
+ case 4:
114
+ return _context3.abrupt("return", true);
115
+ case 5:
116
+ case "end":
117
+ return _context3.stop();
118
+ }
119
+ }, _callee3);
120
+ }));
121
+ function noWhitespaces(_x6) {
122
+ return _noWhitespaces.apply(this, arguments);
25
123
  }
26
- return true;
27
- }
124
+ return noWhitespaces;
125
+ }()
28
126
  });
29
127
  return rules;
30
128
  },
31
- maxchars: function maxchars(config, rules) {
32
- rules.maxLength = {
33
- value: config.validator,
34
- message: config.errorMessage
35
- };
129
+ maxchars: function maxchars(config, rules, form, fieldName) {
130
+ if ((0, _lodashEs.isFunction)(config.errorMessage)) {
131
+ rules.validate = _objectSpread(_objectSpread({}, rules.validate), {}, {
132
+ maxLength: function () {
133
+ var _maxLength = (0, _asyncToGenerator2["default"])(/*#__PURE__*/_regenerator["default"].mark(function _callee4(value) {
134
+ return _regenerator["default"].wrap(function _callee4$(_context4) {
135
+ while (1) switch (_context4.prev = _context4.next) {
136
+ case 0:
137
+ if (!(value == null || value.length <= config.validator)) {
138
+ _context4.next = 2;
139
+ break;
140
+ }
141
+ return _context4.abrupt("return", true);
142
+ case 2:
143
+ _context4.next = 4;
144
+ return resolveErrorMessage(config.errorMessage, value, fieldName, form);
145
+ case 4:
146
+ return _context4.abrupt("return", _context4.sent);
147
+ case 5:
148
+ case "end":
149
+ return _context4.stop();
150
+ }
151
+ }, _callee4);
152
+ }));
153
+ function maxLength(_x7) {
154
+ return _maxLength.apply(this, arguments);
155
+ }
156
+ return maxLength;
157
+ }()
158
+ });
159
+ } else {
160
+ rules.maxLength = {
161
+ value: config.validator,
162
+ message: config.errorMessage
163
+ };
164
+ }
36
165
  return rules;
37
166
  },
38
- minvalue: function minvalue(config, rules) {
39
- rules.min = {
40
- value: config.validator,
41
- message: config.errorMessage
42
- };
167
+ minvalue: function minvalue(config, rules, form, fieldName) {
168
+ if ((0, _lodashEs.isFunction)(config.errorMessage)) {
169
+ rules.validate = _objectSpread(_objectSpread({}, rules.validate), {}, {
170
+ minValue: function () {
171
+ var _minValue = (0, _asyncToGenerator2["default"])(/*#__PURE__*/_regenerator["default"].mark(function _callee5(value) {
172
+ return _regenerator["default"].wrap(function _callee5$(_context5) {
173
+ while (1) switch (_context5.prev = _context5.next) {
174
+ case 0:
175
+ if (!(value == null || Number(value) >= config.validator)) {
176
+ _context5.next = 2;
177
+ break;
178
+ }
179
+ return _context5.abrupt("return", true);
180
+ case 2:
181
+ _context5.next = 4;
182
+ return resolveErrorMessage(config.errorMessage, value, fieldName, form);
183
+ case 4:
184
+ return _context5.abrupt("return", _context5.sent);
185
+ case 5:
186
+ case "end":
187
+ return _context5.stop();
188
+ }
189
+ }, _callee5);
190
+ }));
191
+ function minValue(_x8) {
192
+ return _minValue.apply(this, arguments);
193
+ }
194
+ return minValue;
195
+ }()
196
+ });
197
+ } else {
198
+ rules.min = {
199
+ value: config.validator,
200
+ message: config.errorMessage
201
+ };
202
+ }
43
203
  return rules;
44
204
  },
45
- maxvalue: function maxvalue(config, rules) {
46
- rules.max = {
47
- value: config.validator,
48
- message: config.errorMessage
49
- };
205
+ maxvalue: function maxvalue(config, rules, form, fieldName) {
206
+ if ((0, _lodashEs.isFunction)(config.errorMessage)) {
207
+ rules.validate = _objectSpread(_objectSpread({}, rules.validate), {}, {
208
+ maxValue: function () {
209
+ var _maxValue = (0, _asyncToGenerator2["default"])(/*#__PURE__*/_regenerator["default"].mark(function _callee6(value) {
210
+ return _regenerator["default"].wrap(function _callee6$(_context6) {
211
+ while (1) switch (_context6.prev = _context6.next) {
212
+ case 0:
213
+ if (!(value == null || Number(value) <= config.validator)) {
214
+ _context6.next = 2;
215
+ break;
216
+ }
217
+ return _context6.abrupt("return", true);
218
+ case 2:
219
+ _context6.next = 4;
220
+ return resolveErrorMessage(config.errorMessage, value, fieldName, form);
221
+ case 4:
222
+ return _context6.abrupt("return", _context6.sent);
223
+ case 5:
224
+ case "end":
225
+ return _context6.stop();
226
+ }
227
+ }, _callee6);
228
+ }));
229
+ function maxValue(_x9) {
230
+ return _maxValue.apply(this, arguments);
231
+ }
232
+ return maxValue;
233
+ }()
234
+ });
235
+ } else {
236
+ rules.max = {
237
+ value: config.validator,
238
+ message: config.errorMessage
239
+ };
240
+ }
50
241
  return rules;
51
242
  },
52
- regexp: function regexp(config, rules) {
243
+ regexp: function regexp(config, rules, form, fieldName) {
53
244
  var pattern;
54
245
  try {
55
246
  pattern = (0, _lodashEs.isString)(config.validator) ? new RegExp(config.validator.replace(/^\/|\/$/g, "")) : config.validator;
@@ -57,121 +248,48 @@ var validationHandlers = {
57
248
  console.warn("Invalid regexp string:", config.validator);
58
249
  return rules;
59
250
  }
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
- });
251
+ if ((0, _lodashEs.isFunction)(config.errorMessage)) {
252
+ rules.validate = _objectSpread(_objectSpread({}, rules.validate), {}, {
253
+ regexp: function () {
254
+ var _regexp = (0, _asyncToGenerator2["default"])(/*#__PURE__*/_regenerator["default"].mark(function _callee7(value) {
255
+ return _regenerator["default"].wrap(function _callee7$(_context7) {
256
+ while (1) switch (_context7.prev = _context7.next) {
257
+ case 0:
258
+ if (!(value == null || pattern.test(value))) {
259
+ _context7.next = 2;
260
+ break;
261
+ }
262
+ return _context7.abrupt("return", true);
263
+ case 2:
264
+ _context7.next = 4;
265
+ return resolveErrorMessage(config.errorMessage, value, fieldName, form);
266
+ case 4:
267
+ return _context7.abrupt("return", _context7.sent);
268
+ case 5:
269
+ case "end":
270
+ return _context7.stop();
271
+ }
272
+ }, _callee7);
273
+ }));
274
+ function regexp(_x0) {
275
+ return _regexp.apply(this, arguments);
276
+ }
277
+ return regexp;
278
+ }()
279
+ });
280
+ } else {
281
+ rules.pattern = {
282
+ value: pattern,
283
+ message: config.errorMessage
284
+ };
285
+ }
168
286
  return rules;
169
287
  }
170
288
  };
171
289
 
172
290
  // Type guard functions using lodash
173
291
  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;
292
+ return config && (0, _typeof2["default"])(config) === "object" && !Array.isArray(config) && typeof config !== "function" && (0, _lodashEs.isString)(config.type) && ((0, _lodashEs.isString)(config.errorMessage) || (0, _lodashEs.isFunction)(config.errorMessage)) && config.validator !== undefined;
175
293
  };
176
294
  var isFunctionValidator = function isFunctionValidator(config) {
177
295
  return typeof config === "function";
@@ -179,36 +297,137 @@ var isFunctionValidator = function isFunctionValidator(config) {
179
297
  var validateValidatorConfig = function validateValidatorConfig(config) {
180
298
  var type = config.type,
181
299
  validator = config.validator;
300
+ if (typeof validator === "function") {
301
+ return true;
302
+ }
182
303
  switch (type) {
183
304
  case "required":
184
- return (0, _lodashEs.isBoolean)(validator);
305
+ if ((0, _lodashEs.isBoolean)(validator)) {
306
+ return true;
307
+ }
308
+ if ((0, _lodashEs.isString)(validator)) {
309
+ var str = validator;
310
+ return str.toLowerCase() === "true" || str === "1";
311
+ }
312
+ return false;
185
313
  case "maxchars":
186
314
  case "minvalue":
187
315
  case "maxvalue":
188
- return (0, _lodashEs.isNumber)(validator);
316
+ // Accept number or numeric string
317
+ if ((0, _lodashEs.isNumber)(validator)) {
318
+ return !isNaN(validator) && isFinite(validator);
319
+ }
320
+ if ((0, _lodashEs.isString)(validator)) {
321
+ var numValue = Number(validator);
322
+ return !isNaN(numValue) && isFinite(numValue);
323
+ }
324
+ return false;
189
325
  case "regexp":
190
- return (0, _lodashEs.isRegExp)(validator) || (0, _lodashEs.isString)(validator) && function () {
326
+ // Handle RegExp object, string patterns, and edge cases
327
+ if ((0, _lodashEs.isRegExp)(validator)) {
328
+ return true;
329
+ }
330
+ if ((0, _lodashEs.isString)(validator)) {
331
+ // Empty string is valid (matches everything)
332
+ if (validator === "") {
333
+ return true;
334
+ }
191
335
  try {
192
- new RegExp(validator.replace(/^\/|\/$/g, ""));
336
+ // Try to create RegExp, handling patterns with or without slashes
337
+ var pattern = validator.replace(/^\/|\/$/g, "");
338
+ new RegExp(pattern);
193
339
  return true;
194
- } catch (_unused3) {
340
+ } catch (_unused) {
195
341
  return false;
196
342
  }
197
- }();
343
+ }
344
+ return false;
198
345
  case "mindate":
199
346
  case "maxdate":
200
- return (0, _lodashEs.isString)(validator) || (0, _lodashEs.isDate)(validator);
347
+ // Accept string or Date object
348
+ if ((0, _lodashEs.isString)(validator)) {
349
+ // Validate that it's a parseable date
350
+ var date = new Date(validator);
351
+ return !isNaN(date.getTime());
352
+ }
353
+ if ((0, _lodashEs.isDate)(validator)) {
354
+ return !isNaN(validator.getTime());
355
+ }
356
+ return false;
201
357
  case "mintime":
202
358
  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);
359
+ // Accept time strings in various formats
360
+ if (!(0, _lodashEs.isString)(validator)) {
361
+ return false;
362
+ }
363
+ // Support multiple time formats: HH:mm, HH:mm:ss, H:mm, etc.
364
+ var timeFormats = [/^\d{1,2}:\d{2}$/,
365
+ // H:mm or HH:mm
366
+ /^\d{1,2}:\d{2}:\d{2}$/,
367
+ // H:mm:ss or HH:mm:ss
368
+ /^\d{1,2}:\d{2}\s*(AM|PM|am|pm)$/i,
369
+ // h:mm AM/PM
370
+ /^\d{1,2}:\d{2}:\d{2}\s*(AM|PM|am|pm)$/i // h:mm:ss AM/PM
371
+ ];
372
+ return timeFormats.some(function (format) {
373
+ return format.test(validator.trim());
207
374
  });
375
+ case "excludedates":
376
+ // Accept array of strings/Dates or comma-separated string
377
+ if ((0, _lodashEs.isArray)(validator)) {
378
+ return validator.every(function (v) {
379
+ if ((0, _lodashEs.isString)(v)) {
380
+ var _date = new Date(v);
381
+ return !isNaN(_date.getTime());
382
+ }
383
+ if ((0, _lodashEs.isDate)(v)) {
384
+ return !isNaN(v.getTime());
385
+ }
386
+ return false;
387
+ });
388
+ }
389
+ if ((0, _lodashEs.isString)(validator)) {
390
+ // Handle comma-separated string
391
+ var validatorStr = validator;
392
+ var dates = validatorStr.split(",").map(function (d) {
393
+ return d.trim();
394
+ }).filter(function (d) {
395
+ return d.length > 0;
396
+ });
397
+ return dates.every(function (dateStr) {
398
+ var date = new Date(dateStr);
399
+ return !isNaN(date.getTime());
400
+ });
401
+ }
402
+ return false;
208
403
  case "excludedays":
209
- return (0, _lodashEs.isArray)(validator) && validator.every(function (v) {
210
- return (0, _lodashEs.isNumber)(v) && v >= 0 && v <= 6;
211
- });
404
+ // Accept array of numbers or comma-separated string of numbers (0-6)
405
+ if ((0, _lodashEs.isArray)(validator)) {
406
+ return validator.every(function (v) {
407
+ if ((0, _lodashEs.isNumber)(v)) {
408
+ return v >= 0 && v <= 6 && Number.isInteger(v);
409
+ }
410
+ if ((0, _lodashEs.isString)(v)) {
411
+ var num = Number(v);
412
+ return !isNaN(num) && num >= 0 && num <= 6 && Number.isInteger(num);
413
+ }
414
+ return false;
415
+ });
416
+ }
417
+ if ((0, _lodashEs.isString)(validator)) {
418
+ // Handle comma-separated string
419
+ var _validatorStr = validator;
420
+ var days = _validatorStr.split(",").map(function (d) {
421
+ return d.trim();
422
+ }).filter(function (d) {
423
+ return d.length > 0;
424
+ });
425
+ return days.every(function (dayStr) {
426
+ var num = Number(dayStr);
427
+ return !isNaN(num) && num >= 0 && num <= 6 && Number.isInteger(num);
428
+ });
429
+ }
430
+ return false;
212
431
  default:
213
432
  return false;
214
433
  }
@@ -233,76 +452,70 @@ var createValidationRules = exports.createValidationRules = function createValid
233
452
  });
234
453
  var rules = (0, _lodashEs.reduce)(validConfigs, function (acc, config) {
235
454
  var handler = validationHandlers[config.type];
236
- if (handler) return handler(config, acc);
455
+ if (handler) return handler(config, acc, form, fieldName);
237
456
  console.warn("No handler found for validator type: ".concat(config.type));
238
457
  return acc;
239
458
  }, {});
240
459
  if (functionValidators.length > 0) {
241
460
  var functionValidateRules = (0, _lodashEs.reduce)(functionValidators, function (acc, validator, index) {
242
461
  acc["customValidator".concat(index)] = /*#__PURE__*/function () {
243
- var _ref = (0, _asyncToGenerator2["default"])(/*#__PURE__*/_regenerator["default"].mark(function _callee(value) {
462
+ var _ref2 = (0, _asyncToGenerator2["default"])(/*#__PURE__*/_regenerator["default"].mark(function _callee8(value) {
244
463
  var result;
245
- return _regenerator["default"].wrap(function _callee$(_context) {
246
- while (1) switch (_context.prev = _context.next) {
464
+ return _regenerator["default"].wrap(function _callee8$(_context8) {
465
+ while (1) switch (_context8.prev = _context8.next) {
247
466
  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;
467
+ _context8.prev = 0;
468
+ _context8.next = 3;
256
469
  return validator({
257
470
  value: value,
258
471
  fieldName: fieldName
259
472
  }, form);
260
- case 5:
261
- result = _context.sent;
473
+ case 3:
474
+ result = _context8.sent;
262
475
  if (!(typeof result === "string")) {
263
- _context.next = 8;
476
+ _context8.next = 6;
264
477
  break;
265
478
  }
266
- return _context.abrupt("return", result);
267
- case 8:
479
+ return _context8.abrupt("return", result);
480
+ case 6:
268
481
  if (!(typeof result === "boolean")) {
269
- _context.next = 10;
482
+ _context8.next = 8;
270
483
  break;
271
484
  }
272
- return _context.abrupt("return", result || "Validation failed");
273
- case 10:
485
+ return _context8.abrupt("return", result || "Validation failed");
486
+ case 8:
274
487
  if (!(result !== null && result !== void 0 && result.errorMessage)) {
275
- _context.next = 12;
488
+ _context8.next = 10;
276
489
  break;
277
490
  }
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;
491
+ return _context8.abrupt("return", result.errorMessage);
492
+ case 10:
493
+ return _context8.abrupt("return", true);
494
+ case 13:
495
+ _context8.prev = 13;
496
+ _context8.t0 = _context8["catch"](0);
497
+ if (!(_context8.t0 !== null && _context8.t0 !== void 0 && _context8.t0.errorMessage)) {
498
+ _context8.next = 17;
286
499
  break;
287
500
  }
288
- return _context.abrupt("return", _context.t0.errorMessage);
289
- case 19:
290
- if (!(typeof _context.t0 === "string")) {
291
- _context.next = 21;
501
+ return _context8.abrupt("return", _context8.t0.errorMessage);
502
+ case 17:
503
+ if (!(typeof _context8.t0 === "string")) {
504
+ _context8.next = 19;
292
505
  break;
293
506
  }
294
- return _context.abrupt("return", _context.t0);
507
+ return _context8.abrupt("return", _context8.t0);
508
+ case 19:
509
+ console.warn("Function validator threw an error:", _context8.t0);
510
+ return _context8.abrupt("return", "Validation error occurred");
295
511
  case 21:
296
- console.warn("Function validator threw an error:", _context.t0);
297
- return _context.abrupt("return", "Validation error occurred");
298
- case 23:
299
512
  case "end":
300
- return _context.stop();
513
+ return _context8.stop();
301
514
  }
302
- }, _callee, null, [[0, 15]]);
515
+ }, _callee8, null, [[0, 13]]);
303
516
  }));
304
- return function (_x) {
305
- return _ref.apply(this, arguments);
517
+ return function (_x1) {
518
+ return _ref2.apply(this, arguments);
306
519
  };
307
520
  }();
308
521
  return acc;