@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.
- package/actions/base-action.js +5 -7
- package/actions/login-action.js +7 -8
- package/actions/logout-action.js +5 -7
- package/actions/navigation-action.js +73 -18
- package/actions/notification-action.js +22 -8
- package/actions/timer-action.js +13 -15
- package/actions/toast.js +4 -2
- package/actions/toast.service.js +1 -2
- package/components/advanced/carousel/index.js +1 -1
- package/components/advanced/carousel/template.js +1 -1
- package/components/basic/anchor/index.js +31 -11
- package/components/basic/html/index.js +115 -24
- package/components/basic/icon/index.js +2 -1
- package/components/basic/iframe/index.js +2 -1
- package/components/basic/label/index.js +12 -9
- package/components/basic/message/index.js +12 -3
- package/components/basic/picture/index.js +11 -4
- package/components/basic/progress-bar/index.js +4 -1
- package/components/basic/progress-circle/index.js +34 -28
- package/components/basic/progress-circle/props.js +10 -2
- package/components/basic/richtexteditor/index.js +95 -94
- package/components/basic/search/index.js +401 -156
- package/components/basic/search/providers.js +126 -61
- package/components/basic/spinner/index.js +2 -1
- package/components/basic/tree/index.js +34 -34
- package/components/basic/tree/utils.js +10 -4
- package/components/chart/components/barColumnChart/index.js +36 -33
- package/components/chart/components/bubbleChart/index.js +35 -25
- package/components/chart/components/chartLegend/utils.js +2 -1
- package/components/chart/components/cumulativeLineChart/index.js +30 -26
- package/components/chart/components/lineAreaChart/index.js +50 -32
- package/components/chart/components/pieDonutChart/index.js +13 -4
- package/components/chart/hooks/useXAxisConfig.js +15 -8
- package/components/chart/index.js +223 -53
- package/components/chart/utils.js +12 -1
- package/components/constants.js +5 -2
- package/components/container/accordion/accordion-pane/index.js +17 -12
- package/components/container/accordion/index.js +9 -4
- package/components/container/alignment-utils.js +56 -1
- package/components/container/index.js +49 -20
- package/components/container/panel/components/panel-header/index.js +3 -4
- package/components/container/panel/index.js +15 -10
- package/components/container/repeat-template/index.js +33 -0
- package/components/container/tabs/index.js +83 -14
- package/components/container/tabs/tab-pane/index.js +33 -10
- package/components/container/tabs/utils.js +51 -0
- package/components/container/wizard/components/StepComponents.js +2 -1
- package/components/container/wizard/components/WizardStep.js +2 -1
- package/components/container/wizard/index.js +64 -35
- package/components/container/wizard/utils.js +46 -1
- package/components/container/wizard/wizard-step/index.js +11 -1
- package/components/data/card/card-content/index.js +1 -1
- package/components/data/form/base-form/index.js +985 -183
- package/components/data/form/base-form/props.js +3 -1
- package/components/data/form/base-form/utils.js +159 -1
- package/components/data/form/dynamic-fields/constant.js +53 -0
- package/components/data/form/dynamic-fields/index.js +10 -45
- package/components/data/form/dynamic-fields/utils.js +37 -2
- package/components/data/form/form-action/index.js +5 -4
- package/components/data/form/form-context.js +5 -1
- package/components/data/form/form-controller/utils.js +84 -0
- package/components/data/form/form-controller/validation-contrustor.js +402 -189
- package/components/data/form/form-controller/withFormController.js +191 -52
- package/components/data/form/form-field/base-field.js +67 -45
- package/components/data/form/form-field/index.js +28 -5
- package/components/data/form/form-header/index.js +3 -4
- package/components/data/form/index.js +20 -1
- package/components/data/list/components/ListDND.js +2 -1
- package/components/data/list/components/ListItem.js +6 -2
- package/components/data/list/components/ListItemWithTemplate.js +46 -2
- package/components/data/list/components/ListItems.js +17 -26
- package/components/data/list/components/ListPagination.js +3 -3
- package/components/data/list/components/StandardListItems.js +3 -4
- package/components/data/list/hooks/useListEffects.js +55 -14
- package/components/data/list/hooks/useListEventHandlers.js +3 -1
- package/components/data/list/hooks/useListState.js +3 -1
- package/components/data/list/hooks/usePaginatedGroupedData.js +18 -5
- package/components/data/list/index.js +74 -55
- package/components/data/list/utils/list-helpers.js +73 -35
- package/components/data/list/utils/list-widget-methods.js +138 -95
- package/components/data/live-filter/index.js +26 -15
- package/components/data/live-form/index.js +51 -18
- package/components/data/live-form/props.js +1 -1
- package/components/data/pagination/components/BasicPagination.js +71 -16
- package/components/data/pagination/components/PageSizeSelector.js +8 -3
- package/components/data/pagination/components/TotalRecords.js +1 -5
- package/components/data/pagination/hooks/usePagination.js +349 -66
- package/components/data/pagination/index.js +137 -19
- package/components/data/table/components/AddNewRow.js +5 -1
- package/components/data/table/components/EditableCell.js +2 -2
- package/components/data/table/components/RowCells.js +64 -0
- package/components/data/table/components/RowExpansionButton.js +2 -2
- package/components/data/table/components/SummaryCell.js +111 -0
- package/components/data/table/components/SummaryRow.js +54 -0
- package/components/data/table/components/SummaryRowFooter.js +46 -0
- package/components/data/table/components/TableBody.js +61 -59
- package/components/data/table/components/TableDataRow.js +109 -0
- package/components/data/table/components/TableFilters.js +225 -121
- package/components/data/table/components/TableHeader.js +291 -23
- package/components/data/table/components/TablePanelHeading.js +139 -8
- package/components/data/table/components/index.js +22 -1
- package/components/data/table/hooks/use-edited-rows.js +141 -0
- package/components/data/table/hooks/useCellState.js +5 -12
- package/components/data/table/hooks/useFormWidget.js +58 -52
- package/components/data/table/hooks/usePaginationState.js +45 -24
- package/components/data/table/hooks/usePanelStructure.js +4 -4
- package/components/data/table/hooks/useRowHandlers.js +39 -5
- package/components/data/table/hooks/useRowSelection.js +244 -50
- package/components/data/table/hooks/useServerSideSorting.js +81 -37
- package/components/data/table/hooks/useTableColumns.js +211 -118
- package/components/data/table/hooks/useTableData.js +54 -9
- package/components/data/table/hooks/useTableEdit.js +272 -97
- package/components/data/table/hooks/useTableEffects.js +31 -13
- package/components/data/table/hooks/useTableFilter.js +1 -1
- package/components/data/table/hooks/useTableInitialization.js +23 -22
- package/components/data/table/hooks/useTableState.js +11 -5
- package/components/data/table/hooks/useTableStateManager.js +140 -65
- package/components/data/table/index.js +637 -274
- package/components/data/table/live-table/index.js +54 -22
- package/components/data/table/table-action/index.js +1 -1
- package/components/data/table/table-group/index.js +26 -0
- package/components/data/table/table-row-action/index.js +32 -18
- package/components/data/table/utils/buildSelectionColumns.js +12 -21
- package/components/data/table/utils/columnBuilder.js +29 -14
- package/components/data/table/utils/columnProxy.js +68 -1
- package/components/data/table/utils/constants.js +6 -2
- package/components/data/table/utils/crud-handlers.js +68 -63
- package/components/data/table/utils/groupHeaderUtils.js +102 -0
- package/components/data/table/utils/index.js +210 -21
- package/components/data/table/utils/renderDisplayCell.js +6 -6
- package/components/data/table/utils/selectionUtils.js +25 -26
- package/components/data/table/utils/validation.js +1 -0
- package/components/data/utils/filter-field-util.js +3 -3
- package/components/dialogs/alert-dialog/index.js +1 -1
- package/components/dialogs/confirm-dialog/index.js +1 -1
- package/components/dialogs/dialog/index.js +4 -1
- package/components/dialogs/dialog-content/index.js +3 -1
- package/components/dialogs/dialog-header/index.js +2 -2
- package/components/dialogs/iframe-dialog/index.js +11 -5
- package/components/dialogs/index.js +1 -1
- package/components/dialogs/login-dialog/index.js +1 -1
- package/components/dialogs/page-dialog/index.js +1 -1
- package/components/form/button/index.js +33 -7
- package/components/input/calendar/index.js +18 -6
- package/components/input/chips/index.js +99 -28
- package/components/input/chips/utils.js +34 -4
- package/components/input/color-picker/index.js +74 -25
- package/components/input/composite/index.js +3 -3
- package/components/input/currency/index.js +35 -49
- package/components/input/default/checkbox/index.js +23 -28
- package/components/input/default/checkboxset/index.js +38 -18
- package/components/input/default/checkboxset/utils.js +30 -0
- package/components/input/default/radioset/index.js +36 -39
- package/components/input/default/switch/index.js +30 -13
- package/components/input/epoch/date/index.js +130 -69
- package/components/input/epoch/date/utils.js +94 -1
- package/components/input/epoch/datetime/index.js +72 -22
- package/components/input/epoch/datetime/utils.js +49 -10
- package/components/input/epoch/time/index.js +68 -19
- package/components/input/epoch/time/utils.js +62 -14
- package/components/input/fileupload/Utils.js +12 -7
- package/components/input/fileupload/components/MultiUpload.js +2 -6
- package/components/input/fileupload/components/SingleUpload.js +3 -7
- package/components/input/fileupload/index.js +6 -10
- package/components/input/fileupload/useFileUpload.js +16 -5
- package/components/input/number/index.js +158 -43
- package/components/input/rating/index.js +90 -7
- package/components/input/select/index.js +209 -72
- package/components/input/slider/index.js +84 -26
- package/components/input/text/index.js +38 -18
- package/components/input/text/util.js +283 -130
- package/components/input/textarea/index.js +13 -10
- package/components/input/upload/index.js +124 -0
- package/components/input/upload/props.js +5 -0
- package/components/input/util/index.js +11 -0
- package/components/navbar/index.js +51 -3
- package/components/navbar/nav/index.js +46 -16
- package/components/navbar/nav-item/index.js +11 -5
- package/components/navigation/menu/components/ListItems.js +3 -0
- package/components/navigation/menu/constants.js +2 -1
- package/components/navigation/menu/hooks/useHoverState.hook.js +48 -0
- package/components/navigation/menu/hooks/useKeyboardMovements.hook.js +37 -0
- package/components/navigation/menu/hooks/useTransformedDataset.hook.js +15 -0
- package/components/navigation/menu/index.js +326 -188
- package/components/navigation/menu/utils/action-task.js +14 -0
- package/components/navigation/menu/utils/role-filter.js +76 -0
- package/components/navigation/popover/index.js +105 -32
- package/components/page/partial-container/index.js +34 -5
- package/components/prefab/index.js +2 -4
- package/context/PrefabContext.js +10 -6
- package/context/WidgetProvider.js +30 -31
- package/core/app.service.js +1 -1
- package/core/constants/events.js +57 -1
- package/core/dialog.service.js +1 -2
- package/core/event-notifier.js +1 -2
- package/core/formatter/array-formatters.js +33 -0
- package/core/formatter/date-formatters.js +2 -4
- package/core/formatter/index.js +2 -1
- package/core/formatter/number-formatters.js +5 -10
- package/core/formatter/security-formatters.js +2 -4
- package/core/formatter/string-formatters.js +3 -6
- package/core/proxy-service.js +85 -13
- package/core/script-registry.js +108 -48
- package/core/util/common.js +4 -4
- package/core/util/compare.js +30 -0
- package/core/util/dom.js +8 -8
- package/core/util/index.js +16 -6
- package/core/util/safe-is-equal.js +156 -0
- package/core/util/security.js +1 -2
- package/core/util/utils.js +16 -7
- package/higherOrder/BaseApp.js +108 -65
- package/higherOrder/BaseDateTime.js +31 -13
- package/higherOrder/BasePage.js +268 -144
- package/higherOrder/BasePartial.js +1 -1
- package/higherOrder/BasePrefab.js +33 -15
- package/higherOrder/DataNav.js +99 -16
- package/higherOrder/helper.js +41 -3
- package/higherOrder/withBaseWrapper.js +41 -28
- package/hooks/useAuth.js +11 -5
- package/hooks/useHttp.js +280 -94
- package/mui-config/theme-provider.js +1 -1
- package/mui-config/theme.js +1 -1
- package/package-lock.json +840 -740
- package/package.json +8 -8
- package/store/bindActions/i18nActions.js +18 -0
- package/store/index.js +3 -1
- package/store/slices/appConfigSlice.js +2 -2
- package/store/slices/authSlice.js +31 -28
- package/store/slices/i18nSlice.js +2 -2
- package/store/slices/navigationSlice.js +35 -0
- package/store/viewport.service.js +255 -0
- package/utils/attr.js +35 -0
- package/utils/dataset-util.js +1 -2
- package/utils/form-state.util.js +43 -12
- package/utils/form-utils.js +47 -2
- package/utils/format-util.js +28 -13
- package/utils/page-params-util.js +33 -1
- package/utils/state-persistance.js +72 -13
- package/utils/transformedDataset-utils.js +35 -24
- package/variables/base-variable.js +12 -14
- package/variables/crud-variable.js +225 -0
- package/variables/live-variable.js +56 -20
- package/variables/metadata.service.js +123 -0
- package/variables/model-variable.js +21 -15
- 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
|
-
//
|
|
251
|
-
var
|
|
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 &&
|
|
261
|
+
if (maxchars && cleanValue.length > maxchars) {
|
|
255
262
|
// Prevent input that exceeds maxchars
|
|
256
263
|
return;
|
|
257
264
|
}
|
|
258
265
|
|
|
259
|
-
// Enforce displayformat
|
|
266
|
+
// Enforce displayformat character limit using the generic format parser
|
|
260
267
|
if (displayformat) {
|
|
261
|
-
var
|
|
262
|
-
|
|
263
|
-
|
|
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"])(
|
|
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 &&
|
|
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 (
|
|
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
|
-
|
|
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
|
|
296
|
-
return
|
|
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:
|
|
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
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
if (
|
|
46
|
-
|
|
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
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
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
|
-
|
|
110
|
+
} catch (err) {
|
|
111
|
+
_iterator.e(err);
|
|
112
|
+
} finally {
|
|
113
|
+
_iterator.f();
|
|
83
114
|
}
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
if (format ===
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
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 (
|
|
111
|
-
|
|
112
|
-
|
|
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
|
-
|
|
119
|
-
|
|
120
|
-
var
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
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
|
-
//
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
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
|
-
*
|
|
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
|
-
//
|
|
153
|
-
|
|
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
|
-
|
|
158
|
-
if (
|
|
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
|
}
|