beesoft-components 0.2.25 → 0.2.26-1
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/build/index.cjs.js +1443 -45
- package/build/index.js +1444 -46
- package/build/index.min.js +6 -6
- package/build/index.min.js.gz +0 -0
- package/build/types/src/components/common-functions.d.ts +4 -0
- package/build/types/src/components/common-interfaces.d.ts +6 -0
- package/build/types/src/components/form/date-time/date-time-functions.d.ts +1 -0
- package/build/types/src/components/form/date-time/date-time.component.d.ts +5 -8
- package/build/types/src/components/form/date-time/date-time.reducer.d.ts +6 -2
- package/build/types/src/components/form/form-control.interface.d.ts +12 -0
- package/build/types/src/components/form/{content-editable-input → input/content-editable-input}/content-editable-input.component.d.ts +8 -8
- package/build/types/src/components/form/input/formatted-input/formats/date/day-month-year/format.d.ts +3 -0
- package/build/types/src/components/form/input/formatted-input/formats/date/month-day-year/format.d.ts +3 -0
- package/build/types/src/components/form/input/formatted-input/formats/date/year-month-day/format.d.ts +3 -0
- package/build/types/src/components/form/input/formatted-input/formats/date-range/day-month-year/format.d.ts +3 -0
- package/build/types/src/components/form/input/formatted-input/formats/date-range/month-day-year/format.d.ts +3 -0
- package/build/types/src/components/form/input/formatted-input/formats/date-range/year-month-day/format.d.ts +3 -0
- package/build/types/src/components/form/input/formatted-input/formats/index.d.ts +9 -0
- package/build/types/src/components/form/input/formatted-input/formats/input-format.enums.d.ts +11 -0
- package/build/types/src/components/form/input/formatted-input/formats/input-format.interfaces.d.ts +23 -0
- package/build/types/src/components/form/input/formatted-input/formats/time/12-hour/format.d.ts +3 -0
- package/build/types/src/components/form/input/formatted-input/formats/time/24-hour/format.d.ts +3 -0
- package/build/types/src/components/form/input/formatted-input/formatted-input.component.d.ts +13 -0
- package/build/types/src/components/form/input/formatted-input/parser/format-navigator.d.ts +31 -0
- package/build/types/src/components/form/input/formatted-input/parser/format-parser.d.ts +19 -0
- package/build/types/src/components/form/input/formatted-input/parser/format-renderer.d.ts +9 -0
- package/build/types/src/components/form/input/formatted-input/parser/input-rule-processor.d.ts +19 -0
- package/build/types/src/components/form/input/formatted-input/parser/input-slot-collection.d.ts +15 -0
- package/build/types/src/components/form/input/formatted-input/parser/input-slot-creator.d.ts +4 -0
- package/build/types/src/components/form/input/formatted-input/parser/key-processor.d.ts +13 -0
- package/build/types/src/components/form/input/formatted-input/parser/key-type-checker.d.ts +11 -0
- package/build/types/src/components/form/input/formatted-input/parser/parser.interfaces.d.ts +24 -0
- package/build/types/src/components/form/input/formatted-input/parser/part-entry-creator.d.ts +5 -0
- package/build/types/src/components/form/input/formatted-input/parser/part-entry-iterator.d.ts +14 -0
- package/build/types/src/index.d.ts +4 -0
- package/build/types/src/interfaces/iterator.interface.d.ts +7 -0
- package/package.json +5 -2
package/build/index.cjs.js
CHANGED
|
@@ -30366,44 +30366,73 @@ function OverlayPanel(_a) {
|
|
|
30366
30366
|
} })));
|
|
30367
30367
|
}
|
|
30368
30368
|
|
|
30369
|
-
function
|
|
30370
|
-
var value = props.value, _a = props.readOnly, readOnly = _a === void 0 ? false : _a, _b = props.debounceTime, debounceTime = _b === void 0 ?
|
|
30371
|
-
var
|
|
30372
|
-
var
|
|
30373
|
-
|
|
30374
|
-
|
|
30369
|
+
var ContentEditableInput = function (props, ref) {
|
|
30370
|
+
var value = props.value, _a = props.readOnly, readOnly = _a === void 0 ? false : _a, _b = props.debounceTime, debounceTime = _b === void 0 ? 800 : _b, _c = props.fillContainer, fillContainer = _c === void 0 ? true : _c, leftElement = props.leftElement, rightElement = props.rightElement, className = props.className, leftElementClassName = props.leftElementClassName, rightElementClassName = props.rightElementClassName, _d = props.isSingleLine, isSingleLine = _d === void 0 ? true : _d, _e = props.allowSingleLineScroll, allowSingleLineScroll = _e === void 0 ? false : _e, placeholder = props.placeholder, onFocus = props.onFocus, onBlur = props.onBlur, onInput = props.onInput, onInnerTextChange = props.onInnerTextChange, onInnerHTMLChange = props.onInnerHTMLChange, onElementCreate = props.onElementCreate, onLeftElementClick = props.onLeftElementClick, onRightElementClick = props.onRightElementClick;
|
|
30371
|
+
var textStyles = React.useRef('bsc-flex-grow focus:bsc-outline-none');
|
|
30372
|
+
var placeHolderStyles = React.useRef('bsc-text-gray-400');
|
|
30373
|
+
var inputRef = React.useRef();
|
|
30374
|
+
var focusListener = React.useCallback(function (event) {
|
|
30375
|
+
var element = event.target;
|
|
30376
|
+
var value = element.innerHTML;
|
|
30377
|
+
element.className = "".concat(textStyles.current);
|
|
30378
|
+
if (placeholder && value === placeholder) {
|
|
30379
|
+
element.innerHTML = '';
|
|
30375
30380
|
}
|
|
30376
|
-
|
|
30377
|
-
|
|
30378
|
-
|
|
30379
|
-
|
|
30381
|
+
onFocus === null || onFocus === void 0 ? void 0 : onFocus(event);
|
|
30382
|
+
}, [placeholder, onFocus]);
|
|
30383
|
+
var blurListener = React.useCallback(function (event) {
|
|
30384
|
+
var value = event.target.innerHTML;
|
|
30385
|
+
if (placeholder && value === '') {
|
|
30386
|
+
var element = event.target;
|
|
30387
|
+
element.innerHTML = placeholder;
|
|
30388
|
+
element.className = "".concat(textStyles.current, " ").concat(placeHolderStyles.current);
|
|
30380
30389
|
}
|
|
30381
|
-
|
|
30382
|
-
|
|
30383
|
-
|
|
30384
|
-
|
|
30390
|
+
onBlur === null || onBlur === void 0 ? void 0 : onBlur(event);
|
|
30391
|
+
}, [placeholder, onBlur]);
|
|
30392
|
+
var onInputElementCreated = React.useCallback(function (element) {
|
|
30393
|
+
var _a, _b;
|
|
30394
|
+
(_a = inputRef.current) === null || _a === void 0 ? void 0 : _a.removeEventListener('focus', focusListener);
|
|
30395
|
+
(_b = inputRef.current) === null || _b === void 0 ? void 0 : _b.removeEventListener('blur', blurListener);
|
|
30396
|
+
if (placeholder && element && element !== document.activeElement && element.innerHTML === '') {
|
|
30397
|
+
element.innerHTML = placeholder;
|
|
30398
|
+
element.className = "".concat(textStyles.current, " ").concat(placeHolderStyles.current);
|
|
30385
30399
|
}
|
|
30400
|
+
element.addEventListener('focus', focusListener);
|
|
30401
|
+
element.addEventListener('blur', blurListener);
|
|
30402
|
+
inputRef.current = element;
|
|
30403
|
+
}, [placeholder]);
|
|
30404
|
+
var onElementCreated = React.useCallback(function (element) {
|
|
30405
|
+
onElementCreate === null || onElementCreate === void 0 ? void 0 : onElementCreate(element);
|
|
30406
|
+
}, [onElementCreate]);
|
|
30407
|
+
var onLeftElementClicked = function (event) {
|
|
30408
|
+
onLeftElementClick === null || onLeftElementClick === void 0 ? void 0 : onLeftElementClick(event);
|
|
30386
30409
|
};
|
|
30387
|
-
var
|
|
30388
|
-
|
|
30389
|
-
|
|
30390
|
-
|
|
30410
|
+
var onRightElementClicked = function (event) {
|
|
30411
|
+
onRightElementClick === null || onRightElementClick === void 0 ? void 0 : onRightElementClick(event);
|
|
30412
|
+
};
|
|
30413
|
+
var onInputChanged = lodashExports.debounce(function (event) {
|
|
30414
|
+
onInput === null || onInput === void 0 ? void 0 : onInput(event);
|
|
30415
|
+
onInnerTextChange === null || onInnerTextChange === void 0 ? void 0 : onInnerTextChange(event.target.innerText);
|
|
30416
|
+
onInnerHTMLChange === null || onInnerHTMLChange === void 0 ? void 0 : onInnerHTMLChange(event.target.innerHTML);
|
|
30391
30417
|
}, debounceTime);
|
|
30392
|
-
var
|
|
30393
|
-
if (
|
|
30394
|
-
|
|
30395
|
-
onElementCreate(element);
|
|
30396
|
-
}
|
|
30397
|
-
if (element.offsetWidth < element.scrollWidth && value) {
|
|
30398
|
-
element.setAttribute('title', value);
|
|
30399
|
-
}
|
|
30418
|
+
var setInnerText = React.useCallback(function (innerText) {
|
|
30419
|
+
if (inputRef.current) {
|
|
30420
|
+
inputRef.current.innerText = innerText;
|
|
30400
30421
|
}
|
|
30401
|
-
};
|
|
30402
|
-
var
|
|
30422
|
+
}, []);
|
|
30423
|
+
var setInnerHTML = React.useCallback(function (innerHTML) {
|
|
30424
|
+
if (inputRef.current) {
|
|
30425
|
+
inputRef.current.innerHTML = innerHTML;
|
|
30426
|
+
}
|
|
30427
|
+
}, []);
|
|
30428
|
+
var focus = React.useCallback(function () {
|
|
30403
30429
|
var _a;
|
|
30404
30430
|
(_a = inputRef.current) === null || _a === void 0 ? void 0 : _a.focus();
|
|
30405
|
-
};
|
|
30431
|
+
}, []);
|
|
30406
30432
|
React.useImperativeHandle(ref, function () { return ({
|
|
30433
|
+
inputElement: inputRef.current,
|
|
30434
|
+
setInnerText: setInnerText,
|
|
30435
|
+
setInnerHTML: setInnerHTML,
|
|
30407
30436
|
focus: focus,
|
|
30408
30437
|
}); });
|
|
30409
30438
|
var classNames = cx({ 'bsc-w-full ': fillContainer }, 'bsc-flex bsc-flex-row bsc-shadow-sm bsc-border bsc-border-solid bsc-border-gray-300 dark:bsc-border-white dark:bsc-bg-gray-900 dark:bsc-text-white bsc-rounded-md bsc-p-2', {
|
|
@@ -30412,9 +30441,1297 @@ function ContentEditableInput(props, ref) {
|
|
|
30412
30441
|
}, className);
|
|
30413
30442
|
var leftElementClasses = cx('bsc-flex-shrink', { 'bsc-mr-2': leftElement }, leftElementClassName);
|
|
30414
30443
|
var rightElementClasses = cx('bsc-flex-shrink', { 'bsc-ml-2': rightElement }, rightElementClassName);
|
|
30415
|
-
return (jsxRuntime.jsxs("div", __assign({ className: classNames, ref: function (element) { return onElementCreated(element); } }, { children: [leftElement && (jsxRuntime.jsx("div", __assign({ className: leftElementClasses, onClick: onLeftElementClicked }, { children: leftElement }))), jsxRuntime.jsx("div", __assign({ ref:
|
|
30416
|
-
}
|
|
30417
|
-
var ContentEditableInput$1 = React.forwardRef(ContentEditableInput);
|
|
30444
|
+
return (jsxRuntime.jsxs("div", __assign({ className: classNames, ref: function (element) { return element && onElementCreated(element); } }, { children: [leftElement && (jsxRuntime.jsx("div", __assign({ className: leftElementClasses, onClick: onLeftElementClicked }, { children: leftElement }))), jsxRuntime.jsx("div", __assign({ ref: function (element) { return element && onInputElementCreated(element); }, className: textStyles.current, contentEditable: !readOnly, suppressContentEditableWarning: true, onInput: onInputChanged }, { children: value })), rightElement && (jsxRuntime.jsx("div", __assign({ className: rightElementClasses, onClick: onRightElementClicked }, { children: rightElement })))] })));
|
|
30445
|
+
};
|
|
30446
|
+
var ContentEditableInput$1 = React.memo(React.forwardRef(ContentEditableInput));
|
|
30447
|
+
|
|
30448
|
+
var FormattedInputDefaultFormats;
|
|
30449
|
+
(function (FormattedInputDefaultFormats) {
|
|
30450
|
+
FormattedInputDefaultFormats[FormattedInputDefaultFormats["DateDayMonthYear"] = 0] = "DateDayMonthYear";
|
|
30451
|
+
FormattedInputDefaultFormats[FormattedInputDefaultFormats["DateMonthDayYear"] = 1] = "DateMonthDayYear";
|
|
30452
|
+
FormattedInputDefaultFormats[FormattedInputDefaultFormats["DateYearMonthDay"] = 2] = "DateYearMonthDay";
|
|
30453
|
+
FormattedInputDefaultFormats[FormattedInputDefaultFormats["DateRangeDayMonthYear"] = 3] = "DateRangeDayMonthYear";
|
|
30454
|
+
FormattedInputDefaultFormats[FormattedInputDefaultFormats["DateRangeMonthDayYear"] = 4] = "DateRangeMonthDayYear";
|
|
30455
|
+
FormattedInputDefaultFormats[FormattedInputDefaultFormats["DateRangeYearMonthDay"] = 5] = "DateRangeYearMonthDay";
|
|
30456
|
+
FormattedInputDefaultFormats[FormattedInputDefaultFormats["Time12Hour"] = 6] = "Time12Hour";
|
|
30457
|
+
FormattedInputDefaultFormats[FormattedInputDefaultFormats["Time24Hour"] = 7] = "Time24Hour";
|
|
30458
|
+
FormattedInputDefaultFormats[FormattedInputDefaultFormats["Custom"] = 8] = "Custom";
|
|
30459
|
+
})(FormattedInputDefaultFormats || (FormattedInputDefaultFormats = {}));
|
|
30460
|
+
|
|
30461
|
+
var InputSlotCreator = (function () {
|
|
30462
|
+
function InputSlotCreator() {
|
|
30463
|
+
}
|
|
30464
|
+
InputSlotCreator.create = function (formatPartEntries) {
|
|
30465
|
+
var slots = [];
|
|
30466
|
+
for (var i = 0, len = formatPartEntries.length; i < len; i++) {
|
|
30467
|
+
var entry = formatPartEntries[i];
|
|
30468
|
+
if (entry.isSeparator) {
|
|
30469
|
+
continue;
|
|
30470
|
+
}
|
|
30471
|
+
slots.push(__assign({ partIndex: i, partText: '', isComplete: false }, entry));
|
|
30472
|
+
}
|
|
30473
|
+
return slots;
|
|
30474
|
+
};
|
|
30475
|
+
return InputSlotCreator;
|
|
30476
|
+
}());
|
|
30477
|
+
|
|
30478
|
+
var PartEntryCreator = (function () {
|
|
30479
|
+
function PartEntryCreator() {
|
|
30480
|
+
}
|
|
30481
|
+
PartEntryCreator.create = function (format) {
|
|
30482
|
+
var formatPartList = [];
|
|
30483
|
+
var currentIndex = 0;
|
|
30484
|
+
for (var i = 0, len = format.formatParts.length; i < len; i++) {
|
|
30485
|
+
var formatPart = format.formatParts[i];
|
|
30486
|
+
var startPosition = currentIndex;
|
|
30487
|
+
var endPosition = startPosition + formatPart.characterCount;
|
|
30488
|
+
formatPartList.push(__assign({ startPosition: startPosition, endPosition: endPosition }, formatPart));
|
|
30489
|
+
currentIndex = endPosition;
|
|
30490
|
+
}
|
|
30491
|
+
return formatPartList;
|
|
30492
|
+
};
|
|
30493
|
+
return PartEntryCreator;
|
|
30494
|
+
}());
|
|
30495
|
+
|
|
30496
|
+
var InputSlotCollection = (function () {
|
|
30497
|
+
function InputSlotCollection(format) {
|
|
30498
|
+
this.inputSlots = InputSlotCreator.create(PartEntryCreator.create(format));
|
|
30499
|
+
}
|
|
30500
|
+
InputSlotCollection.getInstance = function (format) {
|
|
30501
|
+
if (!this.instance) {
|
|
30502
|
+
this.instance = new InputSlotCollection(format);
|
|
30503
|
+
}
|
|
30504
|
+
return this.instance;
|
|
30505
|
+
};
|
|
30506
|
+
InputSlotCollection.prototype.clearAllSlots = function () {
|
|
30507
|
+
for (var i = 0, length_1 = this.inputSlots.length; i < length_1; i++) {
|
|
30508
|
+
this.inputSlots[i].partText = '';
|
|
30509
|
+
}
|
|
30510
|
+
};
|
|
30511
|
+
InputSlotCollection.prototype.getSlot = function (partIndex) {
|
|
30512
|
+
return this.inputSlots.find(function (slot) { return slot.partIndex === partIndex; });
|
|
30513
|
+
};
|
|
30514
|
+
InputSlotCollection.prototype.getFirstSlot = function () {
|
|
30515
|
+
return this.inputSlots[0];
|
|
30516
|
+
};
|
|
30517
|
+
InputSlotCollection.prototype.getNextSlot = function (currentPartIndex) {
|
|
30518
|
+
var currentIndex = this.inputSlots.findIndex(function (slot) { return slot.partIndex === currentPartIndex; });
|
|
30519
|
+
if (currentIndex > -1 && currentIndex + 1 < this.inputSlots.length) {
|
|
30520
|
+
return this.inputSlots[currentIndex + 1];
|
|
30521
|
+
}
|
|
30522
|
+
};
|
|
30523
|
+
InputSlotCollection.prototype.getPreviousSlot = function (currentPartIndex) {
|
|
30524
|
+
var currentIndex = this.inputSlots.findIndex(function (slot) { return slot.partIndex === currentPartIndex; });
|
|
30525
|
+
if (currentIndex > -1 && currentIndex - 1 >= 0) {
|
|
30526
|
+
return this.inputSlots[currentIndex - 1];
|
|
30527
|
+
}
|
|
30528
|
+
};
|
|
30529
|
+
InputSlotCollection.prototype.getLastSlotWithData = function () {
|
|
30530
|
+
var incompleteSlotIndex = this.inputSlots.findIndex(function (slot) { return !slot.isComplete; });
|
|
30531
|
+
var finalSlotIndex = incompleteSlotIndex;
|
|
30532
|
+
for (var i = incompleteSlotIndex + 1, length_2 = this.inputSlots.length; i < length_2; i++) {
|
|
30533
|
+
var slot = this.inputSlots[i];
|
|
30534
|
+
if (slot.partText.length > 0) {
|
|
30535
|
+
finalSlotIndex = i;
|
|
30536
|
+
}
|
|
30537
|
+
}
|
|
30538
|
+
return this.inputSlots[finalSlotIndex];
|
|
30539
|
+
};
|
|
30540
|
+
InputSlotCollection.prototype.allSlotsCompleted = function () {
|
|
30541
|
+
return this.inputSlots.every(function (slot) { return slot.isComplete; });
|
|
30542
|
+
};
|
|
30543
|
+
return InputSlotCollection;
|
|
30544
|
+
}());
|
|
30545
|
+
|
|
30546
|
+
var FormatNavigator = (function () {
|
|
30547
|
+
function FormatNavigator(format) {
|
|
30548
|
+
this.currentPartIndex = 0;
|
|
30549
|
+
this.currentCursorPosition = 0;
|
|
30550
|
+
this.inputSelection = null;
|
|
30551
|
+
this.formatPartList = PartEntryCreator.create(format);
|
|
30552
|
+
this.inputSlotCollection = InputSlotCollection.getInstance(format);
|
|
30553
|
+
}
|
|
30554
|
+
FormatNavigator.getInstance = function (format) {
|
|
30555
|
+
if (!this._instance) {
|
|
30556
|
+
this._instance = new FormatNavigator(format);
|
|
30557
|
+
}
|
|
30558
|
+
return this._instance;
|
|
30559
|
+
};
|
|
30560
|
+
FormatNavigator.prototype.getCursorPosition = function () {
|
|
30561
|
+
return this.currentCursorPosition;
|
|
30562
|
+
};
|
|
30563
|
+
FormatNavigator.prototype.getCurrentPartIndex = function () {
|
|
30564
|
+
return this.currentPartIndex;
|
|
30565
|
+
};
|
|
30566
|
+
FormatNavigator.prototype.setInputElement = function (element) {
|
|
30567
|
+
this.inputElement = element;
|
|
30568
|
+
};
|
|
30569
|
+
FormatNavigator.prototype.setCursorToCurrentPosition = function () {
|
|
30570
|
+
this.setCursorSelection(this.currentCursorPosition);
|
|
30571
|
+
};
|
|
30572
|
+
FormatNavigator.prototype.setCursorPosition = function (position) {
|
|
30573
|
+
this.setCursorSelection(position);
|
|
30574
|
+
};
|
|
30575
|
+
FormatNavigator.prototype.setCursorSelection = function (start, end) {
|
|
30576
|
+
this.createInputRangeSelection();
|
|
30577
|
+
if (this.inputRange && this.textNode) {
|
|
30578
|
+
this.inputRange.setStart(this.textNode, start);
|
|
30579
|
+
this.inputRange.setEnd(this.textNode, end || start);
|
|
30580
|
+
this.currentCursorPosition = end || start;
|
|
30581
|
+
this.setPartIndexByCursorPosition();
|
|
30582
|
+
}
|
|
30583
|
+
};
|
|
30584
|
+
FormatNavigator.prototype.isAtLastPart = function () {
|
|
30585
|
+
return this.currentPartIndex === this.formatPartList.length - 1;
|
|
30586
|
+
};
|
|
30587
|
+
FormatNavigator.prototype.moveHome = function () {
|
|
30588
|
+
var firstSlot = this.inputSlotCollection.getFirstSlot();
|
|
30589
|
+
this.setCursorSelection(firstSlot.startPosition);
|
|
30590
|
+
};
|
|
30591
|
+
FormatNavigator.prototype.moveEnd = function () {
|
|
30592
|
+
var lastDataSlot = this.inputSlotCollection.getLastSlotWithData();
|
|
30593
|
+
var lastCursorPosition = lastDataSlot.startPosition + lastDataSlot.partText.length;
|
|
30594
|
+
this.setCursorSelection(lastCursorPosition);
|
|
30595
|
+
};
|
|
30596
|
+
FormatNavigator.prototype.moveCursorLeft = function () {
|
|
30597
|
+
if (this.currentCursorPosition > 0) {
|
|
30598
|
+
var newCursorPosition = this.currentCursorPosition - 1;
|
|
30599
|
+
var currentPartEntry = this.formatPartList[this.currentPartIndex];
|
|
30600
|
+
if (newCursorPosition >= currentPartEntry.startPosition && newCursorPosition <= currentPartEntry.endPosition) {
|
|
30601
|
+
this.setCursorSelection(newCursorPosition);
|
|
30602
|
+
}
|
|
30603
|
+
else {
|
|
30604
|
+
for (var i = this.currentPartIndex - 1; i >= 0; i--) {
|
|
30605
|
+
currentPartEntry = this.formatPartList[i];
|
|
30606
|
+
if (newCursorPosition >= currentPartEntry.startPosition &&
|
|
30607
|
+
newCursorPosition <= currentPartEntry.endPosition) {
|
|
30608
|
+
if (currentPartEntry.isSeparator) {
|
|
30609
|
+
this.setCursorSelection(this.formatPartList[i - 1].endPosition);
|
|
30610
|
+
}
|
|
30611
|
+
else {
|
|
30612
|
+
this.setCursorSelection(newCursorPosition);
|
|
30613
|
+
}
|
|
30614
|
+
}
|
|
30615
|
+
}
|
|
30616
|
+
}
|
|
30617
|
+
}
|
|
30618
|
+
};
|
|
30619
|
+
FormatNavigator.prototype.moveCursorRight = function () {
|
|
30620
|
+
var lastDataSlot = this.inputSlotCollection.getLastSlotWithData();
|
|
30621
|
+
var lastCursorPosition = lastDataSlot.startPosition + lastDataSlot.partText.length;
|
|
30622
|
+
if (this.currentCursorPosition < lastCursorPosition) {
|
|
30623
|
+
var newCursorPosition = this.currentCursorPosition + 1;
|
|
30624
|
+
var currentPartEntry = this.formatPartList[this.currentPartIndex];
|
|
30625
|
+
if (newCursorPosition >= currentPartEntry.startPosition && newCursorPosition <= currentPartEntry.endPosition) {
|
|
30626
|
+
this.setCursorSelection(newCursorPosition);
|
|
30627
|
+
}
|
|
30628
|
+
else {
|
|
30629
|
+
for (var i = this.currentPartIndex + 1, length_1 = this.formatPartList.length; i < length_1; i++) {
|
|
30630
|
+
currentPartEntry = this.formatPartList[i];
|
|
30631
|
+
if (newCursorPosition >= currentPartEntry.startPosition &&
|
|
30632
|
+
newCursorPosition <= currentPartEntry.endPosition) {
|
|
30633
|
+
if (currentPartEntry.isSeparator) {
|
|
30634
|
+
this.setCursorSelection(this.formatPartList[i + 1].startPosition);
|
|
30635
|
+
}
|
|
30636
|
+
else {
|
|
30637
|
+
this.setCursorSelection(newCursorPosition);
|
|
30638
|
+
}
|
|
30639
|
+
}
|
|
30640
|
+
}
|
|
30641
|
+
}
|
|
30642
|
+
}
|
|
30643
|
+
};
|
|
30644
|
+
FormatNavigator.prototype.moveToNextInputPart = function () {
|
|
30645
|
+
if (this.currentPartIndex < this.formatPartList.length - 1) {
|
|
30646
|
+
var partEntry = this.findNextEditablePart();
|
|
30647
|
+
if (partEntry) {
|
|
30648
|
+
this.currentPartIndex = partEntry.partIndex;
|
|
30649
|
+
this.setCursorSelection(partEntry.startPosition);
|
|
30650
|
+
}
|
|
30651
|
+
}
|
|
30652
|
+
};
|
|
30653
|
+
FormatNavigator.prototype.moveToPreviousInputPart = function () {
|
|
30654
|
+
if (this.currentPartIndex > 0) {
|
|
30655
|
+
var partEntry = this.findPreviousEditablePart();
|
|
30656
|
+
if (partEntry) {
|
|
30657
|
+
this.currentPartIndex = partEntry.partIndex;
|
|
30658
|
+
this.setCursorSelection(partEntry.endPosition);
|
|
30659
|
+
}
|
|
30660
|
+
}
|
|
30661
|
+
};
|
|
30662
|
+
FormatNavigator.prototype.findNextEditablePart = function () {
|
|
30663
|
+
return this.inputSlotCollection.getNextSlot(this.currentPartIndex);
|
|
30664
|
+
};
|
|
30665
|
+
FormatNavigator.prototype.findPreviousEditablePart = function () {
|
|
30666
|
+
return this.inputSlotCollection.getPreviousSlot(this.currentPartIndex);
|
|
30667
|
+
};
|
|
30668
|
+
FormatNavigator.prototype.setPartIndexByCursorPosition = function () {
|
|
30669
|
+
for (var i = 0; i < this.formatPartList.length; i++) {
|
|
30670
|
+
var formatPart = this.formatPartList[i];
|
|
30671
|
+
if (this.currentCursorPosition >= formatPart.startPosition &&
|
|
30672
|
+
this.currentCursorPosition <= formatPart.endPosition) {
|
|
30673
|
+
if (formatPart.isSeparator) {
|
|
30674
|
+
this.currentCursorPosition = this.formatPartList[i + 1].startPosition;
|
|
30675
|
+
this.currentPartIndex = i + 1;
|
|
30676
|
+
break;
|
|
30677
|
+
}
|
|
30678
|
+
this.currentPartIndex = i;
|
|
30679
|
+
break;
|
|
30680
|
+
}
|
|
30681
|
+
}
|
|
30682
|
+
};
|
|
30683
|
+
FormatNavigator.prototype.createInputRangeSelection = function () {
|
|
30684
|
+
var _a, _b, _c;
|
|
30685
|
+
if (this.inputElement) {
|
|
30686
|
+
this.inputSelection = window.getSelection();
|
|
30687
|
+
this.inputRange = document.createRange();
|
|
30688
|
+
(_a = this.inputSelection) === null || _a === void 0 ? void 0 : _a.removeAllRanges();
|
|
30689
|
+
this.inputRange.selectNodeContents(this.inputElement);
|
|
30690
|
+
this.inputRange.collapse(true);
|
|
30691
|
+
(_b = this.inputSelection) === null || _b === void 0 ? void 0 : _b.removeAllRanges();
|
|
30692
|
+
(_c = this.inputSelection) === null || _c === void 0 ? void 0 : _c.addRange(this.inputRange);
|
|
30693
|
+
if (this.inputElement.firstChild) {
|
|
30694
|
+
this.textNode = this.inputElement.firstChild;
|
|
30695
|
+
}
|
|
30696
|
+
}
|
|
30697
|
+
};
|
|
30698
|
+
return FormatNavigator;
|
|
30699
|
+
}());
|
|
30700
|
+
|
|
30701
|
+
var FormatRenderer = (function () {
|
|
30702
|
+
function FormatRenderer(format) {
|
|
30703
|
+
this.formatPartList = PartEntryCreator.create(format);
|
|
30704
|
+
this.inputSlotCollection = InputSlotCollection.getInstance(format);
|
|
30705
|
+
}
|
|
30706
|
+
FormatRenderer.prototype.setInputElement = function (element) {
|
|
30707
|
+
this.inputElement = element;
|
|
30708
|
+
};
|
|
30709
|
+
FormatRenderer.prototype.render = function () {
|
|
30710
|
+
var _a;
|
|
30711
|
+
var output = '';
|
|
30712
|
+
for (var i = 0, length_1 = this.formatPartList.length; i < length_1; i++) {
|
|
30713
|
+
var partEntry = this.formatPartList[i];
|
|
30714
|
+
if (!partEntry.isSeparator) {
|
|
30715
|
+
var inputSlot = this.inputSlotCollection.getSlot(i);
|
|
30716
|
+
if (inputSlot) {
|
|
30717
|
+
output +=
|
|
30718
|
+
inputSlot.partText + ((_a = inputSlot.inputText) === null || _a === void 0 ? void 0 : _a.repeat(inputSlot.characterCount - inputSlot.partText.length));
|
|
30719
|
+
}
|
|
30720
|
+
}
|
|
30721
|
+
else {
|
|
30722
|
+
output += partEntry.inputText;
|
|
30723
|
+
}
|
|
30724
|
+
}
|
|
30725
|
+
if (this.inputElement) {
|
|
30726
|
+
this.inputElement.innerHTML = output;
|
|
30727
|
+
}
|
|
30728
|
+
};
|
|
30729
|
+
return FormatRenderer;
|
|
30730
|
+
}());
|
|
30731
|
+
|
|
30732
|
+
var FormatValueType;
|
|
30733
|
+
(function (FormatValueType) {
|
|
30734
|
+
FormatValueType[FormatValueType["Text"] = 0] = "Text";
|
|
30735
|
+
FormatValueType[FormatValueType["Numeric"] = 1] = "Numeric";
|
|
30736
|
+
})(FormatValueType || (FormatValueType = {}));
|
|
30737
|
+
|
|
30738
|
+
var KeyTypeChecker = (function () {
|
|
30739
|
+
function KeyTypeChecker() {
|
|
30740
|
+
this.numberKeys = ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9'];
|
|
30741
|
+
this.movementKeys = ['ArrowLeft', 'ArrowRight', 'Home', 'End'];
|
|
30742
|
+
this.editingKeys = ['Backspace', 'Delete'];
|
|
30743
|
+
this.ignoreKeys = ['Shift', 'Alt', 'Control', 'Fn', 'Meta'];
|
|
30744
|
+
}
|
|
30745
|
+
KeyTypeChecker.prototype.isNumberKey = function (key) {
|
|
30746
|
+
return this.numberKeys.includes(key);
|
|
30747
|
+
};
|
|
30748
|
+
KeyTypeChecker.prototype.isMovementKey = function (event) {
|
|
30749
|
+
return this.movementKeys.includes(event.key);
|
|
30750
|
+
};
|
|
30751
|
+
KeyTypeChecker.prototype.isEditingKey = function (event) {
|
|
30752
|
+
return this.editingKeys.includes(event.key);
|
|
30753
|
+
};
|
|
30754
|
+
KeyTypeChecker.prototype.isIgnoreKey = function (event) {
|
|
30755
|
+
return this.ignoreKeys.includes(event.key);
|
|
30756
|
+
};
|
|
30757
|
+
return KeyTypeChecker;
|
|
30758
|
+
}());
|
|
30759
|
+
|
|
30760
|
+
var PartEntryIterator = (function () {
|
|
30761
|
+
function PartEntryIterator(format) {
|
|
30762
|
+
this._currentIndex = 0;
|
|
30763
|
+
this.index = 0;
|
|
30764
|
+
this.formatParts = PartEntryCreator.create(format);
|
|
30765
|
+
}
|
|
30766
|
+
Object.defineProperty(PartEntryIterator.prototype, "currentIndex", {
|
|
30767
|
+
get: function () {
|
|
30768
|
+
return this._currentIndex;
|
|
30769
|
+
},
|
|
30770
|
+
enumerable: false,
|
|
30771
|
+
configurable: true
|
|
30772
|
+
});
|
|
30773
|
+
PartEntryIterator.prototype.hasNext = function () {
|
|
30774
|
+
return this.index < this.formatParts.length;
|
|
30775
|
+
};
|
|
30776
|
+
PartEntryIterator.prototype.next = function () {
|
|
30777
|
+
if (this.index < this.formatParts.length) {
|
|
30778
|
+
this._currentIndex = this.index++;
|
|
30779
|
+
return this.formatParts[this._currentIndex];
|
|
30780
|
+
}
|
|
30781
|
+
};
|
|
30782
|
+
PartEntryIterator.prototype.peek = function () {
|
|
30783
|
+
if (this.index < this.formatParts.length) {
|
|
30784
|
+
return this.formatParts[this.index];
|
|
30785
|
+
}
|
|
30786
|
+
};
|
|
30787
|
+
PartEntryIterator.prototype.reset = function () {
|
|
30788
|
+
this.index = 0;
|
|
30789
|
+
};
|
|
30790
|
+
return PartEntryIterator;
|
|
30791
|
+
}());
|
|
30792
|
+
|
|
30793
|
+
var InputRuleProcessor = (function () {
|
|
30794
|
+
function InputRuleProcessor(format) {
|
|
30795
|
+
this.format = format;
|
|
30796
|
+
this.inputSlotCollection = InputSlotCollection.getInstance(format);
|
|
30797
|
+
this.formatNavigator = FormatNavigator.getInstance(format);
|
|
30798
|
+
this.keyTypeChecker = new KeyTypeChecker();
|
|
30799
|
+
this.formatRenderer = new FormatRenderer(format);
|
|
30800
|
+
this.formatPartList = new PartEntryIterator(format);
|
|
30801
|
+
}
|
|
30802
|
+
InputRuleProcessor.prototype.setInputElement = function (element) {
|
|
30803
|
+
this.formatRenderer.setInputElement(element);
|
|
30804
|
+
};
|
|
30805
|
+
InputRuleProcessor.prototype.processKeyPress = function (event) {
|
|
30806
|
+
if (this.keyTypeChecker.isEditingKey(event)) {
|
|
30807
|
+
this.processEditRules(event);
|
|
30808
|
+
return;
|
|
30809
|
+
}
|
|
30810
|
+
this.processInputRules(event);
|
|
30811
|
+
};
|
|
30812
|
+
InputRuleProcessor.prototype.processInputValue = function (value) {
|
|
30813
|
+
var _a;
|
|
30814
|
+
this.inputSlotCollection.clearAllSlots();
|
|
30815
|
+
this.formatPartList.reset();
|
|
30816
|
+
var valueIndex = 0;
|
|
30817
|
+
while (this.formatPartList.hasNext()) {
|
|
30818
|
+
var partEntry = this.formatPartList.next();
|
|
30819
|
+
if (partEntry && !partEntry.isSeparator) {
|
|
30820
|
+
if (((_a = this.formatPartList.peek()) === null || _a === void 0 ? void 0 : _a.isSeparator) === true) {
|
|
30821
|
+
var formatPartIndex = this.formatPartList.currentIndex;
|
|
30822
|
+
var separator = this.formatPartList.next();
|
|
30823
|
+
if (separator && separator.inputText) {
|
|
30824
|
+
var separatorIndex = value.indexOf(separator.inputText, valueIndex);
|
|
30825
|
+
var slot = this.inputSlotCollection.getSlot(formatPartIndex);
|
|
30826
|
+
if (slot && separatorIndex > -1) {
|
|
30827
|
+
slot.partText = value.substring(valueIndex, separatorIndex);
|
|
30828
|
+
this.processSlotRules(slot);
|
|
30829
|
+
valueIndex = separatorIndex + separator.characterCount;
|
|
30830
|
+
}
|
|
30831
|
+
}
|
|
30832
|
+
}
|
|
30833
|
+
else {
|
|
30834
|
+
var slot = this.inputSlotCollection.getSlot(this.formatPartList.currentIndex);
|
|
30835
|
+
if (slot) {
|
|
30836
|
+
slot.partText = value.substring(valueIndex);
|
|
30837
|
+
this.processSlotRules(slot);
|
|
30838
|
+
}
|
|
30839
|
+
}
|
|
30840
|
+
}
|
|
30841
|
+
}
|
|
30842
|
+
};
|
|
30843
|
+
InputRuleProcessor.prototype.processEditRules = function (event) {
|
|
30844
|
+
var inputSlot = this.inputSlotCollection.getSlot(this.formatNavigator.getCurrentPartIndex());
|
|
30845
|
+
if (!inputSlot) {
|
|
30846
|
+
return;
|
|
30847
|
+
}
|
|
30848
|
+
var cursorPosition = this.formatNavigator.getCursorPosition();
|
|
30849
|
+
var cursorPositionInSlot = cursorPosition - inputSlot.startPosition;
|
|
30850
|
+
var deleteShiftsFormatPart = this.format.deleteShiftsFormatPart || false;
|
|
30851
|
+
switch (event.key) {
|
|
30852
|
+
case 'Backspace':
|
|
30853
|
+
var isAtBeginningOfInputSlot = inputSlot.startPosition === cursorPosition;
|
|
30854
|
+
if (!isAtBeginningOfInputSlot) {
|
|
30855
|
+
inputSlot.partText =
|
|
30856
|
+
inputSlot.partText.substring(0, cursorPositionInSlot - 1) +
|
|
30857
|
+
inputSlot.partText.substring(cursorPositionInSlot);
|
|
30858
|
+
if (deleteShiftsFormatPart) {
|
|
30859
|
+
this.shiftFormatParts(inputSlot);
|
|
30860
|
+
}
|
|
30861
|
+
this.formatRenderer.render();
|
|
30862
|
+
this.formatNavigator.moveCursorLeft();
|
|
30863
|
+
this.processSlotRules(inputSlot, true);
|
|
30864
|
+
}
|
|
30865
|
+
else {
|
|
30866
|
+
this.processSlotRules(inputSlot, true);
|
|
30867
|
+
var previousSlot = this.inputSlotCollection.getPreviousSlot(inputSlot.partIndex);
|
|
30868
|
+
if (previousSlot) {
|
|
30869
|
+
previousSlot.partText = previousSlot.partText.substring(0, previousSlot.partText.length - 1);
|
|
30870
|
+
if (deleteShiftsFormatPart) {
|
|
30871
|
+
this.shiftFormatParts(previousSlot);
|
|
30872
|
+
}
|
|
30873
|
+
this.formatRenderer.render();
|
|
30874
|
+
this.formatNavigator.setCursorPosition(previousSlot.startPosition + previousSlot.partText.length);
|
|
30875
|
+
this.processSlotRules(previousSlot, true);
|
|
30876
|
+
}
|
|
30877
|
+
}
|
|
30878
|
+
break;
|
|
30879
|
+
case 'Delete':
|
|
30880
|
+
inputSlot.partText =
|
|
30881
|
+
inputSlot.partText.substring(0, cursorPositionInSlot) +
|
|
30882
|
+
inputSlot.partText.substring(cursorPositionInSlot + 1);
|
|
30883
|
+
if (deleteShiftsFormatPart) {
|
|
30884
|
+
this.shiftFormatParts(inputSlot);
|
|
30885
|
+
}
|
|
30886
|
+
this.formatRenderer.render();
|
|
30887
|
+
this.formatNavigator.setCursorToCurrentPosition();
|
|
30888
|
+
this.processSlotRules(inputSlot, true);
|
|
30889
|
+
break;
|
|
30890
|
+
}
|
|
30891
|
+
};
|
|
30892
|
+
InputRuleProcessor.prototype.shiftFormatParts = function (inputSlot) {
|
|
30893
|
+
var previousSlot = inputSlot;
|
|
30894
|
+
var nextSlot;
|
|
30895
|
+
while ((nextSlot = this.inputSlotCollection.getNextSlot(previousSlot.partIndex)) !== undefined) {
|
|
30896
|
+
var removedCharacter = nextSlot.partText.substring(0, 1);
|
|
30897
|
+
nextSlot.partText = nextSlot.partText.substring(1);
|
|
30898
|
+
previousSlot.partText = previousSlot.partText + removedCharacter;
|
|
30899
|
+
previousSlot = nextSlot;
|
|
30900
|
+
}
|
|
30901
|
+
};
|
|
30902
|
+
InputRuleProcessor.prototype.processInputRules = function (event) {
|
|
30903
|
+
var inputSlot = this.inputSlotCollection.getSlot(this.formatNavigator.getCurrentPartIndex());
|
|
30904
|
+
if (!inputSlot) {
|
|
30905
|
+
return;
|
|
30906
|
+
}
|
|
30907
|
+
var key = event.key;
|
|
30908
|
+
var characterCount = inputSlot.characterCount;
|
|
30909
|
+
var currentValue = inputSlot.partText;
|
|
30910
|
+
if (inputSlot.valueType === FormatValueType.Numeric) {
|
|
30911
|
+
if (!this.keyTypeChecker.isNumberKey(key)) {
|
|
30912
|
+
return;
|
|
30913
|
+
}
|
|
30914
|
+
var maximumValue = inputSlot.maximumValue;
|
|
30915
|
+
var exceedingMaximumValueCausesTab = inputSlot.exceedingMaximumValueCausesTab || false;
|
|
30916
|
+
var padWithZeros = inputSlot.padWithZeros || false;
|
|
30917
|
+
var newValue = parseInt(this.createNewValue(inputSlot, key));
|
|
30918
|
+
if (maximumValue && newValue > maximumValue) {
|
|
30919
|
+
if (exceedingMaximumValueCausesTab) {
|
|
30920
|
+
if (padWithZeros) {
|
|
30921
|
+
inputSlot.partText = inputSlot.partText.padStart(characterCount, '0');
|
|
30922
|
+
}
|
|
30923
|
+
inputSlot.isComplete = true;
|
|
30924
|
+
var nextSlot = this.inputSlotCollection.getNextSlot(inputSlot.partIndex);
|
|
30925
|
+
if (nextSlot && !nextSlot.isComplete) {
|
|
30926
|
+
nextSlot.partText = key;
|
|
30927
|
+
}
|
|
30928
|
+
this.formatRenderer.render();
|
|
30929
|
+
if (nextSlot) {
|
|
30930
|
+
this.formatNavigator.setCursorPosition(!nextSlot.isComplete ? nextSlot.startPosition + 1 : nextSlot.startPosition);
|
|
30931
|
+
}
|
|
30932
|
+
}
|
|
30933
|
+
else {
|
|
30934
|
+
return;
|
|
30935
|
+
}
|
|
30936
|
+
}
|
|
30937
|
+
else if (currentValue.length + 1 === characterCount) {
|
|
30938
|
+
this.addToInputSlot(key);
|
|
30939
|
+
inputSlot.isComplete = true;
|
|
30940
|
+
this.formatRenderer.render();
|
|
30941
|
+
if (!this.formatNavigator.isAtLastPart()) {
|
|
30942
|
+
this.formatNavigator.moveToNextInputPart();
|
|
30943
|
+
}
|
|
30944
|
+
else {
|
|
30945
|
+
this.formatNavigator.moveCursorRight();
|
|
30946
|
+
}
|
|
30947
|
+
}
|
|
30948
|
+
else {
|
|
30949
|
+
this.addToInputSlot(key);
|
|
30950
|
+
this.formatRenderer.render();
|
|
30951
|
+
this.formatNavigator.moveCursorRight();
|
|
30952
|
+
}
|
|
30953
|
+
}
|
|
30954
|
+
else {
|
|
30955
|
+
if (currentValue.length + 1 === characterCount) {
|
|
30956
|
+
this.addToInputSlot(key);
|
|
30957
|
+
inputSlot.isComplete = true;
|
|
30958
|
+
this.formatRenderer.render();
|
|
30959
|
+
this.formatNavigator.moveToNextInputPart();
|
|
30960
|
+
}
|
|
30961
|
+
else {
|
|
30962
|
+
this.addToInputSlot(key);
|
|
30963
|
+
this.formatRenderer.render();
|
|
30964
|
+
this.formatNavigator.moveCursorRight();
|
|
30965
|
+
}
|
|
30966
|
+
}
|
|
30967
|
+
};
|
|
30968
|
+
InputRuleProcessor.prototype.addToInputSlot = function (key) {
|
|
30969
|
+
var inputSlot = this.inputSlotCollection.getSlot(this.formatNavigator.getCurrentPartIndex());
|
|
30970
|
+
if (inputSlot) {
|
|
30971
|
+
inputSlot.partText = this.createNewValue(inputSlot, key);
|
|
30972
|
+
}
|
|
30973
|
+
};
|
|
30974
|
+
InputRuleProcessor.prototype.createNewValue = function (inputSlot, key) {
|
|
30975
|
+
var currentValue = inputSlot.partText;
|
|
30976
|
+
var cursorPosition = this.formatNavigator.getCursorPosition();
|
|
30977
|
+
if (cursorPosition >= inputSlot.startPosition + inputSlot.partText.length) {
|
|
30978
|
+
return currentValue + key;
|
|
30979
|
+
}
|
|
30980
|
+
else {
|
|
30981
|
+
var slotCursorPosition = cursorPosition - inputSlot.startPosition;
|
|
30982
|
+
return currentValue.substring(0, slotCursorPosition) + key + currentValue.substring(slotCursorPosition);
|
|
30983
|
+
}
|
|
30984
|
+
};
|
|
30985
|
+
InputRuleProcessor.prototype.processSlotRules = function (inputSlot, isEditing) {
|
|
30986
|
+
if (isEditing === void 0) { isEditing = false; }
|
|
30987
|
+
var characterCount = inputSlot.characterCount;
|
|
30988
|
+
var allCharactersRequired = inputSlot.allCharactersRequired || false;
|
|
30989
|
+
if (inputSlot.valueType === FormatValueType.Numeric) {
|
|
30990
|
+
var minimumValue = inputSlot.minimumValue;
|
|
30991
|
+
var maximumValue = inputSlot.maximumValue;
|
|
30992
|
+
if (allCharactersRequired) {
|
|
30993
|
+
inputSlot.isComplete = inputSlot.partText.length === characterCount;
|
|
30994
|
+
}
|
|
30995
|
+
else if (minimumValue !== undefined && maximumValue !== undefined) {
|
|
30996
|
+
var padWithZeros = inputSlot.padWithZeros || false;
|
|
30997
|
+
var currentValue = parseInt(inputSlot.partText);
|
|
30998
|
+
inputSlot.isComplete = currentValue >= minimumValue && currentValue <= maximumValue;
|
|
30999
|
+
if (inputSlot.isComplete && padWithZeros && !isEditing) {
|
|
31000
|
+
inputSlot.partText = inputSlot.partText.padStart(characterCount, '0');
|
|
31001
|
+
}
|
|
31002
|
+
}
|
|
31003
|
+
else {
|
|
31004
|
+
inputSlot.isComplete = inputSlot.partText.length > 0;
|
|
31005
|
+
}
|
|
31006
|
+
}
|
|
31007
|
+
else {
|
|
31008
|
+
if (allCharactersRequired) {
|
|
31009
|
+
inputSlot.isComplete = inputSlot.partText.length === characterCount;
|
|
31010
|
+
}
|
|
31011
|
+
else {
|
|
31012
|
+
inputSlot.isComplete = inputSlot.partText.length > 0;
|
|
31013
|
+
}
|
|
31014
|
+
}
|
|
31015
|
+
};
|
|
31016
|
+
return InputRuleProcessor;
|
|
31017
|
+
}());
|
|
31018
|
+
|
|
31019
|
+
var KeyProcessor = (function () {
|
|
31020
|
+
function KeyProcessor(format) {
|
|
31021
|
+
this.format = format;
|
|
31022
|
+
this.formatNavigator = FormatNavigator.getInstance(format);
|
|
31023
|
+
this.ruleProcessor = new InputRuleProcessor(format);
|
|
31024
|
+
this.keyTypeChecker = new KeyTypeChecker();
|
|
31025
|
+
this.formatRenderer = new FormatRenderer(format);
|
|
31026
|
+
}
|
|
31027
|
+
KeyProcessor.prototype.setInputElement = function (element) {
|
|
31028
|
+
this.ruleProcessor.setInputElement(element);
|
|
31029
|
+
this.formatRenderer.setInputElement(element);
|
|
31030
|
+
};
|
|
31031
|
+
KeyProcessor.prototype.processMovementKey = function (event) {
|
|
31032
|
+
var key = event.key, metaKey = event.metaKey;
|
|
31033
|
+
switch (key) {
|
|
31034
|
+
case 'ArrowLeft':
|
|
31035
|
+
if (!metaKey) {
|
|
31036
|
+
this.formatNavigator.moveCursorLeft();
|
|
31037
|
+
}
|
|
31038
|
+
else {
|
|
31039
|
+
this.formatNavigator.moveHome();
|
|
31040
|
+
}
|
|
31041
|
+
break;
|
|
31042
|
+
case 'ArrowRight':
|
|
31043
|
+
if (!metaKey) {
|
|
31044
|
+
this.formatNavigator.moveCursorRight();
|
|
31045
|
+
}
|
|
31046
|
+
else {
|
|
31047
|
+
this.formatNavigator.moveEnd();
|
|
31048
|
+
}
|
|
31049
|
+
break;
|
|
31050
|
+
case 'Home':
|
|
31051
|
+
this.formatNavigator.moveHome();
|
|
31052
|
+
break;
|
|
31053
|
+
case 'End':
|
|
31054
|
+
this.formatNavigator.moveEnd();
|
|
31055
|
+
break;
|
|
31056
|
+
}
|
|
31057
|
+
};
|
|
31058
|
+
KeyProcessor.prototype.processKeyPress = function (event) {
|
|
31059
|
+
if (this.keyTypeChecker.isIgnoreKey(event)) {
|
|
31060
|
+
return false;
|
|
31061
|
+
}
|
|
31062
|
+
if (this.keyTypeChecker.isMovementKey(event)) {
|
|
31063
|
+
this.processMovementKey(event);
|
|
31064
|
+
return false;
|
|
31065
|
+
}
|
|
31066
|
+
this.ruleProcessor.processKeyPress(event);
|
|
31067
|
+
return true;
|
|
31068
|
+
};
|
|
31069
|
+
return KeyProcessor;
|
|
31070
|
+
}());
|
|
31071
|
+
|
|
31072
|
+
var FormatParser = (function () {
|
|
31073
|
+
function FormatParser(format, inputValue) {
|
|
31074
|
+
if (inputValue === void 0) { inputValue = ''; }
|
|
31075
|
+
this.inputValue = inputValue;
|
|
31076
|
+
this.inputElementSet = false;
|
|
31077
|
+
this.keyProcessor = new KeyProcessor(format);
|
|
31078
|
+
this.formatNavigator = FormatNavigator.getInstance(format);
|
|
31079
|
+
this.formatRenderer = new FormatRenderer(format);
|
|
31080
|
+
this.inputSlotCollection = InputSlotCollection.getInstance(format);
|
|
31081
|
+
this.inputRuleProcessor = new InputRuleProcessor(format);
|
|
31082
|
+
}
|
|
31083
|
+
FormatParser.prototype.inputElementCreated = function (element) {
|
|
31084
|
+
this.keyProcessor.setInputElement(element);
|
|
31085
|
+
this.formatNavigator.setInputElement(element);
|
|
31086
|
+
this.formatRenderer.setInputElement(element);
|
|
31087
|
+
this.inputElement = element;
|
|
31088
|
+
this.inputElementSet = true;
|
|
31089
|
+
if (this.inputElementSet && this.inputValue.length > 0) {
|
|
31090
|
+
this.inputValuePassed(this.inputValue);
|
|
31091
|
+
}
|
|
31092
|
+
};
|
|
31093
|
+
FormatParser.prototype.inputFocused = function () {
|
|
31094
|
+
var _this = this;
|
|
31095
|
+
this.formatRenderer.render();
|
|
31096
|
+
setTimeout(function () { return _this.formatNavigator.setCursorToCurrentPosition(); });
|
|
31097
|
+
};
|
|
31098
|
+
FormatParser.prototype.inputValuePassed = function (inputValue) {
|
|
31099
|
+
var _this = this;
|
|
31100
|
+
this.inputValue = inputValue;
|
|
31101
|
+
if (this.inputElementSet && this.inputValue.length > 0) {
|
|
31102
|
+
this.inputRuleProcessor.processInputValue(inputValue);
|
|
31103
|
+
setTimeout(function () {
|
|
31104
|
+
_this.formatRenderer.render();
|
|
31105
|
+
_this.formatNavigator.setCursorToCurrentPosition();
|
|
31106
|
+
});
|
|
31107
|
+
}
|
|
31108
|
+
};
|
|
31109
|
+
FormatParser.prototype.registerFormatCompleteEvent = function (onFormatComplete) {
|
|
31110
|
+
this.onFormatComplete = onFormatComplete;
|
|
31111
|
+
};
|
|
31112
|
+
FormatParser.prototype.keyDownHandler = function (event) {
|
|
31113
|
+
if (event.key === 'Tab') {
|
|
31114
|
+
return;
|
|
31115
|
+
}
|
|
31116
|
+
event.preventDefault();
|
|
31117
|
+
event.stopPropagation();
|
|
31118
|
+
if (this.keyProcessor.processKeyPress(event)) {
|
|
31119
|
+
if (this.inputSlotCollection.allSlotsCompleted() && this.inputElement && this.onFormatComplete) {
|
|
31120
|
+
this.onFormatComplete(this.inputElement.innerHTML);
|
|
31121
|
+
}
|
|
31122
|
+
}
|
|
31123
|
+
};
|
|
31124
|
+
return FormatParser;
|
|
31125
|
+
}());
|
|
31126
|
+
|
|
31127
|
+
var format$7 = {
|
|
31128
|
+
formatParts: [
|
|
31129
|
+
{
|
|
31130
|
+
characterCount: 2,
|
|
31131
|
+
placeholder: 'D',
|
|
31132
|
+
inputText: '_',
|
|
31133
|
+
isSeparator: false,
|
|
31134
|
+
allCharactersRequired: false,
|
|
31135
|
+
valueType: FormatValueType.Numeric,
|
|
31136
|
+
minimumValue: 1,
|
|
31137
|
+
maximumValue: 31,
|
|
31138
|
+
exceedingMaximumValueCausesTab: true,
|
|
31139
|
+
padWithZeros: true,
|
|
31140
|
+
},
|
|
31141
|
+
{
|
|
31142
|
+
characterCount: 1,
|
|
31143
|
+
placeholder: '/',
|
|
31144
|
+
inputText: '/',
|
|
31145
|
+
isSeparator: true,
|
|
31146
|
+
},
|
|
31147
|
+
{
|
|
31148
|
+
characterCount: 2,
|
|
31149
|
+
placeholder: 'M',
|
|
31150
|
+
inputText: '_',
|
|
31151
|
+
isSeparator: false,
|
|
31152
|
+
allCharactersRequired: false,
|
|
31153
|
+
valueType: FormatValueType.Numeric,
|
|
31154
|
+
minimumValue: 1,
|
|
31155
|
+
maximumValue: 12,
|
|
31156
|
+
exceedingMaximumValueCausesTab: true,
|
|
31157
|
+
padWithZeros: true,
|
|
31158
|
+
},
|
|
31159
|
+
{
|
|
31160
|
+
characterCount: 1,
|
|
31161
|
+
placeholder: '/',
|
|
31162
|
+
inputText: '/',
|
|
31163
|
+
isSeparator: true,
|
|
31164
|
+
},
|
|
31165
|
+
{
|
|
31166
|
+
characterCount: 4,
|
|
31167
|
+
placeholder: 'Y',
|
|
31168
|
+
inputText: '_',
|
|
31169
|
+
isSeparator: false,
|
|
31170
|
+
allCharactersRequired: true,
|
|
31171
|
+
valueType: FormatValueType.Numeric,
|
|
31172
|
+
},
|
|
31173
|
+
],
|
|
31174
|
+
};
|
|
31175
|
+
|
|
31176
|
+
var format$6 = {
|
|
31177
|
+
formatParts: [
|
|
31178
|
+
{
|
|
31179
|
+
characterCount: 2,
|
|
31180
|
+
placeholder: 'M',
|
|
31181
|
+
inputText: '_',
|
|
31182
|
+
isSeparator: false,
|
|
31183
|
+
allCharactersRequired: false,
|
|
31184
|
+
valueType: FormatValueType.Numeric,
|
|
31185
|
+
minimumValue: 1,
|
|
31186
|
+
maximumValue: 12,
|
|
31187
|
+
exceedingMaximumValueCausesTab: true,
|
|
31188
|
+
padWithZeros: true,
|
|
31189
|
+
},
|
|
31190
|
+
{
|
|
31191
|
+
characterCount: 1,
|
|
31192
|
+
placeholder: '/',
|
|
31193
|
+
inputText: '/',
|
|
31194
|
+
isSeparator: true,
|
|
31195
|
+
},
|
|
31196
|
+
{
|
|
31197
|
+
characterCount: 2,
|
|
31198
|
+
placeholder: 'D',
|
|
31199
|
+
inputText: '_',
|
|
31200
|
+
isSeparator: false,
|
|
31201
|
+
allCharactersRequired: false,
|
|
31202
|
+
valueType: FormatValueType.Numeric,
|
|
31203
|
+
minimumValue: 1,
|
|
31204
|
+
maximumValue: 31,
|
|
31205
|
+
exceedingMaximumValueCausesTab: true,
|
|
31206
|
+
padWithZeros: true,
|
|
31207
|
+
},
|
|
31208
|
+
{
|
|
31209
|
+
characterCount: 1,
|
|
31210
|
+
placeholder: '/',
|
|
31211
|
+
inputText: '/',
|
|
31212
|
+
isSeparator: true,
|
|
31213
|
+
},
|
|
31214
|
+
{
|
|
31215
|
+
characterCount: 4,
|
|
31216
|
+
placeholder: 'Y',
|
|
31217
|
+
inputText: '_',
|
|
31218
|
+
isSeparator: false,
|
|
31219
|
+
allCharactersRequired: true,
|
|
31220
|
+
valueType: FormatValueType.Numeric,
|
|
31221
|
+
},
|
|
31222
|
+
],
|
|
31223
|
+
};
|
|
31224
|
+
|
|
31225
|
+
var format$5 = {
|
|
31226
|
+
formatParts: [
|
|
31227
|
+
{
|
|
31228
|
+
characterCount: 4,
|
|
31229
|
+
placeholder: 'Y',
|
|
31230
|
+
inputText: '_',
|
|
31231
|
+
isSeparator: false,
|
|
31232
|
+
allCharactersRequired: true,
|
|
31233
|
+
valueType: FormatValueType.Numeric,
|
|
31234
|
+
},
|
|
31235
|
+
{
|
|
31236
|
+
characterCount: 1,
|
|
31237
|
+
placeholder: '-',
|
|
31238
|
+
inputText: '-',
|
|
31239
|
+
isSeparator: true,
|
|
31240
|
+
},
|
|
31241
|
+
{
|
|
31242
|
+
characterCount: 2,
|
|
31243
|
+
placeholder: 'M',
|
|
31244
|
+
inputText: '_',
|
|
31245
|
+
isSeparator: false,
|
|
31246
|
+
allCharactersRequired: false,
|
|
31247
|
+
valueType: FormatValueType.Numeric,
|
|
31248
|
+
minimumValue: 1,
|
|
31249
|
+
maximumValue: 12,
|
|
31250
|
+
exceedingMaximumValueCausesTab: true,
|
|
31251
|
+
padWithZeros: true,
|
|
31252
|
+
},
|
|
31253
|
+
{
|
|
31254
|
+
characterCount: 1,
|
|
31255
|
+
placeholder: '-',
|
|
31256
|
+
inputText: '-',
|
|
31257
|
+
isSeparator: true,
|
|
31258
|
+
},
|
|
31259
|
+
{
|
|
31260
|
+
characterCount: 2,
|
|
31261
|
+
placeholder: 'D',
|
|
31262
|
+
inputText: '_',
|
|
31263
|
+
isSeparator: false,
|
|
31264
|
+
allCharactersRequired: false,
|
|
31265
|
+
valueType: FormatValueType.Numeric,
|
|
31266
|
+
minimumValue: 1,
|
|
31267
|
+
maximumValue: 31,
|
|
31268
|
+
exceedingMaximumValueCausesError: true,
|
|
31269
|
+
padWithZeros: true,
|
|
31270
|
+
},
|
|
31271
|
+
],
|
|
31272
|
+
};
|
|
31273
|
+
|
|
31274
|
+
var format$4 = {
|
|
31275
|
+
formatParts: [
|
|
31276
|
+
{
|
|
31277
|
+
characterCount: 2,
|
|
31278
|
+
placeholder: 'D',
|
|
31279
|
+
inputText: '_',
|
|
31280
|
+
isSeparator: false,
|
|
31281
|
+
allCharactersRequired: false,
|
|
31282
|
+
valueType: FormatValueType.Numeric,
|
|
31283
|
+
minimumValue: 1,
|
|
31284
|
+
maximumValue: 31,
|
|
31285
|
+
exceedingMaximumValueCausesTab: true,
|
|
31286
|
+
padWithZeros: true,
|
|
31287
|
+
},
|
|
31288
|
+
{
|
|
31289
|
+
characterCount: 1,
|
|
31290
|
+
placeholder: '/',
|
|
31291
|
+
inputText: '/',
|
|
31292
|
+
isSeparator: true,
|
|
31293
|
+
},
|
|
31294
|
+
{
|
|
31295
|
+
characterCount: 2,
|
|
31296
|
+
placeholder: 'M',
|
|
31297
|
+
inputText: '_',
|
|
31298
|
+
isSeparator: false,
|
|
31299
|
+
allCharactersRequired: false,
|
|
31300
|
+
valueType: FormatValueType.Numeric,
|
|
31301
|
+
minimumValue: 1,
|
|
31302
|
+
maximumValue: 12,
|
|
31303
|
+
exceedingMaximumValueCausesTab: true,
|
|
31304
|
+
padWithZeros: true,
|
|
31305
|
+
},
|
|
31306
|
+
{
|
|
31307
|
+
characterCount: 1,
|
|
31308
|
+
placeholder: '/',
|
|
31309
|
+
inputText: '/',
|
|
31310
|
+
isSeparator: true,
|
|
31311
|
+
},
|
|
31312
|
+
{
|
|
31313
|
+
characterCount: 4,
|
|
31314
|
+
placeholder: 'Y',
|
|
31315
|
+
inputText: '_',
|
|
31316
|
+
isSeparator: false,
|
|
31317
|
+
allCharactersRequired: true,
|
|
31318
|
+
valueType: FormatValueType.Numeric,
|
|
31319
|
+
},
|
|
31320
|
+
{
|
|
31321
|
+
characterCount: 3,
|
|
31322
|
+
placeholder: ' - ',
|
|
31323
|
+
inputText: ' - ',
|
|
31324
|
+
isSeparator: true,
|
|
31325
|
+
},
|
|
31326
|
+
{
|
|
31327
|
+
characterCount: 2,
|
|
31328
|
+
placeholder: 'D',
|
|
31329
|
+
inputText: '_',
|
|
31330
|
+
isSeparator: false,
|
|
31331
|
+
allCharactersRequired: false,
|
|
31332
|
+
valueType: FormatValueType.Numeric,
|
|
31333
|
+
minimumValue: 1,
|
|
31334
|
+
maximumValue: 31,
|
|
31335
|
+
exceedingMaximumValueCausesTab: true,
|
|
31336
|
+
padWithZeros: true,
|
|
31337
|
+
},
|
|
31338
|
+
{
|
|
31339
|
+
characterCount: 1,
|
|
31340
|
+
placeholder: '/',
|
|
31341
|
+
inputText: '/',
|
|
31342
|
+
isSeparator: true,
|
|
31343
|
+
},
|
|
31344
|
+
{
|
|
31345
|
+
characterCount: 2,
|
|
31346
|
+
placeholder: 'M',
|
|
31347
|
+
inputText: '_',
|
|
31348
|
+
isSeparator: false,
|
|
31349
|
+
allCharactersRequired: false,
|
|
31350
|
+
valueType: FormatValueType.Numeric,
|
|
31351
|
+
minimumValue: 1,
|
|
31352
|
+
maximumValue: 12,
|
|
31353
|
+
exceedingMaximumValueCausesTab: true,
|
|
31354
|
+
padWithZeros: true,
|
|
31355
|
+
},
|
|
31356
|
+
{
|
|
31357
|
+
characterCount: 1,
|
|
31358
|
+
placeholder: '/',
|
|
31359
|
+
inputText: '/',
|
|
31360
|
+
isSeparator: true,
|
|
31361
|
+
},
|
|
31362
|
+
{
|
|
31363
|
+
characterCount: 4,
|
|
31364
|
+
placeholder: 'Y',
|
|
31365
|
+
inputText: '_',
|
|
31366
|
+
isSeparator: false,
|
|
31367
|
+
allCharactersRequired: true,
|
|
31368
|
+
valueType: FormatValueType.Numeric,
|
|
31369
|
+
},
|
|
31370
|
+
],
|
|
31371
|
+
};
|
|
31372
|
+
|
|
31373
|
+
var format$3 = {
|
|
31374
|
+
formatParts: [
|
|
31375
|
+
{
|
|
31376
|
+
characterCount: 2,
|
|
31377
|
+
placeholder: 'M',
|
|
31378
|
+
inputText: '_',
|
|
31379
|
+
isSeparator: false,
|
|
31380
|
+
allCharactersRequired: false,
|
|
31381
|
+
valueType: FormatValueType.Numeric,
|
|
31382
|
+
minimumValue: 1,
|
|
31383
|
+
maximumValue: 12,
|
|
31384
|
+
exceedingMaximumValueCausesTab: true,
|
|
31385
|
+
padWithZeros: true,
|
|
31386
|
+
},
|
|
31387
|
+
{
|
|
31388
|
+
characterCount: 1,
|
|
31389
|
+
placeholder: '/',
|
|
31390
|
+
inputText: '/',
|
|
31391
|
+
isSeparator: true,
|
|
31392
|
+
},
|
|
31393
|
+
{
|
|
31394
|
+
characterCount: 2,
|
|
31395
|
+
placeholder: 'D',
|
|
31396
|
+
inputText: '_',
|
|
31397
|
+
isSeparator: false,
|
|
31398
|
+
allCharactersRequired: false,
|
|
31399
|
+
valueType: FormatValueType.Numeric,
|
|
31400
|
+
minimumValue: 1,
|
|
31401
|
+
maximumValue: 31,
|
|
31402
|
+
exceedingMaximumValueCausesTab: true,
|
|
31403
|
+
padWithZeros: true,
|
|
31404
|
+
},
|
|
31405
|
+
{
|
|
31406
|
+
characterCount: 1,
|
|
31407
|
+
placeholder: '/',
|
|
31408
|
+
inputText: '/',
|
|
31409
|
+
isSeparator: true,
|
|
31410
|
+
},
|
|
31411
|
+
{
|
|
31412
|
+
characterCount: 4,
|
|
31413
|
+
placeholder: 'Y',
|
|
31414
|
+
inputText: '_',
|
|
31415
|
+
isSeparator: false,
|
|
31416
|
+
allCharactersRequired: true,
|
|
31417
|
+
valueType: FormatValueType.Numeric,
|
|
31418
|
+
},
|
|
31419
|
+
{
|
|
31420
|
+
characterCount: 3,
|
|
31421
|
+
placeholder: ' - ',
|
|
31422
|
+
inputText: ' - ',
|
|
31423
|
+
isSeparator: true,
|
|
31424
|
+
},
|
|
31425
|
+
{
|
|
31426
|
+
characterCount: 2,
|
|
31427
|
+
placeholder: 'M',
|
|
31428
|
+
inputText: '_',
|
|
31429
|
+
isSeparator: false,
|
|
31430
|
+
allCharactersRequired: false,
|
|
31431
|
+
valueType: FormatValueType.Numeric,
|
|
31432
|
+
minimumValue: 1,
|
|
31433
|
+
maximumValue: 12,
|
|
31434
|
+
exceedingMaximumValueCausesTab: true,
|
|
31435
|
+
padWithZeros: true,
|
|
31436
|
+
},
|
|
31437
|
+
{
|
|
31438
|
+
characterCount: 1,
|
|
31439
|
+
placeholder: '/',
|
|
31440
|
+
inputText: '/',
|
|
31441
|
+
isSeparator: true,
|
|
31442
|
+
},
|
|
31443
|
+
{
|
|
31444
|
+
characterCount: 2,
|
|
31445
|
+
placeholder: 'D',
|
|
31446
|
+
inputText: '_',
|
|
31447
|
+
isSeparator: false,
|
|
31448
|
+
allCharactersRequired: false,
|
|
31449
|
+
valueType: FormatValueType.Numeric,
|
|
31450
|
+
minimumValue: 1,
|
|
31451
|
+
maximumValue: 31,
|
|
31452
|
+
exceedingMaximumValueCausesTab: true,
|
|
31453
|
+
padWithZeros: true,
|
|
31454
|
+
},
|
|
31455
|
+
{
|
|
31456
|
+
characterCount: 1,
|
|
31457
|
+
placeholder: '/',
|
|
31458
|
+
inputText: '/',
|
|
31459
|
+
isSeparator: true,
|
|
31460
|
+
},
|
|
31461
|
+
{
|
|
31462
|
+
characterCount: 4,
|
|
31463
|
+
placeholder: 'Y',
|
|
31464
|
+
inputText: '_',
|
|
31465
|
+
isSeparator: false,
|
|
31466
|
+
allCharactersRequired: true,
|
|
31467
|
+
valueType: FormatValueType.Numeric,
|
|
31468
|
+
},
|
|
31469
|
+
],
|
|
31470
|
+
};
|
|
31471
|
+
|
|
31472
|
+
var format$2 = {
|
|
31473
|
+
formatParts: [
|
|
31474
|
+
{
|
|
31475
|
+
characterCount: 4,
|
|
31476
|
+
placeholder: 'Y',
|
|
31477
|
+
inputText: '_',
|
|
31478
|
+
isSeparator: false,
|
|
31479
|
+
allCharactersRequired: true,
|
|
31480
|
+
valueType: FormatValueType.Numeric,
|
|
31481
|
+
},
|
|
31482
|
+
{
|
|
31483
|
+
characterCount: 1,
|
|
31484
|
+
placeholder: '-',
|
|
31485
|
+
inputText: '-',
|
|
31486
|
+
isSeparator: true,
|
|
31487
|
+
},
|
|
31488
|
+
{
|
|
31489
|
+
characterCount: 2,
|
|
31490
|
+
placeholder: 'M',
|
|
31491
|
+
inputText: '_',
|
|
31492
|
+
isSeparator: false,
|
|
31493
|
+
allCharactersRequired: false,
|
|
31494
|
+
valueType: FormatValueType.Numeric,
|
|
31495
|
+
minimumValue: 1,
|
|
31496
|
+
maximumValue: 12,
|
|
31497
|
+
exceedingMaximumValueCausesTab: true,
|
|
31498
|
+
padWithZeros: true,
|
|
31499
|
+
},
|
|
31500
|
+
{
|
|
31501
|
+
characterCount: 1,
|
|
31502
|
+
placeholder: '-',
|
|
31503
|
+
inputText: '-',
|
|
31504
|
+
isSeparator: true,
|
|
31505
|
+
},
|
|
31506
|
+
{
|
|
31507
|
+
characterCount: 2,
|
|
31508
|
+
placeholder: 'D',
|
|
31509
|
+
inputText: '_',
|
|
31510
|
+
isSeparator: false,
|
|
31511
|
+
allCharactersRequired: false,
|
|
31512
|
+
valueType: FormatValueType.Numeric,
|
|
31513
|
+
minimumValue: 1,
|
|
31514
|
+
maximumValue: 31,
|
|
31515
|
+
exceedingMaximumValueCausesTab: true,
|
|
31516
|
+
padWithZeros: true,
|
|
31517
|
+
},
|
|
31518
|
+
{
|
|
31519
|
+
characterCount: 3,
|
|
31520
|
+
placeholder: ' - ',
|
|
31521
|
+
inputText: ' - ',
|
|
31522
|
+
isSeparator: true,
|
|
31523
|
+
},
|
|
31524
|
+
{
|
|
31525
|
+
characterCount: 4,
|
|
31526
|
+
placeholder: 'Y',
|
|
31527
|
+
inputText: '_',
|
|
31528
|
+
isSeparator: false,
|
|
31529
|
+
allCharactersRequired: true,
|
|
31530
|
+
valueType: FormatValueType.Numeric,
|
|
31531
|
+
},
|
|
31532
|
+
{
|
|
31533
|
+
characterCount: 1,
|
|
31534
|
+
placeholder: '-',
|
|
31535
|
+
inputText: '-',
|
|
31536
|
+
isSeparator: true,
|
|
31537
|
+
},
|
|
31538
|
+
{
|
|
31539
|
+
characterCount: 2,
|
|
31540
|
+
placeholder: 'M',
|
|
31541
|
+
inputText: '_',
|
|
31542
|
+
isSeparator: false,
|
|
31543
|
+
allCharactersRequired: false,
|
|
31544
|
+
valueType: FormatValueType.Numeric,
|
|
31545
|
+
minimumValue: 1,
|
|
31546
|
+
maximumValue: 12,
|
|
31547
|
+
exceedingMaximumValueCausesTab: true,
|
|
31548
|
+
padWithZeros: true,
|
|
31549
|
+
},
|
|
31550
|
+
{
|
|
31551
|
+
characterCount: 1,
|
|
31552
|
+
placeholder: '/',
|
|
31553
|
+
inputText: '/',
|
|
31554
|
+
isSeparator: true,
|
|
31555
|
+
},
|
|
31556
|
+
{
|
|
31557
|
+
characterCount: 2,
|
|
31558
|
+
placeholder: 'D',
|
|
31559
|
+
inputText: '_',
|
|
31560
|
+
isSeparator: false,
|
|
31561
|
+
allCharactersRequired: false,
|
|
31562
|
+
valueType: FormatValueType.Numeric,
|
|
31563
|
+
minimumValue: 1,
|
|
31564
|
+
maximumValue: 31,
|
|
31565
|
+
exceedingMaximumValueCausesError: true,
|
|
31566
|
+
padWithZeros: true,
|
|
31567
|
+
},
|
|
31568
|
+
],
|
|
31569
|
+
};
|
|
31570
|
+
|
|
31571
|
+
var format$1 = {
|
|
31572
|
+
formatParts: [
|
|
31573
|
+
{
|
|
31574
|
+
characterCount: 2,
|
|
31575
|
+
placeholder: 'H',
|
|
31576
|
+
inputText: '_',
|
|
31577
|
+
isSeparator: false,
|
|
31578
|
+
allCharactersRequired: false,
|
|
31579
|
+
valueType: FormatValueType.Numeric,
|
|
31580
|
+
minimumValue: 1,
|
|
31581
|
+
maximumValue: 12,
|
|
31582
|
+
exceedingMaximumValueCausesTab: true,
|
|
31583
|
+
padWithZeros: true,
|
|
31584
|
+
},
|
|
31585
|
+
{
|
|
31586
|
+
characterCount: 1,
|
|
31587
|
+
placeholder: ':',
|
|
31588
|
+
inputText: ':',
|
|
31589
|
+
isSeparator: true,
|
|
31590
|
+
},
|
|
31591
|
+
{
|
|
31592
|
+
characterCount: 2,
|
|
31593
|
+
placeholder: 'M',
|
|
31594
|
+
inputText: '_',
|
|
31595
|
+
isSeparator: false,
|
|
31596
|
+
allCharactersRequired: false,
|
|
31597
|
+
valueType: FormatValueType.Numeric,
|
|
31598
|
+
minimumValue: 0,
|
|
31599
|
+
maximumValue: 59,
|
|
31600
|
+
exceedingMaximumValueCausesError: true,
|
|
31601
|
+
padWithZeros: true,
|
|
31602
|
+
},
|
|
31603
|
+
{
|
|
31604
|
+
characterCount: 1,
|
|
31605
|
+
placeholder: ' ',
|
|
31606
|
+
inputText: ' ',
|
|
31607
|
+
isSeparator: true,
|
|
31608
|
+
},
|
|
31609
|
+
{
|
|
31610
|
+
characterCount: 2,
|
|
31611
|
+
isSeparator: false,
|
|
31612
|
+
possibleValues: ['AM', 'PM'],
|
|
31613
|
+
},
|
|
31614
|
+
],
|
|
31615
|
+
};
|
|
31616
|
+
|
|
31617
|
+
var format = {
|
|
31618
|
+
formatParts: [
|
|
31619
|
+
{
|
|
31620
|
+
characterCount: 2,
|
|
31621
|
+
placeholder: 'H',
|
|
31622
|
+
inputText: '_',
|
|
31623
|
+
isSeparator: false,
|
|
31624
|
+
allCharactersRequired: false,
|
|
31625
|
+
valueType: FormatValueType.Numeric,
|
|
31626
|
+
minimumValue: 0,
|
|
31627
|
+
maximumValue: 23,
|
|
31628
|
+
exceedingMaximumValueCausesTab: true,
|
|
31629
|
+
padWithZeros: true,
|
|
31630
|
+
},
|
|
31631
|
+
{
|
|
31632
|
+
characterCount: 1,
|
|
31633
|
+
placeholder: ':',
|
|
31634
|
+
inputText: ':',
|
|
31635
|
+
isSeparator: true,
|
|
31636
|
+
},
|
|
31637
|
+
{
|
|
31638
|
+
characterCount: 2,
|
|
31639
|
+
placeholder: 'M',
|
|
31640
|
+
inputText: '_',
|
|
31641
|
+
isSeparator: false,
|
|
31642
|
+
allCharactersRequired: false,
|
|
31643
|
+
valueType: FormatValueType.Numeric,
|
|
31644
|
+
minimumValue: 1,
|
|
31645
|
+
maximumValue: 59,
|
|
31646
|
+
exceedingMaximumValueCausesError: true,
|
|
31647
|
+
padWithZeros: true,
|
|
31648
|
+
},
|
|
31649
|
+
],
|
|
31650
|
+
};
|
|
31651
|
+
|
|
31652
|
+
var FormattedInput = function (props, ref) {
|
|
31653
|
+
var _a = props.value, value = _a === void 0 ? '' : _a, format$8 = props.format, _b = props.defaultFormat, defaultFormat = _b === void 0 ? FormattedInputDefaultFormats.Custom : _b, _c = props.readOnly, readOnly = _c === void 0 ? false : _c, _d = props.debounceTime, debounceTime = _d === void 0 ? 800 : _d, _e = props.fillContainer, fillContainer = _e === void 0 ? true : _e, leftElement = props.leftElement, rightElement = props.rightElement, className = props.className, leftElementClassName = props.leftElementClassName, rightElementClassName = props.rightElementClassName, _f = props.isSingleLine, isSingleLine = _f === void 0 ? false : _f, _g = props.allowSingleLineScroll, allowSingleLineScroll = _g === void 0 ? false : _g, onChange = props.onChange, onFocus = props.onFocus, onBlur = props.onBlur, onElementCreate = props.onElementCreate, onLeftElementClick = props.onLeftElementClick, onRightElementClick = props.onRightElementClick;
|
|
31654
|
+
var inputRef = React.useRef();
|
|
31655
|
+
var inputElementRef = React.useRef();
|
|
31656
|
+
var formatParser = React.useRef();
|
|
31657
|
+
React.useEffect(function () {
|
|
31658
|
+
if (formatParser.current) {
|
|
31659
|
+
formatParser.current.inputValuePassed(value);
|
|
31660
|
+
}
|
|
31661
|
+
}, [value]);
|
|
31662
|
+
React.useEffect(function () {
|
|
31663
|
+
var _a, _b;
|
|
31664
|
+
if (defaultFormat !== FormattedInputDefaultFormats.Custom) {
|
|
31665
|
+
var formatSetting = getPreDefinedFormat(defaultFormat);
|
|
31666
|
+
if (!formatSetting) {
|
|
31667
|
+
throw new Error('The selected format does not exist');
|
|
31668
|
+
}
|
|
31669
|
+
formatParser.current = new FormatParser(formatSetting, value);
|
|
31670
|
+
}
|
|
31671
|
+
else {
|
|
31672
|
+
if (!format$8) {
|
|
31673
|
+
throw new Error('The format property is required when the default format is custom');
|
|
31674
|
+
}
|
|
31675
|
+
formatParser.current = new FormatParser(format$8, value);
|
|
31676
|
+
}
|
|
31677
|
+
if (inputElementRef.current) {
|
|
31678
|
+
(_a = formatParser.current) === null || _a === void 0 ? void 0 : _a.inputElementCreated(inputElementRef.current);
|
|
31679
|
+
}
|
|
31680
|
+
(_b = formatParser.current) === null || _b === void 0 ? void 0 : _b.registerFormatCompleteEvent(onFormatComplete);
|
|
31681
|
+
}, [defaultFormat, format$8]);
|
|
31682
|
+
var onFormatComplete = React.useCallback(function (value) {
|
|
31683
|
+
onChange === null || onChange === void 0 ? void 0 : onChange(value);
|
|
31684
|
+
}, [onChange]);
|
|
31685
|
+
var getPreDefinedFormat = React.useCallback(function (format$8) {
|
|
31686
|
+
switch (format$8) {
|
|
31687
|
+
case FormattedInputDefaultFormats.DateDayMonthYear:
|
|
31688
|
+
return format$7;
|
|
31689
|
+
case FormattedInputDefaultFormats.DateMonthDayYear:
|
|
31690
|
+
return format$6;
|
|
31691
|
+
case FormattedInputDefaultFormats.DateYearMonthDay:
|
|
31692
|
+
return format$5;
|
|
31693
|
+
case FormattedInputDefaultFormats.DateRangeDayMonthYear:
|
|
31694
|
+
return format$4;
|
|
31695
|
+
case FormattedInputDefaultFormats.DateRangeMonthDayYear:
|
|
31696
|
+
return format$3;
|
|
31697
|
+
case FormattedInputDefaultFormats.DateRangeYearMonthDay:
|
|
31698
|
+
return format$2;
|
|
31699
|
+
case FormattedInputDefaultFormats.Time12Hour:
|
|
31700
|
+
return format$1;
|
|
31701
|
+
case FormattedInputDefaultFormats.Time24Hour:
|
|
31702
|
+
return format;
|
|
31703
|
+
}
|
|
31704
|
+
}, []);
|
|
31705
|
+
var onFocusHandler = React.useCallback(function (event) {
|
|
31706
|
+
var _a;
|
|
31707
|
+
(_a = formatParser.current) === null || _a === void 0 ? void 0 : _a.inputFocused();
|
|
31708
|
+
onFocus === null || onFocus === void 0 ? void 0 : onFocus(event);
|
|
31709
|
+
}, [onFocus]);
|
|
31710
|
+
var onMouseUp = React.useCallback(function (event) {
|
|
31711
|
+
}, []);
|
|
31712
|
+
var onKeyDownHandler = React.useCallback(function (event) {
|
|
31713
|
+
var _a;
|
|
31714
|
+
(_a = formatParser.current) === null || _a === void 0 ? void 0 : _a.keyDownHandler(event);
|
|
31715
|
+
}, []);
|
|
31716
|
+
var onInputRefCreated = React.useCallback(function (ref) {
|
|
31717
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j;
|
|
31718
|
+
(_b = (_a = inputRef.current) === null || _a === void 0 ? void 0 : _a.inputElement) === null || _b === void 0 ? void 0 : _b.removeEventListener('keydown', onKeyDownHandler);
|
|
31719
|
+
(_d = (_c = inputRef.current) === null || _c === void 0 ? void 0 : _c.inputElement) === null || _d === void 0 ? void 0 : _d.removeEventListener('mouseup', onMouseUp);
|
|
31720
|
+
inputRef.current = ref;
|
|
31721
|
+
(_f = (_e = inputRef.current) === null || _e === void 0 ? void 0 : _e.inputElement) === null || _f === void 0 ? void 0 : _f.addEventListener('keydown', onKeyDownHandler);
|
|
31722
|
+
(_h = (_g = inputRef.current) === null || _g === void 0 ? void 0 : _g.inputElement) === null || _h === void 0 ? void 0 : _h.addEventListener('mouseup', onMouseUp);
|
|
31723
|
+
inputElementRef.current = (_j = inputRef.current) === null || _j === void 0 ? void 0 : _j.inputElement;
|
|
31724
|
+
}, []);
|
|
31725
|
+
var focus = React.useCallback(function () {
|
|
31726
|
+
var _a;
|
|
31727
|
+
(_a = inputRef.current) === null || _a === void 0 ? void 0 : _a.focus();
|
|
31728
|
+
}, []);
|
|
31729
|
+
React.useImperativeHandle(ref, function () { return ({
|
|
31730
|
+
focus: focus,
|
|
31731
|
+
}); });
|
|
31732
|
+
return (jsxRuntime.jsx(ContentEditableInput$1, { ref: function (refElement) { return refElement && onInputRefCreated(refElement); }, readOnly: readOnly, debounceTime: debounceTime, fillContainer: fillContainer, leftElement: leftElement, rightElement: rightElement, className: className, leftElementClassName: leftElementClassName, rightElementClassName: rightElementClassName, isSingleLine: isSingleLine, allowSingleLineScroll: allowSingleLineScroll, onFocus: onFocusHandler, onBlur: onBlur, onElementCreate: onElementCreate, onLeftElementClick: onLeftElementClick, onRightElementClick: onRightElementClick }));
|
|
31733
|
+
};
|
|
31734
|
+
var FormattedInput$1 = React.memo(React.forwardRef(FormattedInput));
|
|
30418
31735
|
|
|
30419
31736
|
var DateTimeContext = React.createContext(undefined);
|
|
30420
31737
|
|
|
@@ -30566,6 +31883,18 @@ function loadLocale(localeToLoad) {
|
|
|
30566
31883
|
.catch(function (error) { return reject(error); });
|
|
30567
31884
|
});
|
|
30568
31885
|
}
|
|
31886
|
+
function getDateFormatByLocale(locale) {
|
|
31887
|
+
var year = 2023;
|
|
31888
|
+
var month = 12;
|
|
31889
|
+
var day = 20;
|
|
31890
|
+
var date = new Date(year, month - 1, day);
|
|
31891
|
+
var formattedDate = date.toLocaleDateString(locale, {
|
|
31892
|
+
year: 'numeric',
|
|
31893
|
+
month: 'numeric',
|
|
31894
|
+
day: 'numeric',
|
|
31895
|
+
});
|
|
31896
|
+
return formattedDate.replace("".concat(year), 'YYYY').replace("".concat(month), 'MM').replace("".concat(day), 'DD');
|
|
31897
|
+
}
|
|
30569
31898
|
function createDefaultColors() {
|
|
30570
31899
|
return {
|
|
30571
31900
|
inputBgColor: 'bsc-bg-white',
|
|
@@ -30650,8 +31979,9 @@ var DateTimeActionType;
|
|
|
30650
31979
|
DateTimeActionType[DateTimeActionType["SetSelectedDateRange"] = 7] = "SetSelectedDateRange";
|
|
30651
31980
|
DateTimeActionType[DateTimeActionType["SetSelectedStartDate"] = 8] = "SetSelectedStartDate";
|
|
30652
31981
|
DateTimeActionType[DateTimeActionType["SetSelectedEndDate"] = 9] = "SetSelectedEndDate";
|
|
30653
|
-
DateTimeActionType[DateTimeActionType["
|
|
30654
|
-
DateTimeActionType[DateTimeActionType["
|
|
31982
|
+
DateTimeActionType[DateTimeActionType["SetInputFormat"] = 10] = "SetInputFormat";
|
|
31983
|
+
DateTimeActionType[DateTimeActionType["ClearDates"] = 11] = "ClearDates";
|
|
31984
|
+
DateTimeActionType[DateTimeActionType["InitializeDates"] = 12] = "InitializeDates";
|
|
30655
31985
|
})(DateTimeActionType || (DateTimeActionType = {}));
|
|
30656
31986
|
var reducer = function (state, action) {
|
|
30657
31987
|
switch (action.type) {
|
|
@@ -30675,6 +32005,8 @@ var reducer = function (state, action) {
|
|
|
30675
32005
|
return __assign(__assign({}, state), { selectedStartDate: action.selectedStartDate, selectedEndDate: undefined });
|
|
30676
32006
|
case DateTimeActionType.SetSelectedEndDate:
|
|
30677
32007
|
return __assign(__assign({}, state), { selectedEndDate: action.selectedEndDate });
|
|
32008
|
+
case DateTimeActionType.SetInputFormat:
|
|
32009
|
+
return __assign(__assign({}, state), { inputFormat: action.inputFormat });
|
|
30678
32010
|
case DateTimeActionType.ClearDates:
|
|
30679
32011
|
return {
|
|
30680
32012
|
currentSelector: state.currentSelector,
|
|
@@ -31092,12 +32424,15 @@ function DateTimeYearSelector(_a) {
|
|
|
31092
32424
|
|
|
31093
32425
|
function DateTime(_a) {
|
|
31094
32426
|
var _b;
|
|
31095
|
-
var value = _a.value, _c = _a.readOnly, readOnly = _c === void 0 ? false : _c, label = _a.label, _d = _a.useDefaultDateValue, useDefaultDateValue = _d === void 0 ? false : _d, _e = _a.
|
|
31096
|
-
var
|
|
31097
|
-
var
|
|
32427
|
+
var value = _a.value, _c = _a.readOnly, readOnly = _c === void 0 ? false : _c, label = _a.label, _d = _a.useDefaultDateValue, useDefaultDateValue = _d === void 0 ? false : _d, _e = _a.useFormattedInput, useFormattedInput = _e === void 0 ? false : _e, _f = _a.allowClear, allowClear = _f === void 0 ? false : _f, locale = _a.locale, className = _a.className, _g = _a.dateSelection, dateSelection = _g === void 0 ? DateSelectionType.DateTime : _g, dateFormat = _a.dateFormat, timeConstraints = _a.timeConstraints, icon = _a.icon, _h = _a.iconPosition, iconPosition = _h === void 0 ? CalendarIconPosition.Right : _h, inputElement = _a.inputElement, _j = _a.colors, colors = _j === void 0 ? createDefaultColors() : _j, selectableDate = _a.selectableDate, isValidDate = _a.isValidDate, onChange = _a.onChange, calendarTemplate = _a.calendarTemplate, dateScrollerTemplate = _a.dateScrollerTemplate, inputTemplate = _a.inputTemplate;
|
|
32428
|
+
var _k = React.useState(false), selectorOpen = _k[0], setSelectorOpen = _k[1];
|
|
32429
|
+
var _l = React.useState(), dropDownTarget = _l[0], setDropDownTarget = _l[1];
|
|
32430
|
+
var isFormattedInput = React.useRef();
|
|
32431
|
+
var inputElementChanged = React.useRef(false);
|
|
31098
32432
|
var language = React.useRef(locale || getBrowserLanguage());
|
|
31099
32433
|
var loadedLocale = React.useRef();
|
|
31100
32434
|
var inputElementRef = React.useRef();
|
|
32435
|
+
var dropDownTargetRef = React.useRef();
|
|
31101
32436
|
var contextProps = React.useRef({
|
|
31102
32437
|
calendarTemplate: calendarTemplate,
|
|
31103
32438
|
dateScrollerTemplate: dateScrollerTemplate,
|
|
@@ -31122,6 +32457,57 @@ function DateTime(_a) {
|
|
|
31122
32457
|
});
|
|
31123
32458
|
}
|
|
31124
32459
|
}, [value, loadedLocale.current]);
|
|
32460
|
+
React.useEffect(function () {
|
|
32461
|
+
if (dateSelection && loadedLocale.current && loadedLocale.current.code) {
|
|
32462
|
+
var dateFormatString = getDateFormatByLocale(loadedLocale.current.code);
|
|
32463
|
+
if (dateSelection === DateSelectionType.DateOnly) {
|
|
32464
|
+
if (dateFormatString === 'DD/MM/YYYY') {
|
|
32465
|
+
dispatcher({
|
|
32466
|
+
type: DateTimeActionType.SetInputFormat,
|
|
32467
|
+
inputFormat: FormattedInputDefaultFormats.DateDayMonthYear,
|
|
32468
|
+
});
|
|
32469
|
+
}
|
|
32470
|
+
else if (dateFormatString === 'MM/DD/YYYY') {
|
|
32471
|
+
dispatcher({
|
|
32472
|
+
type: DateTimeActionType.SetInputFormat,
|
|
32473
|
+
inputFormat: FormattedInputDefaultFormats.DateMonthDayYear,
|
|
32474
|
+
});
|
|
32475
|
+
}
|
|
32476
|
+
else if (dateFormatString === 'YYYY/MM/DD') {
|
|
32477
|
+
dispatcher({
|
|
32478
|
+
type: DateTimeActionType.SetInputFormat,
|
|
32479
|
+
inputFormat: FormattedInputDefaultFormats.DateYearMonthDay,
|
|
32480
|
+
});
|
|
32481
|
+
}
|
|
32482
|
+
}
|
|
32483
|
+
else if (dateSelection === DateSelectionType.TimeOnly) {
|
|
32484
|
+
dispatcher({
|
|
32485
|
+
type: DateTimeActionType.SetInputFormat,
|
|
32486
|
+
inputFormat: FormattedInputDefaultFormats.Time12Hour,
|
|
32487
|
+
});
|
|
32488
|
+
}
|
|
32489
|
+
else if (dateSelection === DateSelectionType.DateRange) {
|
|
32490
|
+
if (dateFormatString === 'DD/MM/YYYY') {
|
|
32491
|
+
dispatcher({
|
|
32492
|
+
type: DateTimeActionType.SetInputFormat,
|
|
32493
|
+
inputFormat: FormattedInputDefaultFormats.DateRangeDayMonthYear,
|
|
32494
|
+
});
|
|
32495
|
+
}
|
|
32496
|
+
else if (dateFormatString === 'MM/DD/YYYY') {
|
|
32497
|
+
dispatcher({
|
|
32498
|
+
type: DateTimeActionType.SetInputFormat,
|
|
32499
|
+
inputFormat: FormattedInputDefaultFormats.DateRangeMonthDayYear,
|
|
32500
|
+
});
|
|
32501
|
+
}
|
|
32502
|
+
else if (dateFormatString === 'YYYY/MM/DD') {
|
|
32503
|
+
dispatcher({
|
|
32504
|
+
type: DateTimeActionType.SetInputFormat,
|
|
32505
|
+
inputFormat: FormattedInputDefaultFormats.DateRangeYearMonthDay,
|
|
32506
|
+
});
|
|
32507
|
+
}
|
|
32508
|
+
}
|
|
32509
|
+
}
|
|
32510
|
+
}, [dateSelection, loadedLocale.current]);
|
|
31125
32511
|
React.useEffect(function () {
|
|
31126
32512
|
if (inputElement) {
|
|
31127
32513
|
inputElementRef.current = inputElement;
|
|
@@ -31167,13 +32553,21 @@ function DateTime(_a) {
|
|
|
31167
32553
|
currentViewDate: new Date(),
|
|
31168
32554
|
dateInitialized: false,
|
|
31169
32555
|
};
|
|
31170
|
-
var
|
|
31171
|
-
var onFocus = function (
|
|
32556
|
+
var _m = React.useReducer(reducer, initialState), state = _m[0], dispatcher = _m[1];
|
|
32557
|
+
var onFocus = function () {
|
|
31172
32558
|
setDropDownElement();
|
|
31173
32559
|
setSelectorOpen(true);
|
|
31174
32560
|
};
|
|
31175
32561
|
var onInput = function (event) {
|
|
31176
32562
|
var dateString = event.target.innerText;
|
|
32563
|
+
onDateStringChange(dateString);
|
|
32564
|
+
};
|
|
32565
|
+
var onFormatStringChange = function (formattedText) {
|
|
32566
|
+
if (formattedText) {
|
|
32567
|
+
onDateStringChange(formattedText);
|
|
32568
|
+
}
|
|
32569
|
+
};
|
|
32570
|
+
var onDateStringChange = function (dateString) {
|
|
31177
32571
|
var inputDate = dateSelection !== DateSelectionType.DateRange
|
|
31178
32572
|
? parseDate(dateString, loadedLocale.current)
|
|
31179
32573
|
: parseDateRange(dateString, loadedLocale.current);
|
|
@@ -31206,7 +32600,7 @@ function DateTime(_a) {
|
|
|
31206
32600
|
onChange === null || onChange === void 0 ? void 0 : onChange();
|
|
31207
32601
|
}
|
|
31208
32602
|
};
|
|
31209
|
-
var onCalendarClick = function (
|
|
32603
|
+
var onCalendarClick = function () {
|
|
31210
32604
|
setDropDownElement();
|
|
31211
32605
|
setSelectorOpen(!selectorOpen);
|
|
31212
32606
|
};
|
|
@@ -31217,14 +32611,18 @@ function DateTime(_a) {
|
|
|
31217
32611
|
setSelectorOpen(false);
|
|
31218
32612
|
onChange === null || onChange === void 0 ? void 0 : onChange();
|
|
31219
32613
|
};
|
|
31220
|
-
var onInputElementCreated = function (element) {
|
|
31221
|
-
if (!inputElementRef.current) {
|
|
32614
|
+
var onInputElementCreated = function (element, formattedInput) {
|
|
32615
|
+
if (!inputElementRef.current || isFormattedInput.current !== formattedInput) {
|
|
31222
32616
|
inputElementRef.current = element;
|
|
32617
|
+
isFormattedInput.current = formattedInput;
|
|
32618
|
+
inputElementChanged.current = true;
|
|
31223
32619
|
}
|
|
31224
32620
|
};
|
|
31225
|
-
var setDropDownElement = function (
|
|
31226
|
-
if (!
|
|
32621
|
+
var setDropDownElement = function () {
|
|
32622
|
+
if ((!dropDownTargetRef.current || inputElementChanged.current) && inputElementRef.current) {
|
|
32623
|
+
dropDownTargetRef.current = inputElementRef.current;
|
|
31227
32624
|
setDropDownTarget(inputElementRef.current);
|
|
32625
|
+
inputElementChanged.current = false;
|
|
31228
32626
|
}
|
|
31229
32627
|
};
|
|
31230
32628
|
var onDateTimeHidden = function () {
|
|
@@ -31326,7 +32724,7 @@ function DateTime(_a) {
|
|
|
31326
32724
|
_b["".concat((colors === null || colors === void 0 ? void 0 : colors.readOnlyInputBgColor) || 'bsc-bg-gray-200')] = readOnly,
|
|
31327
32725
|
_b["".concat((colors === null || colors === void 0 ? void 0 : colors.inputBgColor) || 'bsc-bg-white')] = !readOnly,
|
|
31328
32726
|
_b), "dark:bsc-bg-black ".concat(colors === null || colors === void 0 ? void 0 : colors.inputBorderColor, " bc-dt-input"), className);
|
|
31329
|
-
return (jsxRuntime.jsx(DateTimeContext.Provider, __assign({ value: contextProps.current }, { children: jsxRuntime.jsxs("div", __assign({ className: "bc-date-time" }, { children: [
|
|
32727
|
+
return (jsxRuntime.jsx(DateTimeContext.Provider, __assign({ value: contextProps.current }, { children: jsxRuntime.jsxs("div", __assign({ className: "bc-date-time" }, { children: [label && jsxRuntime.jsx("label", __assign({ className: "dark:bsc-text-white bc-dt-label" }, { children: label })), useFormattedInput === false || state.inputFormat === undefined ? (jsxRuntime.jsx(TemplateOutlet, __assign({ props: inputTemplateProps, template: template }, { children: jsxRuntime.jsx(ContentEditableInput$1, __assign({ value: getValue(), readOnly: readOnly, className: inputStyles, onFocus: onFocus, onInput: onInput, onElementCreate: function (element) { return onInputElementCreated(element, false); } }, inputProps)) }))) : (jsxRuntime.jsx(FormattedInput$1, __assign({ value: getValue(), readOnly: readOnly, className: inputStyles, onFocus: onFocus, onChange: onFormatStringChange, onElementCreate: function (element) { return onInputElementCreated(element, true); }, defaultFormat: state.inputFormat }, inputProps))), jsxRuntime.jsx(OverlayPanel, __assign({ visible: selectorOpen, target: dropDownTarget, shouldTargetCloseOverlay: false, shouldScrollCloseOverlay: true, shouldCheckZIndex: true, shouldRemainOnScreen: true, hidden: onDateTimeHidden, unmountWhenHidden: true }, { children: jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [state.currentSelector === DateTimeActionType.DaySelector &&
|
|
31330
32728
|
canShowDateSelectors &&
|
|
31331
32729
|
state.dateInitialized &&
|
|
31332
32730
|
loadedLocale.current && (jsxRuntime.jsx(DateTimeDaySelector, { selectedDate: state.selectedDate, viewDate: state.currentViewDate, locale: loadedLocale.current, showTimeSelector: dateSelection === DateSelectionType.DateTime, selectableDate: selectableDate, isValidDate: isValidDate, dispatcher: dispatcher, onChange: onChange })), state.currentSelector === DateTimeActionType.MonthSelector &&
|