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