@wavemaker/react-runtime 11.14.2-rc.6311 → 11.15.0-1.246

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 +840 -740
  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
@@ -17,6 +17,7 @@ var _withBaseWrapper = require("@wavemaker/react-runtime/higherOrder/withBaseWra
17
17
  var _withFormController = _interopRequireDefault(require("@wavemaker/react-runtime/components/data/form/form-controller/withFormController"));
18
18
  var _util = require("./util");
19
19
  var _delay = _interopRequireDefault(require("lodash/delay"));
20
+ var _util2 = require("../util");
20
21
  function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function _interopRequireWildcard(e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, "default": e }; if (null === e || "object" != _typeof(e) && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (var _t2 in e) "default" !== _t2 && {}.hasOwnProperty.call(e, _t2) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, _t2)) && (i.get || i.set) ? o(f, _t2, i) : f[_t2] = e[_t2]); return f; })(e, t); }
21
22
  var __jsx = _react["default"].createElement;
22
23
  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; }
@@ -52,7 +53,8 @@ var WmText = /*#__PURE__*/(0, _react.memo)(function (props) {
52
53
  regexp = props.regexp,
53
54
  _props$updateon = props.updateon,
54
55
  updateon = _props$updateon === void 0 ? "blur" : _props$updateon,
55
- autocapitalize = props.autocapitalize,
56
+ _props$autocapitalize = props.autocapitalize,
57
+ autocapitalize = _props$autocapitalize === void 0 ? "none" : _props$autocapitalize,
56
58
  autotrim = props.autotrim,
57
59
  onChange = props.onChange,
58
60
  onBlur = props.onBlur,
@@ -245,55 +247,71 @@ var WmText = /*#__PURE__*/(0, _react.memo)(function (props) {
245
247
  isInternalChange.current = true;
246
248
  var inputEl = e.target;
247
249
  var newValue = inputEl.value;
250
+ var previousValue = rawValue;
248
251
  cursorPositionRef.current = inputEl.selectionStart || 0;
249
252
 
250
- // Extract digits for validation if displayformat is present
251
- var digitsOnly = displayformat ? newValue.replace(/\D/g, "") : newValue;
253
+ // Manual autocapitalize implementation
254
+ var capitalizeResult = (0, _util.applyAutoCapitalize)(newValue, previousValue, cursorPositionRef.current, autocapitalize);
255
+ newValue = capitalizeResult.value;
256
+
257
+ // Extract meaningful characters for validation if displayformat is present
258
+ var cleanValue = displayformat ? (0, _util.removeDisplayFormat)(newValue, displayformat) : newValue;
252
259
 
253
260
  // Enforce maxchars constraint BEFORE setting state
254
- if (maxchars && digitsOnly.length > maxchars) {
261
+ if (maxchars && cleanValue.length > maxchars) {
255
262
  // Prevent input that exceeds maxchars
256
263
  return;
257
264
  }
258
265
 
259
- // Enforce displayformat digit limit
266
+ // Enforce displayformat character limit using the generic format parser
260
267
  if (displayformat) {
261
- var formatDigits = displayformat.replace(/[^9]/g, "");
262
- var maxDigits = formatDigits.length;
263
- if (digitsOnly.length > maxDigits) {
264
- // Prevent input that exceeds format digit limit
268
+ var maxFormatLength = (0, _util.getFormatMaxLength)(displayformat);
269
+ if (cleanValue.length > maxFormatLength) {
270
+ // Prevent input that exceeds format character limit
265
271
  return;
266
272
  }
267
273
  }
268
274
 
269
275
  // Enforce min/max value constraints for number type
270
276
  if (props.type === "number") {
271
- var numValue = (0, _toNumber["default"])(digitsOnly);
277
+ var numValue = (0, _toNumber["default"])(cleanValue);
272
278
  if (props.maxvalue !== undefined && numValue > props.maxvalue) {
273
279
  // Prevent input that exceeds maxvalue
274
280
  return;
275
281
  }
276
- if (props.minvalue !== undefined && numValue < props.minvalue && digitsOnly.length >= String(props.minvalue).length) {
282
+ if (props.minvalue !== undefined && numValue < props.minvalue && cleanValue.length >= String(props.minvalue).length) {
277
283
  // Only prevent if the number length is complete and still below minvalue
278
284
  // This allows typing "1" when minvalue is 10
279
285
  var minLength = String(props.minvalue).length;
280
- if (digitsOnly.length >= minLength) {
286
+ if (cleanValue.length >= minLength) {
281
287
  return;
282
288
  }
283
289
  }
284
290
  }
285
291
  setRawValue(newValue);
286
292
 
293
+ // Restore cursor position after capitalization
294
+ if (capitalizeResult.wasCapitalized) {
295
+ setTimeout(function () {
296
+ if (ref.current && cursorPositionRef.current !== null) {
297
+ ref.current.setSelectionRange(cursorPositionRef.current, cursorPositionRef.current);
298
+ }
299
+ }, 0);
300
+ }
301
+
287
302
  // Handle cursor position for formatted input
288
303
  if (displayformat && showdisplayformaton === "keypress") {
289
304
  setTimeout(function () {
290
305
  if (ref.current) {
291
306
  var formatted = (0, _util.formatInput)(newValue, displayformat);
292
- var digitsBefore = newValue.substring(0, cursorPositionRef.current).replace(/\D/g, "").length;
307
+ // Count meaningful characters (not separators) before cursor
308
+ var charsBefore = (0, _util.removeDisplayFormat)(newValue.substring(0, cursorPositionRef.current), displayformat).length;
309
+
310
+ // Find position in formatted string where we have the same number of meaningful chars
293
311
  var newPos = formatted.split("").reduce(function (pos, _char, index) {
294
312
  if (pos !== -1) return pos;
295
- var digitsSoFar = formatted.substring(0, index).replace(/\D/g, "").length;
296
- return digitsSoFar >= digitsBefore ? index : -1;
313
+ var charsSoFar = (0, _util.removeDisplayFormat)(formatted.substring(0, index + 1), displayformat).length;
314
+ return charsSoFar >= charsBefore ? index + 1 : -1;
297
315
  }, -1);
298
316
  if (newPos !== -1) {
299
317
  ref.current.setSelectionRange(newPos, newPos);
@@ -382,6 +400,7 @@ var WmText = /*#__PURE__*/(0, _react.memo)(function (props) {
382
400
  onMouseLeave: props.onMouseLeave
383
401
  } : {});
384
402
  return __jsx(_TextField["default"], (0, _extends2["default"])({}, events, {
403
+ hidden: props.hidden,
385
404
  title: hint || "Text Input",
386
405
  name: name,
387
406
  id: id || name,
@@ -391,7 +410,7 @@ var WmText = /*#__PURE__*/(0, _react.memo)(function (props) {
391
410
  disabled: disabled,
392
411
  required: required,
393
412
  placeholder: placeholder !== null && placeholder !== void 0 ? placeholder : "Enter text",
394
- value: displayValue,
413
+ value: (0, _util2.sanitizeInputValue)(displayValue),
395
414
  type: type,
396
415
  inputRef: ref,
397
416
  error: displayError,
@@ -401,11 +420,12 @@ var WmText = /*#__PURE__*/(0, _react.memo)(function (props) {
401
420
  htmlInput: {
402
421
  tabIndex: tabindex,
403
422
  readOnly: readonly,
423
+ autoCapitalize: autocapitalize,
404
424
  className: (0, _clsx["default"])(DEFAULT_CLASS, className, isTouched ? "ng-touched" : "ng-untouched", displayError && "ng-invalid"),
405
425
  style: styles,
406
426
  "aria-label": arialabel,
407
427
  maxLength: maxchars,
408
- pattern: new RegExp(regexp || ".*", "g"),
428
+ pattern: regexp,
409
429
  min: props.minvalue,
410
430
  max: props.maxvalue,
411
431
  step: props.step
@@ -425,7 +445,7 @@ var WmText = /*#__PURE__*/(0, _react.memo)(function (props) {
425
445
  }
426
446
  }));
427
447
  }, function (prev, current) {
428
- var keys = ["datavalue", "disabled", "required", "readonly", "placeholder", "maxchars", "tabindex", "shortcutkey", "autofocus", "arialabel", "error", "className"];
448
+ var keys = ["datavalue", "disabled", "required", "readonly", "placeholder", "maxchars", "tabindex", "shortcutkey", "autofocus", "arialabel", "error", "className", "hidden"];
429
449
  return keys.every(function (key) {
430
450
  return prev[key] === current[key];
431
451
  });
@@ -3,165 +3,260 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
+ exports.applyAutoCapitalize = applyAutoCapitalize;
6
7
  exports.autoCapitalize = autoCapitalize;
7
- exports.removeDisplayFormat = exports.formatInput = void 0;
8
- var formatInput = exports.formatInput = function formatInput(value, format) {
9
- if (!format || !value) return value;
10
- value = value.toString();
11
- var digitsOnly = value.replace(/\D/g, "");
12
- var formatDigits = format.replace(/[^9]/g, "");
13
- var maxDigits = formatDigits.length;
14
- if (format === "999-99-9999") {
15
- if (digitsOnly.length === 0) return "";
16
- var result = digitsOnly.substring(0, Math.min(3, digitsOnly.length));
17
- if (digitsOnly.length > 3) {
18
- result += "-" + digitsOnly.substring(3, Math.min(5, digitsOnly.length));
19
- }
20
- if (digitsOnly.length > 5) {
21
- result += "-" + digitsOnly.substring(5, Math.min(9, digitsOnly.length));
22
- }
23
- return result;
24
- }
25
- if (format === "(999) 999-9999") {
26
- if (digitsOnly.length === 0) return "";
27
- var _result = "(" + digitsOnly.substring(0, Math.min(3, digitsOnly.length));
28
- if (digitsOnly.length > 3) {
29
- _result += ") " + digitsOnly.substring(3, Math.min(6, digitsOnly.length));
30
- }
31
- if (digitsOnly.length > 6) {
32
- _result += "-" + digitsOnly.substring(6, Math.min(10, digitsOnly.length));
33
- }
34
- return _result;
35
- }
36
- if (format === "(999) 999-9999 ext. 999") {
37
- if (digitsOnly.length === 0) return "";
38
- var _result2 = "(" + digitsOnly.substring(0, Math.min(3, digitsOnly.length));
39
- if (digitsOnly.length > 3) {
40
- _result2 += ") " + digitsOnly.substring(3, Math.min(6, digitsOnly.length));
41
- }
42
- if (digitsOnly.length > 6) {
43
- _result2 += "-" + digitsOnly.substring(6, Math.min(10, digitsOnly.length));
44
- }
45
- if (digitsOnly.length > 10) {
46
- _result2 += " ext. " + digitsOnly.substring(10);
8
+ exports.removeDisplayFormat = exports.getFormatMaxLength = exports.formatInput = void 0;
9
+ function _createForOfIteratorHelper(r, e) { var t = "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (!t) { if (Array.isArray(r) || (t = _unsupportedIterableToArray(r)) || e && r && "number" == typeof r.length) { t && (r = t); var _n = 0, F = function F() {}; return { s: F, n: function n() { return _n >= r.length ? { done: !0 } : { done: !1, value: r[_n++] }; }, e: function e(r) { throw r; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var o, a = !0, u = !1; return { s: function s() { t = t.call(r); }, n: function n() { var r = t.next(); return a = r.done, r; }, e: function e(r) { u = !0, o = r; }, f: function f() { try { a || null == t["return"] || t["return"](); } finally { if (u) throw o; } } }; }
10
+ function _unsupportedIterableToArray(r, a) { if (r) { if ("string" == typeof r) return _arrayLikeToArray(r, a); var t = {}.toString.call(r).slice(8, -1); return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0; } }
11
+ function _arrayLikeToArray(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; }
12
+ /**
13
+ * Format placeholders:
14
+ * - 9: Any digit (0-9)
15
+ * - A: Any letter (A-Z, a-z) - will be uppercased
16
+ * - a: Any letter (A-Z, a-z) - will be lowercased
17
+ * - X: Any alphanumeric character (preserves case)
18
+ * - ?: Makes the preceding placeholder optional
19
+ * - All other characters (including *, -, (, ), etc.) are treated as literal separators/static text
20
+ *
21
+ * Examples:
22
+ * 999-99-9999 → SSN format
23
+ * (999) 999-9999 → US phone
24
+ * AA-9999 → License plate (letters uppercased)
25
+ * XXX-XXX → Any 6 alphanumeric chars with dash
26
+ * (***: AAA-999) Literal asterisks with letters and digits
27
+ */
28
+
29
+ /**
30
+ * Parse format string into tokens for processing
31
+ */
32
+ var parseFormatTokens = function parseFormatTokens(format) {
33
+ var tokens = [];
34
+ var i = 0;
35
+ while (i < format.length) {
36
+ var _char = format[i];
37
+ var nextChar = format[i + 1];
38
+ var isOptional = nextChar === "?";
39
+ if (_char === "9") {
40
+ tokens.push({
41
+ type: "digit",
42
+ "char": _char,
43
+ optional: isOptional
44
+ });
45
+ i += isOptional ? 2 : 1;
46
+ } else if (_char === "A") {
47
+ tokens.push({
48
+ type: "letter-upper",
49
+ "char": _char,
50
+ optional: isOptional
51
+ });
52
+ i += isOptional ? 2 : 1;
53
+ } else if (_char === "a") {
54
+ tokens.push({
55
+ type: "letter-lower",
56
+ "char": _char,
57
+ optional: isOptional
58
+ });
59
+ i += isOptional ? 2 : 1;
60
+ } else if (_char === "X") {
61
+ // X = alphanumeric placeholder (use X instead of * to avoid conflicts with literal asterisks)
62
+ tokens.push({
63
+ type: "alphanumeric",
64
+ "char": _char,
65
+ optional: isOptional
66
+ });
67
+ i += isOptional ? 2 : 1;
68
+ } else if (_char === "?") {
69
+ // Standalone ? without preceding placeholder - treat as literal
70
+ tokens.push({
71
+ type: "literal",
72
+ "char": _char,
73
+ optional: false
74
+ });
75
+ i++;
76
+ } else {
77
+ // All other characters are literals (including *, -, (, ), spaces, etc.)
78
+ tokens.push({
79
+ type: "literal",
80
+ "char": _char,
81
+ optional: false
82
+ });
83
+ i++;
47
84
  }
48
- return _result2;
49
85
  }
50
- if (format === "(9?9?9?) 9?9?9?-9?9?9?9?9?9?") {
51
- var _result3 = "";
52
- var areaCode = "";
53
- var prefix = "";
54
- var number = "";
55
- if (digitsOnly.length > 0) {
56
- areaCode = "(" + digitsOnly.substring(0, Math.min(3, digitsOnly.length));
57
- if (digitsOnly.length < 3) {
58
- return areaCode;
59
- }
60
- areaCode += ") ";
61
- }
62
- if (digitsOnly.length > 3) {
63
- prefix = digitsOnly.substring(3, Math.min(6, digitsOnly.length));
64
- if (digitsOnly.length < 6) {
65
- return areaCode + prefix;
86
+ return tokens;
87
+ };
88
+
89
+ /**
90
+ * Extract input characters that can be used for formatting
91
+ * Returns an array of characters with their types
92
+ */
93
+ var extractInputChars = function extractInputChars(value) {
94
+ var chars = [];
95
+ var _iterator = _createForOfIteratorHelper(value),
96
+ _step;
97
+ try {
98
+ for (_iterator.s(); !(_step = _iterator.n()).done;) {
99
+ var _char2 = _step.value;
100
+ var isDigit = /\d/.test(_char2);
101
+ var isLetter = /[A-Za-z]/.test(_char2);
102
+ if (isDigit || isLetter) {
103
+ chars.push({
104
+ "char": _char2,
105
+ isDigit: isDigit,
106
+ isLetter: isLetter
107
+ });
66
108
  }
67
- prefix += "-";
68
- }
69
- if (digitsOnly.length > 6) {
70
- number = digitsOnly.substring(6);
71
- }
72
- _result3 = areaCode + prefix + number;
73
- return _result3;
74
- }
75
- if (format === "9999 9999 9999 9999") {
76
- // Credit card format
77
- var _result4 = "";
78
- for (var i = 0; i < digitsOnly.length && i < 16; i += 4) {
79
- if (i > 0) _result4 += " ";
80
- _result4 += digitsOnly.substring(i, Math.min(i + 4, digitsOnly.length));
81
109
  }
82
- return _result4;
110
+ } catch (err) {
111
+ _iterator.e(err);
112
+ } finally {
113
+ _iterator.f();
83
114
  }
84
- if (format === "AA-9999") {
85
- var _value$match;
86
- // Alpha-numeric format
87
- var _result5 = "";
88
- var alphaOnly = ((_value$match = value.match(/[A-Za-z]*/g)) === null || _value$match === void 0 ? void 0 : _value$match.join("")) || "";
89
- if (alphaOnly.length > 0) {
90
- _result5 = alphaOnly.substring(0, Math.min(2, alphaOnly.length)).toUpperCase();
91
- }
92
- if (digitsOnly.length > 0 && _result5.length > 0) {
93
- _result5 += "-";
94
- }
95
- if (digitsOnly.length > 0) {
96
- _result5 += digitsOnly.substring(0, Math.min(4, digitsOnly.length));
97
- }
98
- return _result5;
99
- }
100
- if (format === "(***: AAA-999)") {
101
- var _value$match2;
102
- // Special format with asterisks
103
- var _result6 = "(";
104
- _result6 += "***";
105
- _result6 += ": ";
106
- var _alphaOnly = ((_value$match2 = value.match(/[A-Za-z]*/g)) === null || _value$match2 === void 0 ? void 0 : _value$match2.join("")) || "";
107
- if (_alphaOnly.length > 0) {
108
- _result6 += _alphaOnly.substring(0, Math.min(3, _alphaOnly.length)).toUpperCase();
115
+ return chars;
116
+ };
117
+
118
+ /**
119
+ * Count the maximum number of input characters the format can accept
120
+ */
121
+ var getMaxInputLength = function getMaxInputLength(tokens) {
122
+ return tokens.filter(function (t) {
123
+ return t.type === "digit" || t.type === "letter-upper" || t.type === "letter-lower" || t.type === "alphanumeric";
124
+ }).length;
125
+ };
126
+
127
+ /**
128
+ * Universal format input function that handles any display format pattern
129
+ */
130
+ var formatInput = exports.formatInput = function formatInput(value, format) {
131
+ if (!format || value === null || value === undefined) return value !== null && value !== void 0 ? value : "";
132
+ if (value === "") return "";
133
+ value = value.toString();
134
+ var tokens = parseFormatTokens(format);
135
+ var inputChars = extractInputChars(value);
136
+ if (inputChars.length === 0) return "";
137
+ var result = "";
138
+ var inputIndex = 0;
139
+ var pendingLiterals = "";
140
+ for (var tokenIndex = 0; tokenIndex < tokens.length; tokenIndex++) {
141
+ var token = tokens[tokenIndex];
142
+
143
+ // No more input characters - stop processing
144
+ if (inputIndex >= inputChars.length) {
145
+ break;
109
146
  }
110
- if (digitsOnly.length > 0) {
111
- _result6 += "-";
112
- _result6 += digitsOnly.substring(0, Math.min(3, digitsOnly.length));
147
+ if (token.type === "literal") {
148
+ // Collect literals but don't add them yet
149
+ pendingLiterals += token["char"];
150
+ continue;
113
151
  }
114
- _result6 += ")";
115
- return _result6;
116
- }
117
152
 
118
- // Generic formatter for other patterns
119
- if (format.includes("9")) {
120
- var _result7 = "";
121
- var digitIndex = 0;
122
- var _formatDigits = format.replace(/[^9]/g, "");
123
- var _maxDigits = _formatDigits.length;
153
+ // Find a matching input character for this token
154
+ var matched = false;
155
+ var inputChar = inputChars[inputIndex];
156
+ if (token.type === "digit" && inputChar !== null && inputChar !== void 0 && inputChar.isDigit) {
157
+ // Flush pending literals before adding the matched character
158
+ result += pendingLiterals + inputChar["char"];
159
+ pendingLiterals = "";
160
+ inputIndex++;
161
+ matched = true;
162
+ } else if (token.type === "letter-upper" && inputChar !== null && inputChar !== void 0 && inputChar.isLetter) {
163
+ result += pendingLiterals + inputChar["char"].toUpperCase();
164
+ pendingLiterals = "";
165
+ inputIndex++;
166
+ matched = true;
167
+ } else if (token.type === "letter-lower" && inputChar !== null && inputChar !== void 0 && inputChar.isLetter) {
168
+ result += pendingLiterals + inputChar["char"].toLowerCase();
169
+ pendingLiterals = "";
170
+ inputIndex++;
171
+ matched = true;
172
+ } else if (token.type === "alphanumeric" && (inputChar !== null && inputChar !== void 0 && inputChar.isDigit || inputChar !== null && inputChar !== void 0 && inputChar.isLetter)) {
173
+ result += pendingLiterals + inputChar["char"];
174
+ pendingLiterals = "";
175
+ inputIndex++;
176
+ matched = true;
177
+ }
124
178
 
125
- // Limit digitsOnly to maxDigits from format
126
- var limitedDigits = digitsOnly.substring(0, _maxDigits);
127
- for (var _i2 = 0; _i2 < format.length && digitIndex < limitedDigits.length; _i2++) {
128
- if (format[_i2] === "9") {
129
- _result7 += limitedDigits[digitIndex++] || "";
130
- } else {
131
- // Only add separator if there are more digits to come
132
- if (digitIndex < limitedDigits.length) {
133
- _result7 += format[_i2];
179
+ // If no match and token is not optional, try to skip input chars to find match
180
+ if (!matched && !token.optional) {
181
+ // Look ahead in input to find a matching character
182
+ var foundMatch = false;
183
+ for (var lookAhead = inputIndex; lookAhead < inputChars.length; lookAhead++) {
184
+ var lookAheadChar = inputChars[lookAhead];
185
+ if (token.type === "digit" && lookAheadChar.isDigit) {
186
+ result += pendingLiterals + lookAheadChar["char"];
187
+ pendingLiterals = "";
188
+ inputIndex = lookAhead + 1;
189
+ foundMatch = true;
190
+ break;
191
+ } else if (token.type === "letter-upper" && lookAheadChar.isLetter) {
192
+ result += pendingLiterals + lookAheadChar["char"].toUpperCase();
193
+ pendingLiterals = "";
194
+ inputIndex = lookAhead + 1;
195
+ foundMatch = true;
196
+ break;
197
+ } else if (token.type === "letter-lower" && lookAheadChar.isLetter) {
198
+ result += pendingLiterals + lookAheadChar["char"].toLowerCase();
199
+ pendingLiterals = "";
200
+ inputIndex = lookAhead + 1;
201
+ foundMatch = true;
202
+ break;
203
+ } else if (token.type === "alphanumeric") {
204
+ result += pendingLiterals + lookAheadChar["char"];
205
+ pendingLiterals = "";
206
+ inputIndex = lookAhead + 1;
207
+ foundMatch = true;
208
+ break;
134
209
  }
135
210
  }
211
+
212
+ // If still no match found, stop processing
213
+ if (!foundMatch) {
214
+ break;
215
+ }
136
216
  }
137
- return _result7;
138
217
  }
139
-
140
- // Fallback: return original value
141
- return value;
218
+ return result;
142
219
  };
143
220
 
144
221
  /**
145
222
  * Removes display format characters from the value
146
- * Keeps only alphanumeric characters based on the format type
223
+ * Intelligently extracts only the meaningful input characters based on format type
147
224
  */
148
225
  var removeDisplayFormat = exports.removeDisplayFormat = function removeDisplayFormat(value, format) {
149
226
  if (!format || !value) return value;
150
227
  value = value.toString();
228
+ var tokens = parseFormatTokens(format);
151
229
 
152
- // For alphanumeric formats (like AA-9999), keep both letters and numbers
153
- if (format.includes("A")) {
230
+ // Determine what character types the format accepts
231
+ var acceptsDigits = tokens.some(function (t) {
232
+ return t.type === "digit" || t.type === "alphanumeric";
233
+ });
234
+ var acceptsLetters = tokens.some(function (t) {
235
+ return t.type === "letter-upper" || t.type === "letter-lower" || t.type === "alphanumeric";
236
+ });
237
+ if (acceptsDigits && acceptsLetters) {
238
+ // Mixed format: keep both letters and numbers
154
239
  return value.replace(/[^A-Za-z0-9]/g, "");
155
- }
156
-
157
- // For numeric-only formats, keep only digits
158
- if (format.includes("9")) {
240
+ } else if (acceptsLetters) {
241
+ // Letters only format
242
+ return value.replace(/[^A-Za-z]/g, "");
243
+ } else if (acceptsDigits) {
244
+ // Digits only format
159
245
  return value.replace(/\D/g, "");
160
246
  }
161
247
 
162
- // Default: return the value as-is
248
+ // Default: return the value as-is (no placeholders in format)
163
249
  return value;
164
250
  };
251
+
252
+ /**
253
+ * Get the maximum number of input characters allowed by the format
254
+ */
255
+ var getFormatMaxLength = exports.getFormatMaxLength = function getFormatMaxLength(format) {
256
+ if (!format) return Infinity;
257
+ var tokens = parseFormatTokens(format);
258
+ return getMaxInputLength(tokens);
259
+ };
165
260
  function autoCapitalize(value, type) {
166
261
  if (!value) return value;
167
262
  switch (type) {
@@ -178,4 +273,62 @@ function autoCapitalize(value, type) {
178
273
  default:
179
274
  return value;
180
275
  }
276
+ }
277
+
278
+ /**
279
+ * Applies autocapitalize logic to a character being inserted in real-time
280
+ * @param newValue - The complete new value after character insertion
281
+ * @param previousValue - The value before character insertion
282
+ * @param cursorPosition - The cursor position after insertion
283
+ * @param mode - The autocapitalize mode: "words", "sentence", "characters", or "none"
284
+ * @returns Object with capitalized value and whether capitalization was applied
285
+ */
286
+ function applyAutoCapitalize(newValue, previousValue, cursorPosition, mode) {
287
+ // Only process if a character was inserted (not deleted)
288
+ if (mode === "none" || newValue.length <= previousValue.length) {
289
+ return {
290
+ value: newValue,
291
+ wasCapitalized: false
292
+ };
293
+ }
294
+ var insertedChar = newValue[cursorPosition - 1];
295
+ var shouldCapitalize = false;
296
+
297
+ // Only capitalize alphabetic characters
298
+ if (!/[a-zA-Z]/.test(insertedChar)) {
299
+ return {
300
+ value: newValue,
301
+ wasCapitalized: false
302
+ };
303
+ }
304
+ if (mode === "characters") {
305
+ // Capitalize every character
306
+ shouldCapitalize = true;
307
+ } else if (mode === "words") {
308
+ // Capitalize first letter of each word (after space or at start)
309
+ shouldCapitalize = cursorPosition === 1 || newValue[cursorPosition - 2] === " ";
310
+ } else if (mode === "sentences") {
311
+ // Capitalize first letter after sentence-ending punctuation (. ! ?)
312
+ if (cursorPosition === 1) {
313
+ shouldCapitalize = true;
314
+ } else {
315
+ // Check if we're at the start of a sentence
316
+ var textBefore = newValue.substring(0, cursorPosition - 1);
317
+ // Match sentence-ending punctuation followed by optional spaces
318
+ var sentenceEndPattern = /[.!?]\s*$/;
319
+ shouldCapitalize = sentenceEndPattern.test(textBefore);
320
+ }
321
+ }
322
+ if (shouldCapitalize && insertedChar === insertedChar.toLowerCase()) {
323
+ // Replace the lowercase character with uppercase
324
+ var capitalizedValue = newValue.substring(0, cursorPosition - 1) + insertedChar.toUpperCase() + newValue.substring(cursorPosition);
325
+ return {
326
+ value: capitalizedValue,
327
+ wasCapitalized: true
328
+ };
329
+ }
330
+ return {
331
+ value: newValue,
332
+ wasCapitalized: false
333
+ };
181
334
  }