@alfalab/core-components-date-input 1.2.13 → 2.1.0

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 (49) hide show
  1. package/CHANGELOG.md +78 -0
  2. package/dist/Component.d.ts +16 -18
  3. package/dist/Component.js +68 -29
  4. package/dist/cssm/Component.d.ts +16 -18
  5. package/dist/cssm/Component.js +67 -28
  6. package/dist/cssm/index.js +7 -7
  7. package/dist/cssm/utils/format.d.ts +3 -1
  8. package/dist/cssm/utils/format.js +27 -3
  9. package/dist/cssm/utils/index.d.ts +0 -1
  10. package/dist/cssm/utils/index.js +5 -6
  11. package/dist/cssm/utils/native-supports.d.ts +1 -3
  12. package/dist/cssm/utils/native-supports.js +0 -4
  13. package/dist/esm/Component.d.ts +16 -18
  14. package/dist/esm/Component.js +70 -32
  15. package/dist/esm/index.css +4 -4
  16. package/dist/esm/index.js +7 -5
  17. package/dist/esm/utils/format.d.ts +3 -1
  18. package/dist/esm/utils/format.js +19 -3
  19. package/dist/esm/utils/index.d.ts +0 -1
  20. package/dist/esm/utils/index.js +5 -4
  21. package/dist/esm/utils/native-supports.d.ts +1 -3
  22. package/dist/esm/utils/native-supports.js +1 -3
  23. package/dist/index.css +4 -4
  24. package/dist/index.js +7 -7
  25. package/dist/modern/Component.d.ts +16 -18
  26. package/dist/modern/Component.js +70 -30
  27. package/dist/modern/index.css +4 -4
  28. package/dist/modern/index.js +7 -5
  29. package/dist/modern/utils/format.d.ts +3 -1
  30. package/dist/modern/utils/format.js +15 -3
  31. package/dist/modern/utils/index.d.ts +0 -1
  32. package/dist/modern/utils/index.js +5 -4
  33. package/dist/modern/utils/native-supports.d.ts +1 -3
  34. package/dist/modern/utils/native-supports.js +1 -3
  35. package/dist/utils/format.d.ts +3 -1
  36. package/dist/utils/format.js +27 -3
  37. package/dist/utils/index.d.ts +0 -1
  38. package/dist/utils/index.js +5 -6
  39. package/dist/utils/native-supports.d.ts +1 -3
  40. package/dist/utils/native-supports.js +0 -4
  41. package/package.json +5 -4
  42. package/dist/cssm/utils/date-correction-pipe.d.ts +0 -9
  43. package/dist/cssm/utils/date-correction-pipe.js +0 -59
  44. package/dist/esm/utils/date-correction-pipe.d.ts +0 -9
  45. package/dist/esm/utils/date-correction-pipe.js +0 -54
  46. package/dist/modern/utils/date-correction-pipe.d.ts +0 -9
  47. package/dist/modern/utils/date-correction-pipe.js +0 -52
  48. package/dist/utils/date-correction-pipe.d.ts +0 -9
  49. package/dist/utils/date-correction-pipe.js +0 -59
@@ -1,59 +0,0 @@
1
- 'use strict';
2
-
3
- Object.defineProperty(exports, '__esModule', { value: true });
4
-
5
- var maxValueMonth = [31, 31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31];
6
- var formatOrder = ['yyyy', 'yy', 'mm', 'dd', 'HH', 'MM', 'SS'];
7
- var mask = [/\d/, /\d/, '.', /\d/, /\d/, '.', /\d/, /\d/, /\d/, /\d/];
8
- function createAutoCorrectedDatePipe(_a, dateFormat) {
9
- var _b = _a === void 0 ? {} : _a, _c = _b.minYear, minYear = _c === void 0 ? 1800 : _c, _d = _b.maxYear, maxYear = _d === void 0 ? 2100 : _d;
10
- if (dateFormat === void 0) { dateFormat = 'dd mm yyyy'; }
11
- var dateFormatArray = dateFormat
12
- .split(/[^dmyHMS]+/)
13
- .sort(function (a, b) { return formatOrder.indexOf(a) - formatOrder.indexOf(b); });
14
- return function (conformedValue) {
15
- var indexesOfPipedChars = [];
16
- var maxValue = { dd: 31, mm: 12, yy: 99, yyyy: maxYear, HH: 23, MM: 59, SS: 59 };
17
- var minValue = { dd: 1, mm: 1, yy: 0, yyyy: minYear, HH: 0, MM: 0, SS: 0 };
18
- var conformedValueArr = conformedValue.split('');
19
- // Check first digit
20
- dateFormatArray.forEach(function (format) {
21
- var position = dateFormat.indexOf(format);
22
- var maxFirstDigit = parseInt(maxValue[format].toString().substr(0, 1), 10);
23
- if (parseInt(conformedValueArr[position], 10) > maxFirstDigit) {
24
- conformedValueArr[position + 1] = conformedValueArr[position];
25
- conformedValueArr[position] = '0';
26
- indexesOfPipedChars.push(position);
27
- }
28
- });
29
- // Check for invalid date
30
- var month = 0;
31
- var isInvalid = dateFormatArray.some(function (format) {
32
- var position = dateFormat.indexOf(format);
33
- var length = format.length;
34
- var textValue = conformedValue.substr(position, length).replace(/\D/g, '');
35
- var value = parseInt(textValue, 10);
36
- if (format === 'mm') {
37
- month = value || 0;
38
- }
39
- var maxValueForFormat = format === 'dd' ? maxValueMonth[month] : maxValue[format];
40
- if (format === 'yyyy' && (minYear !== 1 || maxYear !== 9999)) {
41
- var scopedMaxValue = parseInt(maxValue[format].toString().substring(0, textValue.length), 10);
42
- var scopedMinValue = parseInt(minValue[format].toString().substring(0, textValue.length), 10);
43
- return value < scopedMinValue || value > scopedMaxValue;
44
- }
45
- return (value > maxValueForFormat ||
46
- (textValue.length === length && value < minValue[format]));
47
- });
48
- if (isInvalid) {
49
- return false;
50
- }
51
- return {
52
- value: conformedValueArr.join(''),
53
- indexesOfPipedChars: indexesOfPipedChars,
54
- };
55
- };
56
- }
57
-
58
- exports.createAutoCorrectedDatePipe = createAutoCorrectedDatePipe;
59
- exports.mask = mask;