beesoft-components 0.3.0-0 → 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 +436 -734
  2. package/build/index.js +436 -734
  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 : {};
@@ -30376,9 +30386,7 @@ function OverlayPanel(_a) {
30376
30386
  var onEntered = function () {
30377
30387
  if (!panelRef.current)
30378
30388
  return;
30379
- if (shown) {
30380
- shown();
30381
- }
30389
+ shown === null || shown === void 0 ? void 0 : shown();
30382
30390
  var otherElements = undefined;
30383
30391
  if (!shouldTargetCloseOverlay && finalTarget.current) {
30384
30392
  otherElements = [finalTarget.current];
@@ -30403,14 +30411,12 @@ function OverlayPanel(_a) {
30403
30411
  };
30404
30412
  var onExited = function () {
30405
30413
  setZIndex(-1);
30406
- if (hidden) {
30407
- hidden();
30408
- }
30414
+ hidden === null || hidden === void 0 ? void 0 : hidden();
30409
30415
  };
30410
30416
  var onMarkupCreated = function (element) {
30411
30417
  var _a, _b;
30412
30418
  panelRef.current = element;
30413
- markupCreated && markupCreated(element);
30419
+ markupCreated === null || markupCreated === void 0 ? void 0 : markupCreated(element);
30414
30420
  if (finalTarget.current) {
30415
30421
  var position = DomHandler.positionElementToTarget(panelRef.current, finalTarget.current, elementAlignment, targetPosition);
30416
30422
  panelDimensions.current = __assign(__assign({}, position), { width: finalTarget.current.offsetWidth });
@@ -30437,19 +30443,6 @@ function OverlayPanel(_a) {
30437
30443
  } })));
30438
30444
  }
30439
30445
 
30440
- var FormattedInputDefaultFormats;
30441
- (function (FormattedInputDefaultFormats) {
30442
- FormattedInputDefaultFormats[FormattedInputDefaultFormats["DateDayMonthYear"] = 0] = "DateDayMonthYear";
30443
- FormattedInputDefaultFormats[FormattedInputDefaultFormats["DateMonthDayYear"] = 1] = "DateMonthDayYear";
30444
- FormattedInputDefaultFormats[FormattedInputDefaultFormats["DateYearMonthDay"] = 2] = "DateYearMonthDay";
30445
- FormattedInputDefaultFormats[FormattedInputDefaultFormats["DateRangeDayMonthYear"] = 3] = "DateRangeDayMonthYear";
30446
- FormattedInputDefaultFormats[FormattedInputDefaultFormats["DateRangeMonthDayYear"] = 4] = "DateRangeMonthDayYear";
30447
- FormattedInputDefaultFormats[FormattedInputDefaultFormats["DateRangeYearMonthDay"] = 5] = "DateRangeYearMonthDay";
30448
- FormattedInputDefaultFormats[FormattedInputDefaultFormats["Time12Hour"] = 6] = "Time12Hour";
30449
- FormattedInputDefaultFormats[FormattedInputDefaultFormats["Time24Hour"] = 7] = "Time24Hour";
30450
- FormattedInputDefaultFormats[FormattedInputDefaultFormats["Custom"] = 8] = "Custom";
30451
- })(FormattedInputDefaultFormats || (FormattedInputDefaultFormats = {}));
30452
-
30453
30446
  // Unique ID creation requires a high quality random # generator. In the browser we therefore
30454
30447
  // require the crypto API and do not support built-in fallback to lower quality random number
30455
30448
  // generators (like Math.random()).
@@ -30758,7 +30751,7 @@ var InputSlotCollection = (function () {
30758
30751
  finalSlotIndex = i;
30759
30752
  }
30760
30753
  }
30761
- return this.inputSlots[finalSlotIndex];
30754
+ return this.inputSlots[finalSlotIndex > -1 ? finalSlotIndex : 0];
30762
30755
  };
30763
30756
  InputSlotCollection.prototype.allSlotsCompleted = function () {
30764
30757
  return this.inputSlots.every(function (slot) { return slot.isComplete; });
@@ -31064,7 +31057,12 @@ var InputRuleProcessor = (function () {
31064
31057
  this.addToInputSlot(key);
31065
31058
  inputSlot.isComplete = true;
31066
31059
  this.formatRenderer.render();
31067
- this.formatNavigator.moveToNextInputPart();
31060
+ if (!this.formatNavigator.isAtLastPart()) {
31061
+ this.formatNavigator.moveToNextInputPart();
31062
+ }
31063
+ else {
31064
+ this.formatNavigator.moveCursorRight();
31065
+ }
31068
31066
  }
31069
31067
  else {
31070
31068
  this.addToInputSlot(key);
@@ -31207,7 +31205,7 @@ var FormatParser = (function () {
31207
31205
  var _this = this;
31208
31206
  this.isInputFocused = true;
31209
31207
  this.formatRenderer.render();
31210
- setTimeout(function () { return _this.formatNavigator.setCursorToCurrentPosition(); });
31208
+ setTimeout(function () { return _this.formatNavigator.findCursorPosition(); });
31211
31209
  };
31212
31210
  FormatParser.prototype.inputBlurred = function () {
31213
31211
  this.isInputFocused = false;
@@ -31215,8 +31213,13 @@ var FormatParser = (function () {
31215
31213
  FormatParser.prototype.inputValuePassed = function (inputValue) {
31216
31214
  var _this = this;
31217
31215
  this.inputValue = inputValue;
31218
- if (this.inputElementSet && this.inputValue.length > 0) {
31219
- this.inputRuleProcessor.processInputValue(inputValue);
31216
+ if (this.inputElementSet) {
31217
+ if (this.inputValue.length > 0) {
31218
+ this.inputRuleProcessor.processInputValue(inputValue);
31219
+ }
31220
+ else {
31221
+ this.inputSlotCollection.clearAllSlots();
31222
+ }
31220
31223
  setTimeout(function () {
31221
31224
  _this.formatRenderer.render();
31222
31225
  if (_this.isInputFocused) {
@@ -31256,630 +31259,74 @@ var FormatParser = (function () {
31256
31259
  return FormatParser;
31257
31260
  }());
31258
31261
 
31259
- var format$7 = {
31260
- formatParts: [
31261
- {
31262
- characterCount: 2,
31263
- placeholder: 'D',
31264
- inputText: '_',
31265
- isSeparator: false,
31266
- allCharactersRequired: false,
31267
- valueType: FormatValueType.Numeric,
31268
- minimumValue: 1,
31269
- maximumValue: 31,
31270
- exceedingMaximumValueCausesTab: true,
31271
- padWithZeros: true,
31272
- },
31273
- {
31274
- characterCount: 1,
31275
- placeholder: '/',
31276
- inputText: '/',
31277
- isSeparator: true,
31278
- },
31279
- {
31280
- characterCount: 2,
31281
- placeholder: 'M',
31282
- inputText: '_',
31283
- isSeparator: false,
31284
- allCharactersRequired: false,
31285
- valueType: FormatValueType.Numeric,
31286
- minimumValue: 1,
31287
- maximumValue: 12,
31288
- exceedingMaximumValueCausesTab: true,
31289
- padWithZeros: true,
31290
- },
31291
- {
31292
- characterCount: 1,
31293
- placeholder: '/',
31294
- inputText: '/',
31295
- isSeparator: true,
31296
- },
31297
- {
31298
- characterCount: 4,
31299
- placeholder: 'Y',
31300
- inputText: '_',
31301
- isSeparator: false,
31302
- allCharactersRequired: true,
31303
- valueType: FormatValueType.Numeric,
31304
- },
31305
- ],
31306
- };
31307
-
31308
- var format$6 = {
31309
- formatParts: [
31310
- {
31311
- characterCount: 2,
31312
- placeholder: 'M',
31313
- inputText: '_',
31314
- isSeparator: false,
31315
- allCharactersRequired: false,
31316
- valueType: FormatValueType.Numeric,
31317
- minimumValue: 1,
31318
- maximumValue: 12,
31319
- exceedingMaximumValueCausesTab: true,
31320
- padWithZeros: true,
31321
- },
31322
- {
31323
- characterCount: 1,
31324
- placeholder: '/',
31325
- inputText: '/',
31326
- isSeparator: true,
31327
- },
31328
- {
31329
- characterCount: 2,
31330
- placeholder: 'D',
31331
- inputText: '_',
31332
- isSeparator: false,
31333
- allCharactersRequired: false,
31334
- valueType: FormatValueType.Numeric,
31335
- minimumValue: 1,
31336
- maximumValue: 31,
31337
- exceedingMaximumValueCausesTab: true,
31338
- padWithZeros: true,
31339
- },
31340
- {
31341
- characterCount: 1,
31342
- placeholder: '/',
31343
- inputText: '/',
31344
- isSeparator: true,
31345
- },
31346
- {
31347
- characterCount: 4,
31348
- placeholder: 'Y',
31349
- inputText: '_',
31350
- isSeparator: false,
31351
- allCharactersRequired: true,
31352
- valueType: FormatValueType.Numeric,
31353
- },
31354
- ],
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 }));
31355
31326
  };
31327
+ var FormattedInput$1 = React.memo(React.forwardRef(FormattedInput));
31356
31328
 
31357
- var format$5 = {
31358
- formatParts: [
31359
- {
31360
- characterCount: 4,
31361
- placeholder: 'Y',
31362
- inputText: '_',
31363
- isSeparator: false,
31364
- allCharactersRequired: true,
31365
- valueType: FormatValueType.Numeric,
31366
- },
31367
- {
31368
- characterCount: 1,
31369
- placeholder: '-',
31370
- inputText: '-',
31371
- isSeparator: true,
31372
- },
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
- exceedingMaximumValueCausesError: true,
31401
- padWithZeros: true,
31402
- },
31403
- ],
31404
- };
31405
-
31406
- var format$4 = {
31407
- formatParts: [
31408
- {
31409
- characterCount: 2,
31410
- placeholder: 'D',
31411
- inputText: '_',
31412
- isSeparator: false,
31413
- allCharactersRequired: false,
31414
- valueType: FormatValueType.Numeric,
31415
- minimumValue: 1,
31416
- maximumValue: 31,
31417
- exceedingMaximumValueCausesTab: true,
31418
- padWithZeros: true,
31419
- },
31420
- {
31421
- characterCount: 1,
31422
- placeholder: '/',
31423
- inputText: '/',
31424
- isSeparator: true,
31425
- },
31426
- {
31427
- characterCount: 2,
31428
- placeholder: 'M',
31429
- inputText: '_',
31430
- isSeparator: false,
31431
- allCharactersRequired: false,
31432
- valueType: FormatValueType.Numeric,
31433
- minimumValue: 1,
31434
- maximumValue: 12,
31435
- exceedingMaximumValueCausesTab: true,
31436
- padWithZeros: true,
31437
- },
31438
- {
31439
- characterCount: 1,
31440
- placeholder: '/',
31441
- inputText: '/',
31442
- isSeparator: true,
31443
- },
31444
- {
31445
- characterCount: 4,
31446
- placeholder: 'Y',
31447
- inputText: '_',
31448
- isSeparator: false,
31449
- allCharactersRequired: true,
31450
- valueType: FormatValueType.Numeric,
31451
- },
31452
- {
31453
- characterCount: 3,
31454
- placeholder: ' - ',
31455
- inputText: ' - ',
31456
- isSeparator: true,
31457
- },
31458
- {
31459
- characterCount: 2,
31460
- placeholder: 'D',
31461
- inputText: '_',
31462
- isSeparator: false,
31463
- allCharactersRequired: false,
31464
- valueType: FormatValueType.Numeric,
31465
- minimumValue: 1,
31466
- maximumValue: 31,
31467
- exceedingMaximumValueCausesTab: true,
31468
- padWithZeros: true,
31469
- },
31470
- {
31471
- characterCount: 1,
31472
- placeholder: '/',
31473
- inputText: '/',
31474
- isSeparator: true,
31475
- },
31476
- {
31477
- characterCount: 2,
31478
- placeholder: 'M',
31479
- inputText: '_',
31480
- isSeparator: false,
31481
- allCharactersRequired: false,
31482
- valueType: FormatValueType.Numeric,
31483
- minimumValue: 1,
31484
- maximumValue: 12,
31485
- exceedingMaximumValueCausesTab: true,
31486
- padWithZeros: true,
31487
- },
31488
- {
31489
- characterCount: 1,
31490
- placeholder: '/',
31491
- inputText: '/',
31492
- isSeparator: true,
31493
- },
31494
- {
31495
- characterCount: 4,
31496
- placeholder: 'Y',
31497
- inputText: '_',
31498
- isSeparator: false,
31499
- allCharactersRequired: true,
31500
- valueType: FormatValueType.Numeric,
31501
- },
31502
- ],
31503
- };
31504
-
31505
- var format$3 = {
31506
- formatParts: [
31507
- {
31508
- characterCount: 2,
31509
- placeholder: 'M',
31510
- inputText: '_',
31511
- isSeparator: false,
31512
- allCharactersRequired: false,
31513
- valueType: FormatValueType.Numeric,
31514
- minimumValue: 1,
31515
- maximumValue: 12,
31516
- exceedingMaximumValueCausesTab: true,
31517
- padWithZeros: true,
31518
- },
31519
- {
31520
- characterCount: 1,
31521
- placeholder: '/',
31522
- inputText: '/',
31523
- isSeparator: true,
31524
- },
31525
- {
31526
- characterCount: 2,
31527
- placeholder: 'D',
31528
- inputText: '_',
31529
- isSeparator: false,
31530
- allCharactersRequired: false,
31531
- valueType: FormatValueType.Numeric,
31532
- minimumValue: 1,
31533
- maximumValue: 31,
31534
- exceedingMaximumValueCausesTab: true,
31535
- padWithZeros: true,
31536
- },
31537
- {
31538
- characterCount: 1,
31539
- placeholder: '/',
31540
- inputText: '/',
31541
- isSeparator: true,
31542
- },
31543
- {
31544
- characterCount: 4,
31545
- placeholder: 'Y',
31546
- inputText: '_',
31547
- isSeparator: false,
31548
- allCharactersRequired: true,
31549
- valueType: FormatValueType.Numeric,
31550
- },
31551
- {
31552
- characterCount: 3,
31553
- placeholder: ' - ',
31554
- inputText: ' - ',
31555
- isSeparator: true,
31556
- },
31557
- {
31558
- characterCount: 2,
31559
- placeholder: 'M',
31560
- inputText: '_',
31561
- isSeparator: false,
31562
- allCharactersRequired: false,
31563
- valueType: FormatValueType.Numeric,
31564
- minimumValue: 1,
31565
- maximumValue: 12,
31566
- exceedingMaximumValueCausesTab: true,
31567
- padWithZeros: true,
31568
- },
31569
- {
31570
- characterCount: 1,
31571
- placeholder: '/',
31572
- inputText: '/',
31573
- isSeparator: true,
31574
- },
31575
- {
31576
- characterCount: 2,
31577
- placeholder: 'D',
31578
- inputText: '_',
31579
- isSeparator: false,
31580
- allCharactersRequired: false,
31581
- valueType: FormatValueType.Numeric,
31582
- minimumValue: 1,
31583
- maximumValue: 31,
31584
- exceedingMaximumValueCausesTab: true,
31585
- padWithZeros: true,
31586
- },
31587
- {
31588
- characterCount: 1,
31589
- placeholder: '/',
31590
- inputText: '/',
31591
- isSeparator: true,
31592
- },
31593
- {
31594
- characterCount: 4,
31595
- placeholder: 'Y',
31596
- inputText: '_',
31597
- isSeparator: false,
31598
- allCharactersRequired: true,
31599
- valueType: FormatValueType.Numeric,
31600
- },
31601
- ],
31602
- };
31603
-
31604
- var format$2 = {
31605
- formatParts: [
31606
- {
31607
- characterCount: 4,
31608
- placeholder: 'Y',
31609
- inputText: '_',
31610
- isSeparator: false,
31611
- allCharactersRequired: true,
31612
- valueType: FormatValueType.Numeric,
31613
- },
31614
- {
31615
- characterCount: 1,
31616
- placeholder: '-',
31617
- inputText: '-',
31618
- isSeparator: true,
31619
- },
31620
- {
31621
- characterCount: 2,
31622
- placeholder: 'M',
31623
- inputText: '_',
31624
- isSeparator: false,
31625
- allCharactersRequired: false,
31626
- valueType: FormatValueType.Numeric,
31627
- minimumValue: 1,
31628
- maximumValue: 12,
31629
- exceedingMaximumValueCausesTab: true,
31630
- padWithZeros: true,
31631
- },
31632
- {
31633
- characterCount: 1,
31634
- placeholder: '-',
31635
- inputText: '-',
31636
- isSeparator: true,
31637
- },
31638
- {
31639
- characterCount: 2,
31640
- placeholder: 'D',
31641
- inputText: '_',
31642
- isSeparator: false,
31643
- allCharactersRequired: false,
31644
- valueType: FormatValueType.Numeric,
31645
- minimumValue: 1,
31646
- maximumValue: 31,
31647
- exceedingMaximumValueCausesTab: true,
31648
- padWithZeros: true,
31649
- },
31650
- {
31651
- characterCount: 3,
31652
- placeholder: ' - ',
31653
- inputText: ' - ',
31654
- isSeparator: true,
31655
- },
31656
- {
31657
- characterCount: 4,
31658
- placeholder: 'Y',
31659
- inputText: '_',
31660
- isSeparator: false,
31661
- allCharactersRequired: true,
31662
- valueType: FormatValueType.Numeric,
31663
- },
31664
- {
31665
- characterCount: 1,
31666
- placeholder: '-',
31667
- inputText: '-',
31668
- isSeparator: true,
31669
- },
31670
- {
31671
- characterCount: 2,
31672
- placeholder: 'M',
31673
- inputText: '_',
31674
- isSeparator: false,
31675
- allCharactersRequired: false,
31676
- valueType: FormatValueType.Numeric,
31677
- minimumValue: 1,
31678
- maximumValue: 12,
31679
- exceedingMaximumValueCausesTab: true,
31680
- padWithZeros: true,
31681
- },
31682
- {
31683
- characterCount: 1,
31684
- placeholder: '/',
31685
- inputText: '/',
31686
- isSeparator: true,
31687
- },
31688
- {
31689
- characterCount: 2,
31690
- placeholder: 'D',
31691
- inputText: '_',
31692
- isSeparator: false,
31693
- allCharactersRequired: false,
31694
- valueType: FormatValueType.Numeric,
31695
- minimumValue: 1,
31696
- maximumValue: 31,
31697
- exceedingMaximumValueCausesError: true,
31698
- padWithZeros: true,
31699
- },
31700
- ],
31701
- };
31702
-
31703
- var format$1 = {
31704
- formatParts: [
31705
- {
31706
- characterCount: 2,
31707
- placeholder: 'H',
31708
- inputText: '_',
31709
- isSeparator: false,
31710
- allCharactersRequired: false,
31711
- valueType: FormatValueType.Numeric,
31712
- minimumValue: 1,
31713
- maximumValue: 12,
31714
- exceedingMaximumValueCausesTab: true,
31715
- padWithZeros: true,
31716
- },
31717
- {
31718
- characterCount: 1,
31719
- placeholder: ':',
31720
- inputText: ':',
31721
- isSeparator: true,
31722
- },
31723
- {
31724
- characterCount: 2,
31725
- placeholder: 'M',
31726
- inputText: '_',
31727
- isSeparator: false,
31728
- allCharactersRequired: false,
31729
- valueType: FormatValueType.Numeric,
31730
- minimumValue: 0,
31731
- maximumValue: 59,
31732
- exceedingMaximumValueCausesError: true,
31733
- padWithZeros: true,
31734
- },
31735
- {
31736
- characterCount: 1,
31737
- placeholder: ' ',
31738
- inputText: ' ',
31739
- isSeparator: true,
31740
- },
31741
- {
31742
- characterCount: 2,
31743
- inputText: '_',
31744
- isSeparator: false,
31745
- possibleValues: ['AM', 'PM'],
31746
- },
31747
- ],
31748
- };
31749
-
31750
- var format = {
31751
- formatParts: [
31752
- {
31753
- characterCount: 2,
31754
- placeholder: 'H',
31755
- inputText: '_',
31756
- isSeparator: false,
31757
- allCharactersRequired: false,
31758
- valueType: FormatValueType.Numeric,
31759
- minimumValue: 0,
31760
- maximumValue: 23,
31761
- exceedingMaximumValueCausesTab: true,
31762
- padWithZeros: true,
31763
- },
31764
- {
31765
- characterCount: 1,
31766
- placeholder: ':',
31767
- inputText: ':',
31768
- isSeparator: true,
31769
- },
31770
- {
31771
- characterCount: 2,
31772
- placeholder: 'M',
31773
- inputText: '_',
31774
- isSeparator: false,
31775
- allCharactersRequired: false,
31776
- valueType: FormatValueType.Numeric,
31777
- minimumValue: 1,
31778
- maximumValue: 59,
31779
- exceedingMaximumValueCausesError: true,
31780
- padWithZeros: true,
31781
- },
31782
- ],
31783
- };
31784
-
31785
- var FormattedInput = function (props, ref) {
31786
- 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;
31787
- var inputRef = React.useRef();
31788
- var inputElementRef = React.useRef();
31789
- var formatParser = React.useRef();
31790
- React.useEffect(function () {
31791
- return function () {
31792
- var _a;
31793
- (_a = formatParser.current) === null || _a === void 0 ? void 0 : _a.dispose();
31794
- };
31795
- }, []);
31796
- React.useEffect(function () {
31797
- var _a;
31798
- (_a = formatParser.current) === null || _a === void 0 ? void 0 : _a.inputValuePassed(value);
31799
- }, [value]);
31800
- React.useEffect(function () {
31801
- var _a, _b, _c;
31802
- (_a = formatParser.current) === null || _a === void 0 ? void 0 : _a.dispose();
31803
- if (defaultFormat !== FormattedInputDefaultFormats.Custom) {
31804
- var formatSetting = getPreDefinedFormat(defaultFormat);
31805
- if (!formatSetting) {
31806
- throw new Error('The selected format does not exist');
31807
- }
31808
- formatParser.current = new FormatParser(formatSetting, value);
31809
- }
31810
- else {
31811
- if (!format$8) {
31812
- throw new Error('The format property is required when the default format is custom');
31813
- }
31814
- formatParser.current = new FormatParser(format$8, value);
31815
- }
31816
- if (inputElementRef.current) {
31817
- (_b = formatParser.current) === null || _b === void 0 ? void 0 : _b.inputElementCreated(inputElementRef.current);
31818
- }
31819
- (_c = formatParser.current) === null || _c === void 0 ? void 0 : _c.registerFormatChangeEvent(onFormatChange);
31820
- }, [defaultFormat, format$8]);
31821
- var onFormatChange = React.useCallback(function (value) {
31822
- onChange === null || onChange === void 0 ? void 0 : onChange(value);
31823
- }, [onChange]);
31824
- var getPreDefinedFormat = React.useCallback(function (format$8) {
31825
- switch (format$8) {
31826
- case FormattedInputDefaultFormats.DateDayMonthYear:
31827
- return format$7;
31828
- case FormattedInputDefaultFormats.DateMonthDayYear:
31829
- return format$6;
31830
- case FormattedInputDefaultFormats.DateYearMonthDay:
31831
- return format$5;
31832
- case FormattedInputDefaultFormats.DateRangeDayMonthYear:
31833
- return format$4;
31834
- case FormattedInputDefaultFormats.DateRangeMonthDayYear:
31835
- return format$3;
31836
- case FormattedInputDefaultFormats.DateRangeYearMonthDay:
31837
- return format$2;
31838
- case FormattedInputDefaultFormats.Time12Hour:
31839
- return format$1;
31840
- case FormattedInputDefaultFormats.Time24Hour:
31841
- return format;
31842
- }
31843
- }, []);
31844
- var onFocusHandler = React.useCallback(function (event) {
31845
- var _a;
31846
- (_a = formatParser.current) === null || _a === void 0 ? void 0 : _a.inputFocused();
31847
- onFocus === null || onFocus === void 0 ? void 0 : onFocus(event);
31848
- }, [onFocus]);
31849
- var onBlurHandler = React.useCallback(function (event) {
31850
- var _a;
31851
- (_a = formatParser.current) === null || _a === void 0 ? void 0 : _a.inputBlurred();
31852
- onBlur === null || onBlur === void 0 ? void 0 : onBlur(event);
31853
- }, [onBlur]);
31854
- var onMouseUpHandler = React.useCallback(function () {
31855
- var _a;
31856
- (_a = formatParser.current) === null || _a === void 0 ? void 0 : _a.mouseUpHandler();
31857
- }, []);
31858
- var onKeyDownHandler = React.useCallback(function (event) {
31859
- var _a;
31860
- (_a = formatParser.current) === null || _a === void 0 ? void 0 : _a.keyDownHandler(event);
31861
- }, []);
31862
- var onInputRefCreated = React.useCallback(function (ref) {
31863
- var _a, _b, _c, _d, _e, _f, _g, _h, _j;
31864
- (_b = (_a = inputRef.current) === null || _a === void 0 ? void 0 : _a.inputElement) === null || _b === void 0 ? void 0 : _b.removeEventListener('keydown', onKeyDownHandler);
31865
- (_d = (_c = inputRef.current) === null || _c === void 0 ? void 0 : _c.inputElement) === null || _d === void 0 ? void 0 : _d.removeEventListener('mouseup', onMouseUpHandler);
31866
- inputRef.current = ref;
31867
- (_f = (_e = inputRef.current) === null || _e === void 0 ? void 0 : _e.inputElement) === null || _f === void 0 ? void 0 : _f.addEventListener('keydown', onKeyDownHandler);
31868
- (_h = (_g = inputRef.current) === null || _g === void 0 ? void 0 : _g.inputElement) === null || _h === void 0 ? void 0 : _h.addEventListener('mouseup', onMouseUpHandler);
31869
- inputElementRef.current = (_j = inputRef.current) === null || _j === void 0 ? void 0 : _j.inputElement;
31870
- }, []);
31871
- var focus = React.useCallback(function () {
31872
- var _a;
31873
- (_a = inputRef.current) === null || _a === void 0 ? void 0 : _a.focus();
31874
- }, []);
31875
- React.useImperativeHandle(ref, function () { return ({
31876
- focus: focus,
31877
- }); });
31878
- 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 }));
31879
- };
31880
- var FormattedInput$1 = React.memo(React.forwardRef(FormattedInput));
31881
-
31882
- var DateTimeContext = React.createContext(undefined);
31329
+ var DateTimeContext = React.createContext(undefined);
31883
31330
 
31884
31331
  function getMonthMatrix(matrixDate, locale, loadOtherMonths) {
31885
31332
  var _a, _b;
@@ -32045,25 +31492,6 @@ function loadLocale(localeToLoad) {
32045
31492
  });
32046
31493
  });
32047
31494
  }
32048
- function getDateFormatByLocale(locale) {
32049
- var year = 2023;
32050
- var month = 12;
32051
- var day = 20;
32052
- var date = new Date(year, month - 1, day);
32053
- var formattedDate = date.toLocaleDateString(locale, {
32054
- year: 'numeric',
32055
- month: 'numeric',
32056
- day: 'numeric',
32057
- });
32058
- return formattedDate.replace("".concat(year), 'YYYY').replace("".concat(month), 'MM').replace("".concat(day), 'DD');
32059
- }
32060
- function uses24HourTimeByLocale(locale) {
32061
- var date = new Date();
32062
- var hour = 18;
32063
- date.setHours(hour);
32064
- var timeParts = date.toLocaleTimeString(locale).split(':');
32065
- return timeParts[0] === '18';
32066
- }
32067
31495
  function createDefaultColors() {
32068
31496
  return {
32069
31497
  inputBgColor: 'bsc-bg-white',
@@ -32084,16 +31512,19 @@ function parseDate(dateValue, locale) {
32084
31512
  localDate = parse(dateValue, 'P HH:mm', new Date(), { locale: locale });
32085
31513
  if (!isNaN(localDate.valueOf()))
32086
31514
  return localDate;
32087
- localDate = parse(dateValue, 'P HH:mm aaa', new Date(), { locale: locale });
31515
+ localDate = parse(dateValue, 'P hh:mm a..aaa', new Date(), { locale: locale });
32088
31516
  if (!isNaN(localDate.valueOf()))
32089
31517
  return localDate;
32090
31518
  localDate = parse(dateValue, 'P HH:mm:ss', new Date(), { locale: locale });
32091
31519
  if (!isNaN(localDate.valueOf()))
32092
31520
  return localDate;
32093
- 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 });
32094
31522
  if (!isNaN(localDate.valueOf()))
32095
31523
  return localDate;
32096
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 });
32097
31528
  if (!isNaN(localDate.valueOf()))
32098
31529
  return localDate;
32099
31530
  localDate = parse(dateValue, 'pp', new Date(), { locale: locale });
@@ -32168,7 +31599,7 @@ var DateTimeActionType;
32168
31599
  DateTimeActionType[DateTimeActionType["SetSelectedDateRange"] = 7] = "SetSelectedDateRange";
32169
31600
  DateTimeActionType[DateTimeActionType["SetSelectedStartDate"] = 8] = "SetSelectedStartDate";
32170
31601
  DateTimeActionType[DateTimeActionType["SetSelectedEndDate"] = 9] = "SetSelectedEndDate";
32171
- DateTimeActionType[DateTimeActionType["SetInputFormat"] = 10] = "SetInputFormat";
31602
+ DateTimeActionType[DateTimeActionType["SetTimeFormat"] = 10] = "SetTimeFormat";
32172
31603
  DateTimeActionType[DateTimeActionType["ClearDates"] = 11] = "ClearDates";
32173
31604
  DateTimeActionType[DateTimeActionType["InitializeDates"] = 12] = "InitializeDates";
32174
31605
  })(DateTimeActionType || (DateTimeActionType = {}));
@@ -32194,16 +31625,13 @@ var reducer = function (state, action) {
32194
31625
  return __assign(__assign({}, state), { selectedStartDate: action.selectedStartDate, selectedEndDate: undefined });
32195
31626
  case DateTimeActionType.SetSelectedEndDate:
32196
31627
  return __assign(__assign({}, state), { selectedEndDate: action.selectedEndDate });
32197
- case DateTimeActionType.SetInputFormat:
32198
- return __assign(__assign({}, state), { timeFormat: action.inputFormat === FormattedInputDefaultFormats.Time24Hour
32199
- ? TimeFormatType.TwentyFourHour
32200
- : action.timeFormat || TimeFormatType.TwelveHour, inputFormat: action.inputFormat });
31628
+ case DateTimeActionType.SetTimeFormat:
31629
+ return __assign(__assign({}, state), { timeFormat: action.timeFormat || state.timeFormat });
32201
31630
  case DateTimeActionType.ClearDates:
32202
31631
  return {
32203
31632
  currentSelector: state.currentSelector,
32204
31633
  currentViewDate: state.currentViewDate,
32205
31634
  timeFormat: state.timeFormat,
32206
- inputFormat: state.inputFormat,
32207
31635
  dateInitialized: true,
32208
31636
  };
32209
31637
  case DateTimeActionType.InitializeDates:
@@ -32667,17 +32095,341 @@ function DateTimeYearSelector(_a) {
32667
32095
  }) })) }))] })));
32668
32096
  }
32669
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
+
32670
32420
  function DateTime(_a) {
32671
32421
  var _b;
32672
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;
32673
32423
  var _k = React.useState(false), selectorOpen = _k[0], setSelectorOpen = _k[1];
32674
- 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];
32675
32426
  var isFormattedInput = React.useRef();
32676
32427
  var inputElementChanged = React.useRef(false);
32677
32428
  var language = React.useRef(locale || getBrowserLanguage());
32678
32429
  var loadedLocale = React.useRef();
32679
32430
  var inputElementRef = React.useRef();
32680
32431
  var dropDownTargetRef = React.useRef();
32432
+ var _o = useGetDateTimeFormat(dateSelection, localeCode), inputFormat = _o[0], use24HourTime = _o[1];
32681
32433
  var contextProps = React.useRef({
32682
32434
  calendarTemplate: calendarTemplate,
32683
32435
  dateScrollerTemplate: dateScrollerTemplate,
@@ -32703,64 +32455,13 @@ function DateTime(_a) {
32703
32455
  }
32704
32456
  }, [value, loadedLocale.current]);
32705
32457
  React.useEffect(function () {
32706
- if (dateSelection && loadedLocale.current && loadedLocale.current.code) {
32707
- var dateFormatString = getDateFormatByLocale(loadedLocale.current.code);
32708
- if (dateSelection === DateSelectionType.DateOnly) {
32709
- if (dateFormatString === 'DD/MM/YYYY') {
32710
- dispatcher({
32711
- type: DateTimeActionType.SetInputFormat,
32712
- inputFormat: FormattedInputDefaultFormats.DateDayMonthYear,
32713
- });
32714
- }
32715
- else if (dateFormatString === 'MM/DD/YYYY') {
32716
- dispatcher({
32717
- type: DateTimeActionType.SetInputFormat,
32718
- inputFormat: FormattedInputDefaultFormats.DateMonthDayYear,
32719
- });
32720
- }
32721
- else if (dateFormatString === 'YYYY/MM/DD') {
32722
- dispatcher({
32723
- type: DateTimeActionType.SetInputFormat,
32724
- inputFormat: FormattedInputDefaultFormats.DateYearMonthDay,
32725
- });
32726
- }
32727
- }
32728
- else if (dateSelection === DateSelectionType.TimeOnly) {
32729
- if (uses24HourTimeByLocale(loadedLocale.current.code)) {
32730
- dispatcher({
32731
- type: DateTimeActionType.SetInputFormat,
32732
- inputFormat: FormattedInputDefaultFormats.Time24Hour,
32733
- });
32734
- }
32735
- else {
32736
- dispatcher({
32737
- type: DateTimeActionType.SetInputFormat,
32738
- inputFormat: FormattedInputDefaultFormats.Time12Hour,
32739
- });
32740
- }
32741
- }
32742
- else if (dateSelection === DateSelectionType.DateRange) {
32743
- if (dateFormatString === 'DD/MM/YYYY') {
32744
- dispatcher({
32745
- type: DateTimeActionType.SetInputFormat,
32746
- inputFormat: FormattedInputDefaultFormats.DateRangeDayMonthYear,
32747
- });
32748
- }
32749
- else if (dateFormatString === 'MM/DD/YYYY') {
32750
- dispatcher({
32751
- type: DateTimeActionType.SetInputFormat,
32752
- inputFormat: FormattedInputDefaultFormats.DateRangeMonthDayYear,
32753
- });
32754
- }
32755
- else if (dateFormatString === 'YYYY/MM/DD') {
32756
- dispatcher({
32757
- type: DateTimeActionType.SetInputFormat,
32758
- inputFormat: FormattedInputDefaultFormats.DateRangeYearMonthDay,
32759
- });
32760
- }
32761
- }
32458
+ if (use24HourTime) {
32459
+ dispatcher({
32460
+ type: DateTimeActionType.SetTimeFormat,
32461
+ timeFormat: use24HourTime ? TimeFormatType.TwentyFourHour : TimeFormatType.TwelveHour,
32462
+ });
32762
32463
  }
32763
- }, [dateSelection, loadedLocale.current]);
32464
+ }, [use24HourTime]);
32764
32465
  React.useEffect(function () {
32765
32466
  if (inputElement) {
32766
32467
  inputElementRef.current = inputElement;
@@ -32769,6 +32470,7 @@ function DateTime(_a) {
32769
32470
  var loadLocaleObject = function (localeToLoad) {
32770
32471
  loadLocale(localeToLoad)
32771
32472
  .then(function (locale) {
32473
+ setLocaleCode(locale.code);
32772
32474
  loadedLocale.current = locale;
32773
32475
  var defaultDate = getDateValue();
32774
32476
  if (value || useDefaultDateValue) {
@@ -32807,7 +32509,7 @@ function DateTime(_a) {
32807
32509
  timeFormat: TimeFormatType.TwelveHour,
32808
32510
  dateInitialized: false,
32809
32511
  };
32810
- 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];
32811
32513
  var onFocus = function () {
32812
32514
  setDropDownElement();
32813
32515
  setSelectorOpen(true);
@@ -32982,7 +32684,7 @@ function DateTime(_a) {
32982
32684
  _b["".concat((colors === null || colors === void 0 ? void 0 : colors.readOnlyInputBgColor) || 'bsc-bg-gray-200')] = readOnly,
32983
32685
  _b["".concat((colors === null || colors === void 0 ? void 0 : colors.inputBgColor) || 'bsc-bg-white')] = !readOnly,
32984
32686
  _b), "dark:bsc-bg-black ".concat(colors === null || colors === void 0 ? void 0 : colors.inputBorderColor, " bc-dt-input"), className);
32985
- 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 &&
32986
32688
  canShowDateSelectors &&
32987
32689
  state.dateInitialized &&
32988
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 &&