beesoft-components 0.3.0-1 → 0.3.0-2

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 (31) hide show
  1. package/build/index.cjs.js +426 -725
  2. package/build/index.js +426 -725
  3. package/build/index.min.js +6 -6
  4. package/build/index.min.js.gz +0 -0
  5. package/build/types/src/components/form/date-time/date-time-format-creator.d.ts +28 -0
  6. package/build/types/src/components/form/date-time/date-time-functions.d.ts +0 -2
  7. package/build/types/src/components/form/date-time/date-time.reducer.d.ts +1 -4
  8. package/build/types/src/components/form/date-time/hooks/get-date-time-format.hook.d.ts +4 -0
  9. package/build/types/src/components/form/input/formatted-input/formatted-input.component.d.ts +1 -3
  10. package/build/types/src/components/form/input/formatted-input/parser/format-instance-collection.d.ts +1 -1
  11. package/build/types/src/components/form/input/formatted-input/parser/format-navigator.d.ts +1 -1
  12. package/build/types/src/components/form/input/formatted-input/parser/format-parser.d.ts +1 -1
  13. package/build/types/src/components/form/input/formatted-input/parser/format-renderer.d.ts +1 -1
  14. package/build/types/src/components/form/input/formatted-input/parser/input-rule-processor.d.ts +1 -1
  15. package/build/types/src/components/form/input/formatted-input/parser/input-slot-collection.d.ts +1 -1
  16. package/build/types/src/components/form/input/formatted-input/parser/key-processor.d.ts +1 -1
  17. package/build/types/src/components/form/input/formatted-input/parser/parser.interfaces.d.ts +1 -1
  18. package/build/types/src/components/form/input/formatted-input/parser/part-entry-creator.d.ts +1 -1
  19. package/build/types/src/components/form/input/formatted-input/parser/part-entry-iterator.d.ts +1 -1
  20. package/package.json +1 -1
  21. package/build/types/src/components/form/input/formatted-input/formats/date/day-month-year/format.d.ts +0 -3
  22. package/build/types/src/components/form/input/formatted-input/formats/date/month-day-year/format.d.ts +0 -3
  23. package/build/types/src/components/form/input/formatted-input/formats/date/year-month-day/format.d.ts +0 -3
  24. package/build/types/src/components/form/input/formatted-input/formats/date-range/day-month-year/format.d.ts +0 -3
  25. package/build/types/src/components/form/input/formatted-input/formats/date-range/month-day-year/format.d.ts +0 -3
  26. package/build/types/src/components/form/input/formatted-input/formats/date-range/year-month-day/format.d.ts +0 -3
  27. package/build/types/src/components/form/input/formatted-input/formats/index.d.ts +0 -9
  28. package/build/types/src/components/form/input/formatted-input/formats/input-format.enums.d.ts +0 -11
  29. package/build/types/src/components/form/input/formatted-input/formats/time/12-hour/format.d.ts +0 -3
  30. package/build/types/src/components/form/input/formatted-input/formats/time/24-hour/format.d.ts +0 -3
  31. /package/build/types/src/components/form/input/formatted-input/{formats/input-format.interfaces.d.ts → input-format.interfaces.d.ts} +0 -0
@@ -66,6 +66,16 @@ function __generator(thisArg, body) {
66
66
  } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
67
67
  if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
68
68
  }
69
+ }
70
+
71
+ function __spreadArray(to, from, pack) {
72
+ if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
73
+ if (ar || !(i in from)) {
74
+ if (!ar) ar = Array.prototype.slice.call(from, 0, i);
75
+ ar[i] = from[i];
76
+ }
77
+ }
78
+ return to.concat(ar || Array.prototype.slice.call(from));
69
79
  }
70
80
 
71
81
  var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};
@@ -30433,19 +30443,6 @@ function OverlayPanel(_a) {
30433
30443
  } })));
30434
30444
  }
30435
30445
 
30436
- var FormattedInputDefaultFormats;
30437
- (function (FormattedInputDefaultFormats) {
30438
- FormattedInputDefaultFormats[FormattedInputDefaultFormats["DateDayMonthYear"] = 0] = "DateDayMonthYear";
30439
- FormattedInputDefaultFormats[FormattedInputDefaultFormats["DateMonthDayYear"] = 1] = "DateMonthDayYear";
30440
- FormattedInputDefaultFormats[FormattedInputDefaultFormats["DateYearMonthDay"] = 2] = "DateYearMonthDay";
30441
- FormattedInputDefaultFormats[FormattedInputDefaultFormats["DateRangeDayMonthYear"] = 3] = "DateRangeDayMonthYear";
30442
- FormattedInputDefaultFormats[FormattedInputDefaultFormats["DateRangeMonthDayYear"] = 4] = "DateRangeMonthDayYear";
30443
- FormattedInputDefaultFormats[FormattedInputDefaultFormats["DateRangeYearMonthDay"] = 5] = "DateRangeYearMonthDay";
30444
- FormattedInputDefaultFormats[FormattedInputDefaultFormats["Time12Hour"] = 6] = "Time12Hour";
30445
- FormattedInputDefaultFormats[FormattedInputDefaultFormats["Time24Hour"] = 7] = "Time24Hour";
30446
- FormattedInputDefaultFormats[FormattedInputDefaultFormats["Custom"] = 8] = "Custom";
30447
- })(FormattedInputDefaultFormats || (FormattedInputDefaultFormats = {}));
30448
-
30449
30446
  // Unique ID creation requires a high quality random # generator. In the browser we therefore
30450
30447
  // require the crypto API and do not support built-in fallback to lower quality random number
30451
30448
  // generators (like Math.random()).
@@ -30754,7 +30751,7 @@ var InputSlotCollection = (function () {
30754
30751
  finalSlotIndex = i;
30755
30752
  }
30756
30753
  }
30757
- return this.inputSlots[finalSlotIndex];
30754
+ return this.inputSlots[finalSlotIndex > -1 ? finalSlotIndex : 0];
30758
30755
  };
30759
30756
  InputSlotCollection.prototype.allSlotsCompleted = function () {
30760
30757
  return this.inputSlots.every(function (slot) { return slot.isComplete; });
@@ -31060,7 +31057,12 @@ var InputRuleProcessor = (function () {
31060
31057
  this.addToInputSlot(key);
31061
31058
  inputSlot.isComplete = true;
31062
31059
  this.formatRenderer.render();
31063
- this.formatNavigator.moveToNextInputPart();
31060
+ if (!this.formatNavigator.isAtLastPart()) {
31061
+ this.formatNavigator.moveToNextInputPart();
31062
+ }
31063
+ else {
31064
+ this.formatNavigator.moveCursorRight();
31065
+ }
31064
31066
  }
31065
31067
  else {
31066
31068
  this.addToInputSlot(key);
@@ -31203,7 +31205,7 @@ var FormatParser = (function () {
31203
31205
  var _this = this;
31204
31206
  this.isInputFocused = true;
31205
31207
  this.formatRenderer.render();
31206
- setTimeout(function () { return _this.formatNavigator.setCursorToCurrentPosition(); });
31208
+ setTimeout(function () { return _this.formatNavigator.findCursorPosition(); });
31207
31209
  };
31208
31210
  FormatParser.prototype.inputBlurred = function () {
31209
31211
  this.isInputFocused = false;
@@ -31257,630 +31259,74 @@ var FormatParser = (function () {
31257
31259
  return FormatParser;
31258
31260
  }());
31259
31261
 
31260
- var format$7 = {
31261
- formatParts: [
31262
- {
31263
- characterCount: 2,
31264
- placeholder: 'D',
31265
- inputText: '_',
31266
- isSeparator: false,
31267
- allCharactersRequired: false,
31268
- valueType: FormatValueType.Numeric,
31269
- minimumValue: 1,
31270
- maximumValue: 31,
31271
- exceedingMaximumValueCausesTab: true,
31272
- padWithZeros: true,
31273
- },
31274
- {
31275
- characterCount: 1,
31276
- placeholder: '/',
31277
- inputText: '/',
31278
- isSeparator: true,
31279
- },
31280
- {
31281
- characterCount: 2,
31282
- placeholder: 'M',
31283
- inputText: '_',
31284
- isSeparator: false,
31285
- allCharactersRequired: false,
31286
- valueType: FormatValueType.Numeric,
31287
- minimumValue: 1,
31288
- maximumValue: 12,
31289
- exceedingMaximumValueCausesTab: true,
31290
- padWithZeros: true,
31291
- },
31292
- {
31293
- characterCount: 1,
31294
- placeholder: '/',
31295
- inputText: '/',
31296
- isSeparator: true,
31297
- },
31298
- {
31299
- characterCount: 4,
31300
- placeholder: 'Y',
31301
- inputText: '_',
31302
- isSeparator: false,
31303
- allCharactersRequired: true,
31304
- valueType: FormatValueType.Numeric,
31305
- },
31306
- ],
31307
- };
31308
-
31309
- var format$6 = {
31310
- formatParts: [
31311
- {
31312
- characterCount: 2,
31313
- placeholder: 'M',
31314
- inputText: '_',
31315
- isSeparator: false,
31316
- allCharactersRequired: false,
31317
- valueType: FormatValueType.Numeric,
31318
- minimumValue: 1,
31319
- maximumValue: 12,
31320
- exceedingMaximumValueCausesTab: true,
31321
- padWithZeros: true,
31322
- },
31323
- {
31324
- characterCount: 1,
31325
- placeholder: '/',
31326
- inputText: '/',
31327
- isSeparator: true,
31328
- },
31329
- {
31330
- characterCount: 2,
31331
- placeholder: 'D',
31332
- inputText: '_',
31333
- isSeparator: false,
31334
- allCharactersRequired: false,
31335
- valueType: FormatValueType.Numeric,
31336
- minimumValue: 1,
31337
- maximumValue: 31,
31338
- exceedingMaximumValueCausesTab: true,
31339
- padWithZeros: true,
31340
- },
31341
- {
31342
- characterCount: 1,
31343
- placeholder: '/',
31344
- inputText: '/',
31345
- isSeparator: true,
31346
- },
31347
- {
31348
- characterCount: 4,
31349
- placeholder: 'Y',
31350
- inputText: '_',
31351
- isSeparator: false,
31352
- allCharactersRequired: true,
31353
- valueType: FormatValueType.Numeric,
31354
- },
31355
- ],
31356
- };
31357
-
31358
- var format$5 = {
31359
- formatParts: [
31360
- {
31361
- characterCount: 4,
31362
- placeholder: 'Y',
31363
- inputText: '_',
31364
- isSeparator: false,
31365
- allCharactersRequired: true,
31366
- valueType: FormatValueType.Numeric,
31367
- },
31368
- {
31369
- characterCount: 1,
31370
- placeholder: '-',
31371
- inputText: '-',
31372
- isSeparator: true,
31373
- },
31374
- {
31375
- characterCount: 2,
31376
- placeholder: 'M',
31377
- inputText: '_',
31378
- isSeparator: false,
31379
- allCharactersRequired: false,
31380
- valueType: FormatValueType.Numeric,
31381
- minimumValue: 1,
31382
- maximumValue: 12,
31383
- exceedingMaximumValueCausesTab: true,
31384
- padWithZeros: true,
31385
- },
31386
- {
31387
- characterCount: 1,
31388
- placeholder: '-',
31389
- inputText: '-',
31390
- isSeparator: true,
31391
- },
31392
- {
31393
- characterCount: 2,
31394
- placeholder: 'D',
31395
- inputText: '_',
31396
- isSeparator: false,
31397
- allCharactersRequired: false,
31398
- valueType: FormatValueType.Numeric,
31399
- minimumValue: 1,
31400
- maximumValue: 31,
31401
- exceedingMaximumValueCausesError: true,
31402
- padWithZeros: true,
31403
- },
31404
- ],
31262
+ var FormattedInput = function (props, ref) {
31263
+ var _a = props.value, value = _a === void 0 ? '' : _a, format = props.format, _b = props.readOnly, readOnly = _b === void 0 ? false : _b, _c = props.debounceTime, debounceTime = _c === void 0 ? 800 : _c, _d = props.fillContainer, fillContainer = _d === void 0 ? true : _d, leftElement = props.leftElement, rightElement = props.rightElement, className = props.className, leftElementClassName = props.leftElementClassName, rightElementClassName = props.rightElementClassName, _e = props.isSingleLine, isSingleLine = _e === void 0 ? false : _e, _f = props.allowSingleLineScroll, allowSingleLineScroll = _f === void 0 ? false : _f, onChange = props.onChange, onFocus = props.onFocus, onBlur = props.onBlur, onElementCreate = props.onElementCreate, onLeftElementClick = props.onLeftElementClick, onRightElementClick = props.onRightElementClick;
31264
+ var inputRef = React.useRef();
31265
+ var inputElementRef = React.useRef();
31266
+ var formatParser = React.useRef();
31267
+ React.useEffect(function () {
31268
+ return function () {
31269
+ var _a;
31270
+ (_a = formatParser.current) === null || _a === void 0 ? void 0 : _a.dispose();
31271
+ };
31272
+ }, []);
31273
+ React.useEffect(function () {
31274
+ var _a;
31275
+ (_a = formatParser.current) === null || _a === void 0 ? void 0 : _a.inputValuePassed(value);
31276
+ }, [value]);
31277
+ React.useEffect(function () {
31278
+ var _a, _b, _c;
31279
+ (_a = formatParser.current) === null || _a === void 0 ? void 0 : _a.dispose();
31280
+ if (format) {
31281
+ formatParser.current = new FormatParser(format, value);
31282
+ if (inputElementRef.current) {
31283
+ (_b = formatParser.current) === null || _b === void 0 ? void 0 : _b.inputElementCreated(inputElementRef.current);
31284
+ }
31285
+ (_c = formatParser.current) === null || _c === void 0 ? void 0 : _c.registerFormatChangeEvent(onFormatChange);
31286
+ }
31287
+ }, [format]);
31288
+ var onFormatChange = React.useCallback(function (value) {
31289
+ onChange === null || onChange === void 0 ? void 0 : onChange(value);
31290
+ }, [onChange]);
31291
+ var onFocusHandler = React.useCallback(function (event) {
31292
+ var _a;
31293
+ (_a = formatParser.current) === null || _a === void 0 ? void 0 : _a.inputFocused();
31294
+ onFocus === null || onFocus === void 0 ? void 0 : onFocus(event);
31295
+ }, [onFocus]);
31296
+ var onBlurHandler = React.useCallback(function (event) {
31297
+ var _a;
31298
+ (_a = formatParser.current) === null || _a === void 0 ? void 0 : _a.inputBlurred();
31299
+ onBlur === null || onBlur === void 0 ? void 0 : onBlur(event);
31300
+ }, [onBlur]);
31301
+ var onMouseUpHandler = React.useCallback(function () {
31302
+ var _a;
31303
+ (_a = formatParser.current) === null || _a === void 0 ? void 0 : _a.mouseUpHandler();
31304
+ }, []);
31305
+ var onKeyDownHandler = React.useCallback(function (event) {
31306
+ var _a;
31307
+ (_a = formatParser.current) === null || _a === void 0 ? void 0 : _a.keyDownHandler(event);
31308
+ }, []);
31309
+ var onInputRefCreated = React.useCallback(function (ref) {
31310
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j;
31311
+ (_b = (_a = inputRef.current) === null || _a === void 0 ? void 0 : _a.inputElement) === null || _b === void 0 ? void 0 : _b.removeEventListener('keydown', onKeyDownHandler);
31312
+ (_d = (_c = inputRef.current) === null || _c === void 0 ? void 0 : _c.inputElement) === null || _d === void 0 ? void 0 : _d.removeEventListener('mouseup', onMouseUpHandler);
31313
+ inputRef.current = ref;
31314
+ (_f = (_e = inputRef.current) === null || _e === void 0 ? void 0 : _e.inputElement) === null || _f === void 0 ? void 0 : _f.addEventListener('keydown', onKeyDownHandler);
31315
+ (_h = (_g = inputRef.current) === null || _g === void 0 ? void 0 : _g.inputElement) === null || _h === void 0 ? void 0 : _h.addEventListener('mouseup', onMouseUpHandler);
31316
+ inputElementRef.current = (_j = inputRef.current) === null || _j === void 0 ? void 0 : _j.inputElement;
31317
+ }, []);
31318
+ var focus = React.useCallback(function () {
31319
+ var _a;
31320
+ (_a = inputRef.current) === null || _a === void 0 ? void 0 : _a.focus();
31321
+ }, []);
31322
+ React.useImperativeHandle(ref, function () { return ({
31323
+ focus: focus,
31324
+ }); });
31325
+ 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: onBlurHandler, onElementCreate: onElementCreate, onLeftElementClick: onLeftElementClick, onRightElementClick: onRightElementClick }));
31405
31326
  };
31327
+ var FormattedInput$1 = React.memo(React.forwardRef(FormattedInput));
31406
31328
 
31407
- var format$4 = {
31408
- formatParts: [
31409
- {
31410
- characterCount: 2,
31411
- placeholder: 'D',
31412
- inputText: '_',
31413
- isSeparator: false,
31414
- allCharactersRequired: false,
31415
- valueType: FormatValueType.Numeric,
31416
- minimumValue: 1,
31417
- maximumValue: 31,
31418
- exceedingMaximumValueCausesTab: true,
31419
- padWithZeros: true,
31420
- },
31421
- {
31422
- characterCount: 1,
31423
- placeholder: '/',
31424
- inputText: '/',
31425
- isSeparator: true,
31426
- },
31427
- {
31428
- characterCount: 2,
31429
- placeholder: 'M',
31430
- inputText: '_',
31431
- isSeparator: false,
31432
- allCharactersRequired: false,
31433
- valueType: FormatValueType.Numeric,
31434
- minimumValue: 1,
31435
- maximumValue: 12,
31436
- exceedingMaximumValueCausesTab: true,
31437
- padWithZeros: true,
31438
- },
31439
- {
31440
- characterCount: 1,
31441
- placeholder: '/',
31442
- inputText: '/',
31443
- isSeparator: true,
31444
- },
31445
- {
31446
- characterCount: 4,
31447
- placeholder: 'Y',
31448
- inputText: '_',
31449
- isSeparator: false,
31450
- allCharactersRequired: true,
31451
- valueType: FormatValueType.Numeric,
31452
- },
31453
- {
31454
- characterCount: 3,
31455
- placeholder: ' - ',
31456
- inputText: ' - ',
31457
- isSeparator: true,
31458
- },
31459
- {
31460
- characterCount: 2,
31461
- placeholder: 'D',
31462
- inputText: '_',
31463
- isSeparator: false,
31464
- allCharactersRequired: false,
31465
- valueType: FormatValueType.Numeric,
31466
- minimumValue: 1,
31467
- maximumValue: 31,
31468
- exceedingMaximumValueCausesTab: true,
31469
- padWithZeros: true,
31470
- },
31471
- {
31472
- characterCount: 1,
31473
- placeholder: '/',
31474
- inputText: '/',
31475
- isSeparator: true,
31476
- },
31477
- {
31478
- characterCount: 2,
31479
- placeholder: 'M',
31480
- inputText: '_',
31481
- isSeparator: false,
31482
- allCharactersRequired: false,
31483
- valueType: FormatValueType.Numeric,
31484
- minimumValue: 1,
31485
- maximumValue: 12,
31486
- exceedingMaximumValueCausesTab: true,
31487
- padWithZeros: true,
31488
- },
31489
- {
31490
- characterCount: 1,
31491
- placeholder: '/',
31492
- inputText: '/',
31493
- isSeparator: true,
31494
- },
31495
- {
31496
- characterCount: 4,
31497
- placeholder: 'Y',
31498
- inputText: '_',
31499
- isSeparator: false,
31500
- allCharactersRequired: true,
31501
- valueType: FormatValueType.Numeric,
31502
- },
31503
- ],
31504
- };
31505
-
31506
- var format$3 = {
31507
- formatParts: [
31508
- {
31509
- characterCount: 2,
31510
- placeholder: 'M',
31511
- inputText: '_',
31512
- isSeparator: false,
31513
- allCharactersRequired: false,
31514
- valueType: FormatValueType.Numeric,
31515
- minimumValue: 1,
31516
- maximumValue: 12,
31517
- exceedingMaximumValueCausesTab: true,
31518
- padWithZeros: true,
31519
- },
31520
- {
31521
- characterCount: 1,
31522
- placeholder: '/',
31523
- inputText: '/',
31524
- isSeparator: true,
31525
- },
31526
- {
31527
- characterCount: 2,
31528
- placeholder: 'D',
31529
- inputText: '_',
31530
- isSeparator: false,
31531
- allCharactersRequired: false,
31532
- valueType: FormatValueType.Numeric,
31533
- minimumValue: 1,
31534
- maximumValue: 31,
31535
- exceedingMaximumValueCausesTab: true,
31536
- padWithZeros: true,
31537
- },
31538
- {
31539
- characterCount: 1,
31540
- placeholder: '/',
31541
- inputText: '/',
31542
- isSeparator: true,
31543
- },
31544
- {
31545
- characterCount: 4,
31546
- placeholder: 'Y',
31547
- inputText: '_',
31548
- isSeparator: false,
31549
- allCharactersRequired: true,
31550
- valueType: FormatValueType.Numeric,
31551
- },
31552
- {
31553
- characterCount: 3,
31554
- placeholder: ' - ',
31555
- inputText: ' - ',
31556
- isSeparator: true,
31557
- },
31558
- {
31559
- characterCount: 2,
31560
- placeholder: 'M',
31561
- inputText: '_',
31562
- isSeparator: false,
31563
- allCharactersRequired: false,
31564
- valueType: FormatValueType.Numeric,
31565
- minimumValue: 1,
31566
- maximumValue: 12,
31567
- exceedingMaximumValueCausesTab: true,
31568
- padWithZeros: true,
31569
- },
31570
- {
31571
- characterCount: 1,
31572
- placeholder: '/',
31573
- inputText: '/',
31574
- isSeparator: true,
31575
- },
31576
- {
31577
- characterCount: 2,
31578
- placeholder: 'D',
31579
- inputText: '_',
31580
- isSeparator: false,
31581
- allCharactersRequired: false,
31582
- valueType: FormatValueType.Numeric,
31583
- minimumValue: 1,
31584
- maximumValue: 31,
31585
- exceedingMaximumValueCausesTab: true,
31586
- padWithZeros: true,
31587
- },
31588
- {
31589
- characterCount: 1,
31590
- placeholder: '/',
31591
- inputText: '/',
31592
- isSeparator: true,
31593
- },
31594
- {
31595
- characterCount: 4,
31596
- placeholder: 'Y',
31597
- inputText: '_',
31598
- isSeparator: false,
31599
- allCharactersRequired: true,
31600
- valueType: FormatValueType.Numeric,
31601
- },
31602
- ],
31603
- };
31604
-
31605
- var format$2 = {
31606
- formatParts: [
31607
- {
31608
- characterCount: 4,
31609
- placeholder: 'Y',
31610
- inputText: '_',
31611
- isSeparator: false,
31612
- allCharactersRequired: true,
31613
- valueType: FormatValueType.Numeric,
31614
- },
31615
- {
31616
- characterCount: 1,
31617
- placeholder: '-',
31618
- inputText: '-',
31619
- isSeparator: true,
31620
- },
31621
- {
31622
- characterCount: 2,
31623
- placeholder: 'M',
31624
- inputText: '_',
31625
- isSeparator: false,
31626
- allCharactersRequired: false,
31627
- valueType: FormatValueType.Numeric,
31628
- minimumValue: 1,
31629
- maximumValue: 12,
31630
- exceedingMaximumValueCausesTab: true,
31631
- padWithZeros: true,
31632
- },
31633
- {
31634
- characterCount: 1,
31635
- placeholder: '-',
31636
- inputText: '-',
31637
- isSeparator: true,
31638
- },
31639
- {
31640
- characterCount: 2,
31641
- placeholder: 'D',
31642
- inputText: '_',
31643
- isSeparator: false,
31644
- allCharactersRequired: false,
31645
- valueType: FormatValueType.Numeric,
31646
- minimumValue: 1,
31647
- maximumValue: 31,
31648
- exceedingMaximumValueCausesTab: true,
31649
- padWithZeros: true,
31650
- },
31651
- {
31652
- characterCount: 3,
31653
- placeholder: ' - ',
31654
- inputText: ' - ',
31655
- isSeparator: true,
31656
- },
31657
- {
31658
- characterCount: 4,
31659
- placeholder: 'Y',
31660
- inputText: '_',
31661
- isSeparator: false,
31662
- allCharactersRequired: true,
31663
- valueType: FormatValueType.Numeric,
31664
- },
31665
- {
31666
- characterCount: 1,
31667
- placeholder: '-',
31668
- inputText: '-',
31669
- isSeparator: true,
31670
- },
31671
- {
31672
- characterCount: 2,
31673
- placeholder: 'M',
31674
- inputText: '_',
31675
- isSeparator: false,
31676
- allCharactersRequired: false,
31677
- valueType: FormatValueType.Numeric,
31678
- minimumValue: 1,
31679
- maximumValue: 12,
31680
- exceedingMaximumValueCausesTab: true,
31681
- padWithZeros: true,
31682
- },
31683
- {
31684
- characterCount: 1,
31685
- placeholder: '/',
31686
- inputText: '/',
31687
- isSeparator: true,
31688
- },
31689
- {
31690
- characterCount: 2,
31691
- placeholder: 'D',
31692
- inputText: '_',
31693
- isSeparator: false,
31694
- allCharactersRequired: false,
31695
- valueType: FormatValueType.Numeric,
31696
- minimumValue: 1,
31697
- maximumValue: 31,
31698
- exceedingMaximumValueCausesError: true,
31699
- padWithZeros: true,
31700
- },
31701
- ],
31702
- };
31703
-
31704
- var format$1 = {
31705
- formatParts: [
31706
- {
31707
- characterCount: 2,
31708
- placeholder: 'H',
31709
- inputText: '_',
31710
- isSeparator: false,
31711
- allCharactersRequired: false,
31712
- valueType: FormatValueType.Numeric,
31713
- minimumValue: 1,
31714
- maximumValue: 12,
31715
- exceedingMaximumValueCausesTab: true,
31716
- padWithZeros: true,
31717
- },
31718
- {
31719
- characterCount: 1,
31720
- placeholder: ':',
31721
- inputText: ':',
31722
- isSeparator: true,
31723
- },
31724
- {
31725
- characterCount: 2,
31726
- placeholder: 'M',
31727
- inputText: '_',
31728
- isSeparator: false,
31729
- allCharactersRequired: false,
31730
- valueType: FormatValueType.Numeric,
31731
- minimumValue: 0,
31732
- maximumValue: 59,
31733
- exceedingMaximumValueCausesError: true,
31734
- padWithZeros: true,
31735
- },
31736
- {
31737
- characterCount: 1,
31738
- placeholder: ' ',
31739
- inputText: ' ',
31740
- isSeparator: true,
31741
- },
31742
- {
31743
- characterCount: 2,
31744
- inputText: '_',
31745
- isSeparator: false,
31746
- possibleValues: ['AM', 'PM'],
31747
- },
31748
- ],
31749
- };
31750
-
31751
- var format = {
31752
- formatParts: [
31753
- {
31754
- characterCount: 2,
31755
- placeholder: 'H',
31756
- inputText: '_',
31757
- isSeparator: false,
31758
- allCharactersRequired: false,
31759
- valueType: FormatValueType.Numeric,
31760
- minimumValue: 0,
31761
- maximumValue: 23,
31762
- exceedingMaximumValueCausesTab: true,
31763
- padWithZeros: true,
31764
- },
31765
- {
31766
- characterCount: 1,
31767
- placeholder: ':',
31768
- inputText: ':',
31769
- isSeparator: true,
31770
- },
31771
- {
31772
- characterCount: 2,
31773
- placeholder: 'M',
31774
- inputText: '_',
31775
- isSeparator: false,
31776
- allCharactersRequired: false,
31777
- valueType: FormatValueType.Numeric,
31778
- minimumValue: 1,
31779
- maximumValue: 59,
31780
- exceedingMaximumValueCausesError: true,
31781
- padWithZeros: true,
31782
- },
31783
- ],
31784
- };
31785
-
31786
- var FormattedInput = function (props, ref) {
31787
- 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;
31788
- var inputRef = React.useRef();
31789
- var inputElementRef = React.useRef();
31790
- var formatParser = React.useRef();
31791
- React.useEffect(function () {
31792
- return function () {
31793
- var _a;
31794
- (_a = formatParser.current) === null || _a === void 0 ? void 0 : _a.dispose();
31795
- };
31796
- }, []);
31797
- React.useEffect(function () {
31798
- var _a;
31799
- (_a = formatParser.current) === null || _a === void 0 ? void 0 : _a.inputValuePassed(value);
31800
- }, [value]);
31801
- React.useEffect(function () {
31802
- var _a, _b, _c;
31803
- (_a = formatParser.current) === null || _a === void 0 ? void 0 : _a.dispose();
31804
- if (defaultFormat !== FormattedInputDefaultFormats.Custom) {
31805
- var formatSetting = getPreDefinedFormat(defaultFormat);
31806
- if (!formatSetting) {
31807
- throw new Error('The selected format does not exist');
31808
- }
31809
- formatParser.current = new FormatParser(formatSetting, value);
31810
- }
31811
- else {
31812
- if (!format$8) {
31813
- throw new Error('The format property is required when the default format is custom');
31814
- }
31815
- formatParser.current = new FormatParser(format$8, value);
31816
- }
31817
- if (inputElementRef.current) {
31818
- (_b = formatParser.current) === null || _b === void 0 ? void 0 : _b.inputElementCreated(inputElementRef.current);
31819
- }
31820
- (_c = formatParser.current) === null || _c === void 0 ? void 0 : _c.registerFormatChangeEvent(onFormatChange);
31821
- }, [defaultFormat, format$8]);
31822
- var onFormatChange = React.useCallback(function (value) {
31823
- onChange === null || onChange === void 0 ? void 0 : onChange(value);
31824
- }, [onChange]);
31825
- var getPreDefinedFormat = React.useCallback(function (format$8) {
31826
- switch (format$8) {
31827
- case FormattedInputDefaultFormats.DateDayMonthYear:
31828
- return format$7;
31829
- case FormattedInputDefaultFormats.DateMonthDayYear:
31830
- return format$6;
31831
- case FormattedInputDefaultFormats.DateYearMonthDay:
31832
- return format$5;
31833
- case FormattedInputDefaultFormats.DateRangeDayMonthYear:
31834
- return format$4;
31835
- case FormattedInputDefaultFormats.DateRangeMonthDayYear:
31836
- return format$3;
31837
- case FormattedInputDefaultFormats.DateRangeYearMonthDay:
31838
- return format$2;
31839
- case FormattedInputDefaultFormats.Time12Hour:
31840
- return format$1;
31841
- case FormattedInputDefaultFormats.Time24Hour:
31842
- return format;
31843
- }
31844
- }, []);
31845
- var onFocusHandler = React.useCallback(function (event) {
31846
- var _a;
31847
- (_a = formatParser.current) === null || _a === void 0 ? void 0 : _a.inputFocused();
31848
- onFocus === null || onFocus === void 0 ? void 0 : onFocus(event);
31849
- }, [onFocus]);
31850
- var onBlurHandler = React.useCallback(function (event) {
31851
- var _a;
31852
- (_a = formatParser.current) === null || _a === void 0 ? void 0 : _a.inputBlurred();
31853
- onBlur === null || onBlur === void 0 ? void 0 : onBlur(event);
31854
- }, [onBlur]);
31855
- var onMouseUpHandler = React.useCallback(function () {
31856
- var _a;
31857
- (_a = formatParser.current) === null || _a === void 0 ? void 0 : _a.mouseUpHandler();
31858
- }, []);
31859
- var onKeyDownHandler = React.useCallback(function (event) {
31860
- var _a;
31861
- (_a = formatParser.current) === null || _a === void 0 ? void 0 : _a.keyDownHandler(event);
31862
- }, []);
31863
- var onInputRefCreated = React.useCallback(function (ref) {
31864
- var _a, _b, _c, _d, _e, _f, _g, _h, _j;
31865
- (_b = (_a = inputRef.current) === null || _a === void 0 ? void 0 : _a.inputElement) === null || _b === void 0 ? void 0 : _b.removeEventListener('keydown', onKeyDownHandler);
31866
- (_d = (_c = inputRef.current) === null || _c === void 0 ? void 0 : _c.inputElement) === null || _d === void 0 ? void 0 : _d.removeEventListener('mouseup', onMouseUpHandler);
31867
- inputRef.current = ref;
31868
- (_f = (_e = inputRef.current) === null || _e === void 0 ? void 0 : _e.inputElement) === null || _f === void 0 ? void 0 : _f.addEventListener('keydown', onKeyDownHandler);
31869
- (_h = (_g = inputRef.current) === null || _g === void 0 ? void 0 : _g.inputElement) === null || _h === void 0 ? void 0 : _h.addEventListener('mouseup', onMouseUpHandler);
31870
- inputElementRef.current = (_j = inputRef.current) === null || _j === void 0 ? void 0 : _j.inputElement;
31871
- }, []);
31872
- var focus = React.useCallback(function () {
31873
- var _a;
31874
- (_a = inputRef.current) === null || _a === void 0 ? void 0 : _a.focus();
31875
- }, []);
31876
- React.useImperativeHandle(ref, function () { return ({
31877
- focus: focus,
31878
- }); });
31879
- 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: onBlurHandler, onElementCreate: onElementCreate, onLeftElementClick: onLeftElementClick, onRightElementClick: onRightElementClick }));
31880
- };
31881
- var FormattedInput$1 = React.memo(React.forwardRef(FormattedInput));
31882
-
31883
- var DateTimeContext = React.createContext(undefined);
31329
+ var DateTimeContext = React.createContext(undefined);
31884
31330
 
31885
31331
  function getMonthMatrix(matrixDate, locale, loadOtherMonths) {
31886
31332
  var _a, _b;
@@ -32046,25 +31492,6 @@ function loadLocale(localeToLoad) {
32046
31492
  });
32047
31493
  });
32048
31494
  }
32049
- function getDateFormatByLocale(locale) {
32050
- var year = 2023;
32051
- var month = 12;
32052
- var day = 20;
32053
- var date = new Date(year, month - 1, day);
32054
- var formattedDate = date.toLocaleDateString(locale, {
32055
- year: 'numeric',
32056
- month: 'numeric',
32057
- day: 'numeric',
32058
- });
32059
- return formattedDate.replace("".concat(year), 'YYYY').replace("".concat(month), 'MM').replace("".concat(day), 'DD');
32060
- }
32061
- function uses24HourTimeByLocale(locale) {
32062
- var date = new Date();
32063
- var hour = 18;
32064
- date.setHours(hour);
32065
- var timeParts = date.toLocaleTimeString(locale).split(':');
32066
- return timeParts[0] === '18';
32067
- }
32068
31495
  function createDefaultColors() {
32069
31496
  return {
32070
31497
  inputBgColor: 'bsc-bg-white',
@@ -32085,16 +31512,19 @@ function parseDate(dateValue, locale) {
32085
31512
  localDate = parse(dateValue, 'P HH:mm', new Date(), { locale: locale });
32086
31513
  if (!isNaN(localDate.valueOf()))
32087
31514
  return localDate;
32088
- localDate = parse(dateValue, 'P HH:mm aaa', new Date(), { locale: locale });
31515
+ localDate = parse(dateValue, 'P hh:mm a..aaa', new Date(), { locale: locale });
32089
31516
  if (!isNaN(localDate.valueOf()))
32090
31517
  return localDate;
32091
31518
  localDate = parse(dateValue, 'P HH:mm:ss', new Date(), { locale: locale });
32092
31519
  if (!isNaN(localDate.valueOf()))
32093
31520
  return localDate;
32094
- localDate = parse(dateValue, 'P HH:mm:ss aaa', new Date(), { locale: locale });
31521
+ localDate = parse(dateValue, 'P hh:mm:ss a..aaa', new Date(), { locale: locale });
32095
31522
  if (!isNaN(localDate.valueOf()))
32096
31523
  return localDate;
32097
31524
  localDate = parse(dateValue, 'P', new Date(), { locale: locale });
31525
+ if (!isNaN(localDate.valueOf()))
31526
+ return localDate;
31527
+ localDate = parse(dateValue, 'P p', new Date(), { locale: locale });
32098
31528
  if (!isNaN(localDate.valueOf()))
32099
31529
  return localDate;
32100
31530
  localDate = parse(dateValue, 'pp', new Date(), { locale: locale });
@@ -32169,7 +31599,7 @@ var DateTimeActionType;
32169
31599
  DateTimeActionType[DateTimeActionType["SetSelectedDateRange"] = 7] = "SetSelectedDateRange";
32170
31600
  DateTimeActionType[DateTimeActionType["SetSelectedStartDate"] = 8] = "SetSelectedStartDate";
32171
31601
  DateTimeActionType[DateTimeActionType["SetSelectedEndDate"] = 9] = "SetSelectedEndDate";
32172
- DateTimeActionType[DateTimeActionType["SetInputFormat"] = 10] = "SetInputFormat";
31602
+ DateTimeActionType[DateTimeActionType["SetTimeFormat"] = 10] = "SetTimeFormat";
32173
31603
  DateTimeActionType[DateTimeActionType["ClearDates"] = 11] = "ClearDates";
32174
31604
  DateTimeActionType[DateTimeActionType["InitializeDates"] = 12] = "InitializeDates";
32175
31605
  })(DateTimeActionType || (DateTimeActionType = {}));
@@ -32195,16 +31625,13 @@ var reducer = function (state, action) {
32195
31625
  return __assign(__assign({}, state), { selectedStartDate: action.selectedStartDate, selectedEndDate: undefined });
32196
31626
  case DateTimeActionType.SetSelectedEndDate:
32197
31627
  return __assign(__assign({}, state), { selectedEndDate: action.selectedEndDate });
32198
- case DateTimeActionType.SetInputFormat:
32199
- return __assign(__assign({}, state), { timeFormat: action.inputFormat === FormattedInputDefaultFormats.Time24Hour
32200
- ? TimeFormatType.TwentyFourHour
32201
- : action.timeFormat || TimeFormatType.TwelveHour, inputFormat: action.inputFormat });
31628
+ case DateTimeActionType.SetTimeFormat:
31629
+ return __assign(__assign({}, state), { timeFormat: action.timeFormat || state.timeFormat });
32202
31630
  case DateTimeActionType.ClearDates:
32203
31631
  return {
32204
31632
  currentSelector: state.currentSelector,
32205
31633
  currentViewDate: state.currentViewDate,
32206
31634
  timeFormat: state.timeFormat,
32207
- inputFormat: state.inputFormat,
32208
31635
  dateInitialized: true,
32209
31636
  };
32210
31637
  case DateTimeActionType.InitializeDates:
@@ -32668,17 +32095,341 @@ function DateTimeYearSelector(_a) {
32668
32095
  }) })) }))] })));
32669
32096
  }
32670
32097
 
32098
+ var DateTimeFormatCreator = (function () {
32099
+ function DateTimeFormatCreator(dateSelection, localeCode) {
32100
+ this.dateSelection = dateSelection;
32101
+ var year = 2023;
32102
+ var month = 12;
32103
+ var day = 20;
32104
+ var date = new Date(year, month - 1, day);
32105
+ var format = date.toLocaleDateString(localeCode, {
32106
+ year: 'numeric',
32107
+ month: 'numeric',
32108
+ day: 'numeric',
32109
+ });
32110
+ this.dateFormat = format.replace("".concat(year), 'YYYY').replace("".concat(month), 'MM').replace("".concat(day), 'DD');
32111
+ var time = new Date();
32112
+ var hour = 18;
32113
+ var minute = 24;
32114
+ var second = 37;
32115
+ var milliseconds = 317;
32116
+ time.setHours(hour, minute, second, milliseconds);
32117
+ var testTimeFormat = time.toLocaleTimeString(localeCode);
32118
+ this.use24HourTime = testTimeFormat.startsWith('18');
32119
+ this.timeFormat = testTimeFormat
32120
+ .replace("".concat(this.use24HourTime ? hour : '6'), 'HH')
32121
+ .replace("".concat(minute), 'MM')
32122
+ .replace("".concat(second), 'SS')
32123
+ .replace("".concat(milliseconds), 'LLL');
32124
+ this.createDateParts();
32125
+ }
32126
+ Object.defineProperty(DateTimeFormatCreator.prototype, "is24HourTime", {
32127
+ get: function () {
32128
+ return this.use24HourTime;
32129
+ },
32130
+ enumerable: false,
32131
+ configurable: true
32132
+ });
32133
+ DateTimeFormatCreator.prototype.createInputFormat = function () {
32134
+ var inputFormat = {
32135
+ deleteShiftsFormatPart: false,
32136
+ formatParts: [],
32137
+ };
32138
+ switch (this.dateSelection) {
32139
+ case DateSelectionType.DateOnly:
32140
+ return this.createDateFormat(inputFormat);
32141
+ case DateSelectionType.TimeOnly:
32142
+ return this.createTimeFormat(inputFormat);
32143
+ case DateSelectionType.DateRange:
32144
+ return this.createDateRangeFormat(inputFormat);
32145
+ case DateSelectionType.DateTime:
32146
+ return this.createDateTimeFormat(inputFormat);
32147
+ }
32148
+ };
32149
+ DateTimeFormatCreator.prototype.createDateFormat = function (inputFormat) {
32150
+ var _a, _b, _c;
32151
+ if (this.dateFormat.startsWith('MM')) {
32152
+ (_a = inputFormat.formatParts).push.apply(_a, this.createMonthDayYearFormatParts());
32153
+ }
32154
+ else if (this.dateFormat.startsWith('DD')) {
32155
+ (_b = inputFormat.formatParts).push.apply(_b, this.createDayMonthYearFormatParts());
32156
+ }
32157
+ else {
32158
+ (_c = inputFormat.formatParts).push.apply(_c, this.createYearMonthDayFormatParts());
32159
+ }
32160
+ return inputFormat;
32161
+ };
32162
+ DateTimeFormatCreator.prototype.createTimeFormat = function (inputFormat) {
32163
+ var _a, _b;
32164
+ if (!this.use24HourTime) {
32165
+ (_a = inputFormat.formatParts).push.apply(_a, this.createTwelveHourFormatParts());
32166
+ }
32167
+ else {
32168
+ (_b = inputFormat.formatParts).push.apply(_b, this.createTwentyFourHourFormatParts());
32169
+ }
32170
+ return inputFormat;
32171
+ };
32172
+ DateTimeFormatCreator.prototype.createDateRangeFormat = function (inputFormat) {
32173
+ var _a;
32174
+ var formatParts = [];
32175
+ if (this.dateFormat.startsWith('MM')) {
32176
+ formatParts.push.apply(formatParts, this.createMonthDayYearFormatParts());
32177
+ }
32178
+ else if (this.dateFormat.startsWith('DD')) {
32179
+ formatParts.push.apply(formatParts, this.createDayMonthYearFormatParts());
32180
+ }
32181
+ else {
32182
+ formatParts.push.apply(formatParts, this.createYearMonthDayFormatParts());
32183
+ }
32184
+ var dividerPart = {
32185
+ characterCount: 3,
32186
+ placeholder: ' - ',
32187
+ inputText: ' - ',
32188
+ isSeparator: true,
32189
+ };
32190
+ (_a = inputFormat.formatParts).push.apply(_a, __spreadArray(__spreadArray(__spreadArray([], formatParts, false), [dividerPart], false), formatParts, false));
32191
+ return inputFormat;
32192
+ };
32193
+ DateTimeFormatCreator.prototype.createDateTimeFormat = function (inputFormat) {
32194
+ var _a, _b, _c, _d, _e;
32195
+ if (this.dateFormat.startsWith('MM')) {
32196
+ (_a = inputFormat.formatParts).push.apply(_a, this.createMonthDayYearFormatParts());
32197
+ }
32198
+ else if (this.dateFormat.startsWith('DD')) {
32199
+ (_b = inputFormat.formatParts).push.apply(_b, this.createDayMonthYearFormatParts());
32200
+ }
32201
+ else {
32202
+ (_c = inputFormat.formatParts).push.apply(_c, this.createYearMonthDayFormatParts());
32203
+ }
32204
+ var dividerPart = {
32205
+ characterCount: 1,
32206
+ placeholder: ' ',
32207
+ inputText: ' ',
32208
+ isSeparator: true,
32209
+ };
32210
+ inputFormat.formatParts.push(dividerPart);
32211
+ if (!this.use24HourTime) {
32212
+ (_d = inputFormat.formatParts).push.apply(_d, this.createTwelveHourFormatParts());
32213
+ }
32214
+ else {
32215
+ (_e = inputFormat.formatParts).push.apply(_e, this.createTwentyFourHourFormatParts());
32216
+ }
32217
+ return inputFormat;
32218
+ };
32219
+ DateTimeFormatCreator.prototype.createMonthDayYearFormatParts = function () {
32220
+ if (this.monthPart && this.dayPart && this.yearPart) {
32221
+ var tempDateFormat = this.dateFormat.replace('MM', '');
32222
+ var placeholderIndex = tempDateFormat.indexOf('DD');
32223
+ var placeholderText = tempDateFormat.substring(0, placeholderIndex);
32224
+ tempDateFormat = tempDateFormat.replace(placeholderText, '').replace('DD', '');
32225
+ var placeholder1 = {
32226
+ characterCount: placeholderText.length,
32227
+ placeholder: placeholderText,
32228
+ inputText: placeholderText,
32229
+ isSeparator: true,
32230
+ };
32231
+ placeholderIndex = tempDateFormat.indexOf('YYYY');
32232
+ placeholderText = tempDateFormat.substring(0, placeholderIndex);
32233
+ var placeholder2 = {
32234
+ characterCount: placeholderText.length,
32235
+ placeholder: placeholderText,
32236
+ inputText: placeholderText,
32237
+ isSeparator: true,
32238
+ };
32239
+ return [this.monthPart, placeholder1, this.dayPart, placeholder2, this.yearPart];
32240
+ }
32241
+ return [];
32242
+ };
32243
+ DateTimeFormatCreator.prototype.createDayMonthYearFormatParts = function () {
32244
+ if (this.monthPart && this.dayPart && this.yearPart) {
32245
+ var tempDateFormat = this.dateFormat.replace('DD', '');
32246
+ var placeholderIndex = tempDateFormat.indexOf('MM');
32247
+ var placeholderText = tempDateFormat.substring(0, placeholderIndex);
32248
+ tempDateFormat = tempDateFormat.replace(placeholderText, '').replace('MM', '');
32249
+ var placeholder1 = {
32250
+ characterCount: placeholderText.length,
32251
+ placeholder: placeholderText,
32252
+ inputText: placeholderText,
32253
+ isSeparator: true,
32254
+ };
32255
+ placeholderIndex = tempDateFormat.indexOf('YYYY');
32256
+ placeholderText = tempDateFormat.substring(0, placeholderIndex);
32257
+ var placeholder2 = {
32258
+ characterCount: placeholderText.length,
32259
+ placeholder: placeholderText,
32260
+ inputText: placeholderText,
32261
+ isSeparator: true,
32262
+ };
32263
+ return [this.dayPart, placeholder1, this.monthPart, placeholder2, this.yearPart];
32264
+ }
32265
+ return [];
32266
+ };
32267
+ DateTimeFormatCreator.prototype.createYearMonthDayFormatParts = function () {
32268
+ if (this.monthPart && this.dayPart && this.yearPart) {
32269
+ var tempDateFormat = this.dateFormat.replace('YYYY', '');
32270
+ var placeholderIndex = tempDateFormat.indexOf('MM');
32271
+ var placeholderText = tempDateFormat.substring(0, placeholderIndex);
32272
+ tempDateFormat = tempDateFormat.replace(placeholderText, '').replace('MM', '');
32273
+ var placeholder1 = {
32274
+ characterCount: placeholderText.length,
32275
+ placeholder: placeholderText,
32276
+ inputText: placeholderText,
32277
+ isSeparator: true,
32278
+ };
32279
+ placeholderIndex = tempDateFormat.indexOf('DD');
32280
+ placeholderText = tempDateFormat.substring(0, placeholderIndex);
32281
+ var placeholder2 = {
32282
+ characterCount: placeholderText.length,
32283
+ placeholder: placeholderText,
32284
+ inputText: placeholderText,
32285
+ isSeparator: true,
32286
+ };
32287
+ return [this.yearPart, placeholder1, this.monthPart, placeholder2, this.dayPart];
32288
+ }
32289
+ return [];
32290
+ };
32291
+ DateTimeFormatCreator.prototype.createTwelveHourFormatParts = function () {
32292
+ if (this.twelveHourPart && this.minutePart && this.meridianPart) {
32293
+ var tempTimeFormat = this.timeFormat.replace('HH', '');
32294
+ var placeholderIndex = tempTimeFormat.indexOf('MM');
32295
+ var placeholderText = tempTimeFormat.substring(0, placeholderIndex);
32296
+ var placeholder1 = {
32297
+ characterCount: placeholderText.length,
32298
+ placeholder: placeholderText,
32299
+ inputText: placeholderText,
32300
+ isSeparator: true,
32301
+ };
32302
+ var placeholder2 = {
32303
+ characterCount: 1,
32304
+ placeholder: ' ',
32305
+ inputText: ' ',
32306
+ isSeparator: true,
32307
+ };
32308
+ return [this.twelveHourPart, placeholder1, this.minutePart, placeholder2, this.meridianPart];
32309
+ }
32310
+ return [];
32311
+ };
32312
+ DateTimeFormatCreator.prototype.createTwentyFourHourFormatParts = function () {
32313
+ if (this.twentyFourHourPart && this.minutePart) {
32314
+ var tempTimeFormat = this.timeFormat.replace('HH', '');
32315
+ var placeholderIndex = tempTimeFormat.indexOf('MM');
32316
+ var placeholderText = tempTimeFormat.substring(0, placeholderIndex);
32317
+ var placeholder1 = {
32318
+ characterCount: placeholderText.length,
32319
+ placeholder: placeholderText,
32320
+ inputText: placeholderText,
32321
+ isSeparator: true,
32322
+ };
32323
+ return [this.twentyFourHourPart, placeholder1, this.minutePart];
32324
+ }
32325
+ return [];
32326
+ };
32327
+ DateTimeFormatCreator.prototype.createDateParts = function () {
32328
+ this.monthPart = {
32329
+ characterCount: 2,
32330
+ placeholder: 'M',
32331
+ inputText: '_',
32332
+ isSeparator: false,
32333
+ allCharactersRequired: false,
32334
+ valueType: FormatValueType.Numeric,
32335
+ minimumValue: 1,
32336
+ maximumValue: 12,
32337
+ exceedingMaximumValueCausesTab: true,
32338
+ padWithZeros: true,
32339
+ };
32340
+ this.dayPart = {
32341
+ characterCount: 2,
32342
+ placeholder: 'D',
32343
+ inputText: '_',
32344
+ isSeparator: false,
32345
+ allCharactersRequired: false,
32346
+ valueType: FormatValueType.Numeric,
32347
+ minimumValue: 1,
32348
+ maximumValue: 31,
32349
+ exceedingMaximumValueCausesTab: true,
32350
+ padWithZeros: true,
32351
+ };
32352
+ this.yearPart = {
32353
+ characterCount: 4,
32354
+ placeholder: 'Y',
32355
+ inputText: '_',
32356
+ isSeparator: false,
32357
+ allCharactersRequired: true,
32358
+ valueType: FormatValueType.Numeric,
32359
+ };
32360
+ this.twelveHourPart = {
32361
+ characterCount: 2,
32362
+ placeholder: 'H',
32363
+ inputText: '_',
32364
+ isSeparator: false,
32365
+ allCharactersRequired: false,
32366
+ valueType: FormatValueType.Numeric,
32367
+ minimumValue: 1,
32368
+ maximumValue: 12,
32369
+ exceedingMaximumValueCausesTab: true,
32370
+ padWithZeros: true,
32371
+ };
32372
+ this.twentyFourHourPart = {
32373
+ characterCount: 2,
32374
+ placeholder: 'H',
32375
+ inputText: '_',
32376
+ isSeparator: false,
32377
+ allCharactersRequired: false,
32378
+ valueType: FormatValueType.Numeric,
32379
+ minimumValue: 0,
32380
+ maximumValue: 23,
32381
+ exceedingMaximumValueCausesTab: true,
32382
+ padWithZeros: true,
32383
+ };
32384
+ this.minutePart = {
32385
+ characterCount: 2,
32386
+ placeholder: 'M',
32387
+ inputText: '_',
32388
+ isSeparator: false,
32389
+ allCharactersRequired: false,
32390
+ valueType: FormatValueType.Numeric,
32391
+ minimumValue: 0,
32392
+ maximumValue: 59,
32393
+ exceedingMaximumValueCausesError: true,
32394
+ padWithZeros: true,
32395
+ };
32396
+ this.meridianPart = {
32397
+ characterCount: 2,
32398
+ inputText: '_',
32399
+ isSeparator: false,
32400
+ valueType: FormatValueType.Text,
32401
+ possibleValues: ['AM', 'PM'],
32402
+ };
32403
+ };
32404
+ return DateTimeFormatCreator;
32405
+ }());
32406
+
32407
+ var useGetDateTimeFormat = function (dateSelection, localeCode) {
32408
+ var _a;
32409
+ var _b = React.useState(), inputFormat = _b[0], setInputFormat = _b[1];
32410
+ var formatCreator = React.useRef();
32411
+ React.useEffect(function () {
32412
+ if (localeCode && !inputFormat) {
32413
+ formatCreator.current = new DateTimeFormatCreator(dateSelection, localeCode);
32414
+ setInputFormat(formatCreator.current.createInputFormat());
32415
+ }
32416
+ }, [localeCode]);
32417
+ return [inputFormat, (_a = formatCreator.current) === null || _a === void 0 ? void 0 : _a.is24HourTime];
32418
+ };
32419
+
32671
32420
  function DateTime(_a) {
32672
32421
  var _b;
32673
32422
  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;
32674
32423
  var _k = React.useState(false), selectorOpen = _k[0], setSelectorOpen = _k[1];
32675
- var _l = React.useState(), dropDownTarget = _l[0], setDropDownTarget = _l[1];
32424
+ var _l = React.useState(), localeCode = _l[0], setLocaleCode = _l[1];
32425
+ var _m = React.useState(), dropDownTarget = _m[0], setDropDownTarget = _m[1];
32676
32426
  var isFormattedInput = React.useRef();
32677
32427
  var inputElementChanged = React.useRef(false);
32678
32428
  var language = React.useRef(locale || getBrowserLanguage());
32679
32429
  var loadedLocale = React.useRef();
32680
32430
  var inputElementRef = React.useRef();
32681
32431
  var dropDownTargetRef = React.useRef();
32432
+ var _o = useGetDateTimeFormat(dateSelection, localeCode), inputFormat = _o[0], use24HourTime = _o[1];
32682
32433
  var contextProps = React.useRef({
32683
32434
  calendarTemplate: calendarTemplate,
32684
32435
  dateScrollerTemplate: dateScrollerTemplate,
@@ -32704,64 +32455,13 @@ function DateTime(_a) {
32704
32455
  }
32705
32456
  }, [value, loadedLocale.current]);
32706
32457
  React.useEffect(function () {
32707
- if (dateSelection && loadedLocale.current && loadedLocale.current.code) {
32708
- var dateFormatString = getDateFormatByLocale(loadedLocale.current.code);
32709
- if (dateSelection === DateSelectionType.DateOnly) {
32710
- if (dateFormatString === 'DD/MM/YYYY') {
32711
- dispatcher({
32712
- type: DateTimeActionType.SetInputFormat,
32713
- inputFormat: FormattedInputDefaultFormats.DateDayMonthYear,
32714
- });
32715
- }
32716
- else if (dateFormatString === 'MM/DD/YYYY') {
32717
- dispatcher({
32718
- type: DateTimeActionType.SetInputFormat,
32719
- inputFormat: FormattedInputDefaultFormats.DateMonthDayYear,
32720
- });
32721
- }
32722
- else if (dateFormatString === 'YYYY/MM/DD') {
32723
- dispatcher({
32724
- type: DateTimeActionType.SetInputFormat,
32725
- inputFormat: FormattedInputDefaultFormats.DateYearMonthDay,
32726
- });
32727
- }
32728
- }
32729
- else if (dateSelection === DateSelectionType.TimeOnly) {
32730
- if (uses24HourTimeByLocale(loadedLocale.current.code)) {
32731
- dispatcher({
32732
- type: DateTimeActionType.SetInputFormat,
32733
- inputFormat: FormattedInputDefaultFormats.Time24Hour,
32734
- });
32735
- }
32736
- else {
32737
- dispatcher({
32738
- type: DateTimeActionType.SetInputFormat,
32739
- inputFormat: FormattedInputDefaultFormats.Time12Hour,
32740
- });
32741
- }
32742
- }
32743
- else if (dateSelection === DateSelectionType.DateRange) {
32744
- if (dateFormatString === 'DD/MM/YYYY') {
32745
- dispatcher({
32746
- type: DateTimeActionType.SetInputFormat,
32747
- inputFormat: FormattedInputDefaultFormats.DateRangeDayMonthYear,
32748
- });
32749
- }
32750
- else if (dateFormatString === 'MM/DD/YYYY') {
32751
- dispatcher({
32752
- type: DateTimeActionType.SetInputFormat,
32753
- inputFormat: FormattedInputDefaultFormats.DateRangeMonthDayYear,
32754
- });
32755
- }
32756
- else if (dateFormatString === 'YYYY/MM/DD') {
32757
- dispatcher({
32758
- type: DateTimeActionType.SetInputFormat,
32759
- inputFormat: FormattedInputDefaultFormats.DateRangeYearMonthDay,
32760
- });
32761
- }
32762
- }
32458
+ if (use24HourTime) {
32459
+ dispatcher({
32460
+ type: DateTimeActionType.SetTimeFormat,
32461
+ timeFormat: use24HourTime ? TimeFormatType.TwentyFourHour : TimeFormatType.TwelveHour,
32462
+ });
32763
32463
  }
32764
- }, [dateSelection, loadedLocale.current]);
32464
+ }, [use24HourTime]);
32765
32465
  React.useEffect(function () {
32766
32466
  if (inputElement) {
32767
32467
  inputElementRef.current = inputElement;
@@ -32770,6 +32470,7 @@ function DateTime(_a) {
32770
32470
  var loadLocaleObject = function (localeToLoad) {
32771
32471
  loadLocale(localeToLoad)
32772
32472
  .then(function (locale) {
32473
+ setLocaleCode(locale.code);
32773
32474
  loadedLocale.current = locale;
32774
32475
  var defaultDate = getDateValue();
32775
32476
  if (value || useDefaultDateValue) {
@@ -32808,7 +32509,7 @@ function DateTime(_a) {
32808
32509
  timeFormat: TimeFormatType.TwelveHour,
32809
32510
  dateInitialized: false,
32810
32511
  };
32811
- var _m = React.useReducer(reducer, initialState), state = _m[0], dispatcher = _m[1];
32512
+ var _p = React.useReducer(reducer, initialState), state = _p[0], dispatcher = _p[1];
32812
32513
  var onFocus = function () {
32813
32514
  setDropDownElement();
32814
32515
  setSelectorOpen(true);
@@ -32983,7 +32684,7 @@ function DateTime(_a) {
32983
32684
  _b["".concat((colors === null || colors === void 0 ? void 0 : colors.readOnlyInputBgColor) || 'bsc-bg-gray-200')] = readOnly,
32984
32685
  _b["".concat((colors === null || colors === void 0 ? void 0 : colors.inputBgColor) || 'bsc-bg-white')] = !readOnly,
32985
32686
  _b), "dark:bsc-bg-black ".concat(colors === null || colors === void 0 ? void 0 : colors.inputBorderColor, " bc-dt-input"), className);
32986
- 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 })), jsxRuntime.jsx(TemplateOutlet, __assign({ props: inputTemplateProps, template: template }, { children: useFormattedInput === false || state.inputFormat === undefined ? (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 &&
32687
+ 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 })), jsxRuntime.jsx(TemplateOutlet, __assign({ props: inputTemplateProps, template: template }, { children: useFormattedInput === false ? (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, format: inputFormat, onFocus: onFocus, onChange: onFormatStringChange, onElementCreate: function (element) { return onInputElementCreated(element, true); } }, 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 &&
32987
32688
  canShowDateSelectors &&
32988
32689
  state.dateInitialized &&
32989
32690
  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 &&