carbon-react 106.1.5 → 106.2.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.
- package/esm/components/date/__internal__/date-formats/index.js +88 -20
- package/esm/components/date/__internal__/utils.js +13 -3
- package/esm/components/date/date.component.js +13 -5
- package/esm/components/flat-table/flat-table.style.js +2 -1
- package/esm/components/typography/typography.component.js +1 -1
- package/lib/components/date/__internal__/date-formats/index.js +88 -20
- package/lib/components/date/__internal__/utils.js +14 -3
- package/lib/components/date/date.component.js +13 -5
- package/lib/components/flat-table/flat-table.style.js +2 -1
- package/lib/components/typography/typography.component.js +1 -1
- package/package.json +1 -1
|
@@ -1,39 +1,107 @@
|
|
|
1
|
-
// The order of this array is important
|
|
2
|
-
const EU_FORMATS = ["d M yyyy", "dd M yyyy", "d MM yyyy", "dd MM yyyy", "d M yy", "dd M yy", "d MM yy", "dd MM yy", "d", "d M", "dd", "d MM", "dd M", "dd MM"]; // The order of this array is important
|
|
1
|
+
// The order of this array is important, when an input value matches more than one format the last one is used
|
|
2
|
+
const EU_FORMATS = ["d M yyyy", "dd M yyyy", "d MM yyyy", "dd MM yyyy", "d M yy", "dd M yy", "d MM yy", "dd MM yy", "d", "d M", "dd", "d MM", "dd M", "dd MM"]; // The order of this array is important, when an input value matches more than one format the last one is used
|
|
3
3
|
|
|
4
|
-
const NA_FORMATS = ["M", "M d", "MM", "M dd", "MM d", "MM dd", "M d yy", "MM d yy", "M dd yy", "MM dd yy", "M d yyyy", "MM d yyyy", "M dd yyyy", "MM dd yyyy"];
|
|
4
|
+
const NA_FORMATS = ["M", "M d", "MM", "M dd", "MM d", "MM dd", "M d yy", "MM d yy", "M dd yy", "MM dd yy", "M d yyyy", "MM d yyyy", "M dd yyyy", "MM dd yyyy"]; // The order of this array is important, when an input value matches more than one format the last one is used
|
|
5
|
+
|
|
6
|
+
const CN_FORMATS = ["yyyy M", "yyyy M d", "yyyy MM d", "yyyy M dd", "yyyy MM dd", "yy M", "yy MM", "yy M d", "yy MM d", "yy M dd", "yy MM dd", "M", "M d", "MM", "M dd", "MM d", "MM dd"];
|
|
5
7
|
const SEPARATORS = ["", ".", ",", "-", "/", ":"];
|
|
8
|
+
const STANDARD_FORMAT_LENGTH = 10;
|
|
9
|
+
|
|
10
|
+
const generateFormats = (formatArray, separator, trailingChar) => {
|
|
11
|
+
const separators = SEPARATORS.includes(separator) ? SEPARATORS : [...SEPARATORS, separator];
|
|
12
|
+
return formatArray.reduce((arr, formatString) => {
|
|
13
|
+
const array = [...arr, formatString];
|
|
14
|
+
|
|
15
|
+
if (formatString.includes(" ")) {
|
|
16
|
+
separators.forEach(char => {
|
|
17
|
+
if (separator === char && trailingChar) {
|
|
18
|
+
array.push(`${formatString.replace(/ /g, char)}${trailingChar}`);
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
array.push(formatString.replace(/ /g, char));
|
|
22
|
+
});
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
return array;
|
|
26
|
+
}, []);
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
const getOutputFormatForLocale = localeCode => {
|
|
30
|
+
const formatMap = {
|
|
31
|
+
day: "dd",
|
|
32
|
+
month: "MM",
|
|
33
|
+
year: "yyyy"
|
|
34
|
+
};
|
|
35
|
+
const formatter = new Intl.DateTimeFormat(localeCode);
|
|
36
|
+
let separator;
|
|
37
|
+
const format = formatter.formatToParts(new Date()).map(({
|
|
38
|
+
type,
|
|
39
|
+
value
|
|
40
|
+
}) => {
|
|
41
|
+
if (type !== "literal") {
|
|
42
|
+
return formatMap[type];
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
if (!separator) {
|
|
46
|
+
separator = value;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
return value;
|
|
50
|
+
}).join("");
|
|
51
|
+
|
|
52
|
+
if (localeCode.startsWith("bg")) {
|
|
53
|
+
// this locale adds an additional char that has no effect on the output formatting
|
|
54
|
+
return {
|
|
55
|
+
format: format.substring(0, STANDARD_FORMAT_LENGTH),
|
|
56
|
+
separator
|
|
57
|
+
};
|
|
58
|
+
}
|
|
6
59
|
|
|
7
|
-
|
|
8
|
-
|
|
60
|
+
return {
|
|
61
|
+
format,
|
|
62
|
+
separator
|
|
63
|
+
};
|
|
64
|
+
};
|
|
9
65
|
|
|
10
|
-
|
|
11
|
-
|
|
66
|
+
const getInputFormatsArrayForLocale = format => {
|
|
67
|
+
if (format.startsWith("y")) {
|
|
68
|
+
return CN_FORMATS;
|
|
12
69
|
}
|
|
13
70
|
|
|
14
|
-
|
|
15
|
-
|
|
71
|
+
if (format.startsWith("M")) {
|
|
72
|
+
return NA_FORMATS;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
return EU_FORMATS;
|
|
76
|
+
}; // we need this to handle for formats that add extra chars at the end of the format
|
|
77
|
+
|
|
78
|
+
|
|
79
|
+
const getTrailingChar = format => {
|
|
80
|
+
const lastChar = format.split("").pop();
|
|
81
|
+
return ["y", "M", "d"].includes(lastChar) ? "" : lastChar;
|
|
82
|
+
};
|
|
16
83
|
|
|
17
84
|
const getFormatData = ({
|
|
18
85
|
code
|
|
19
86
|
}) => {
|
|
20
87
|
if (["en-CA", "en-US"].includes(code)) {
|
|
88
|
+
const format = "MM/dd/yyyy";
|
|
89
|
+
const formats = getInputFormatsArrayForLocale(format);
|
|
21
90
|
return {
|
|
22
|
-
format
|
|
23
|
-
formats: generateFormats(
|
|
24
|
-
};
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
if (code === "de") {
|
|
28
|
-
return {
|
|
29
|
-
format: "dd.MM.yyyy",
|
|
30
|
-
formats: generateFormats(EU_FORMATS)
|
|
91
|
+
format,
|
|
92
|
+
formats: generateFormats(formats, "/")
|
|
31
93
|
};
|
|
32
94
|
}
|
|
33
95
|
|
|
96
|
+
const {
|
|
97
|
+
format,
|
|
98
|
+
separator
|
|
99
|
+
} = getOutputFormatForLocale(code);
|
|
100
|
+
const outputFormat = ["fr-CA", "en-ZA", "ar-EG"].includes(code) ? "dd/MM/yyyy" : format;
|
|
101
|
+
const formatsForLocale = getInputFormatsArrayForLocale(outputFormat);
|
|
34
102
|
return {
|
|
35
|
-
format:
|
|
36
|
-
formats: generateFormats(
|
|
103
|
+
format: outputFormat,
|
|
104
|
+
formats: generateFormats(formatsForLocale, separator, getTrailingChar(format))
|
|
37
105
|
};
|
|
38
106
|
};
|
|
39
107
|
|
|
@@ -28,21 +28,31 @@ function hasMatchedFormat(formatString, valueString, fullFormat, fullValue) {
|
|
|
28
28
|
return formatString.length === valueString.length && isMatch(formatString, valueString);
|
|
29
29
|
}
|
|
30
30
|
|
|
31
|
+
const THRESHOLD_FOR_ADDITIONAL_YEARS = 69;
|
|
31
32
|
export function additionalYears(formatString, value) {
|
|
32
33
|
if (formatString.split("y").length - 1 !== 2) {
|
|
33
34
|
return [formatString, value];
|
|
34
35
|
}
|
|
35
36
|
|
|
36
|
-
|
|
37
|
-
const
|
|
37
|
+
const formatStartWithYear = formatString.startsWith("yy");
|
|
38
|
+
const yearStringStartIndex = formatStartWithYear ? 0 : value.length - 2;
|
|
39
|
+
const yearStringEndIndex = formatStartWithYear ? 2 : value.length;
|
|
40
|
+
const dayAndMonthStringStartIndex = formatStartWithYear ? yearStringEndIndex : 0;
|
|
41
|
+
const dayAndMonthStringEndIndex = formatStartWithYear ? value.length : value.length - 2;
|
|
42
|
+
let year = value.substring(yearStringStartIndex, yearStringEndIndex);
|
|
43
|
+
const dayAndMonth = value.substring(dayAndMonthStringStartIndex, dayAndMonthStringEndIndex);
|
|
38
44
|
const yearAsNumber = Number(year);
|
|
39
45
|
|
|
40
|
-
if (yearAsNumber <
|
|
46
|
+
if (yearAsNumber < THRESHOLD_FOR_ADDITIONAL_YEARS) {
|
|
41
47
|
year = String(2000 + yearAsNumber);
|
|
42
48
|
} else {
|
|
43
49
|
year = String(1900 + yearAsNumber);
|
|
44
50
|
}
|
|
45
51
|
|
|
52
|
+
if (formatStartWithYear) {
|
|
53
|
+
return [`yyyy${formatString.substring(2, formatString.length)}`, `${year}${dayAndMonth}`];
|
|
54
|
+
}
|
|
55
|
+
|
|
46
56
|
return [`${formatString.substring(0, formatString.length - 2)}yyyy`, `${dayAndMonth}${year}`];
|
|
47
57
|
}
|
|
48
58
|
|
|
@@ -72,7 +72,7 @@ const DateInput = ({
|
|
|
72
72
|
} = ev.target;
|
|
73
73
|
const [matchedFormat, matchedValue] = findMatchedFormatAndValue(ev.target.value, formats);
|
|
74
74
|
const formattedValueString = ev.type === "blur" ? formattedValue(format, selectedDays) : ev.target.value;
|
|
75
|
-
const rawValue = isDateValid(parseDate(matchedFormat, matchedValue)) ? formatToISO(matchedFormat, matchedValue) : computeInvalidRawValue(ev.target.value);
|
|
75
|
+
const rawValue = isDateValid(parseDate(matchedFormat, matchedValue)) ? formatToISO(...additionalYears(matchedFormat, matchedValue)) : computeInvalidRawValue(ev.target.value);
|
|
76
76
|
ev.target = { ...(name && {
|
|
77
77
|
name
|
|
78
78
|
}),
|
|
@@ -195,7 +195,9 @@ const DateInput = ({
|
|
|
195
195
|
return;
|
|
196
196
|
}
|
|
197
197
|
|
|
198
|
-
|
|
198
|
+
if (setInputRefMap) {
|
|
199
|
+
isBlurBlocked.current = true;
|
|
200
|
+
}
|
|
199
201
|
|
|
200
202
|
if (ev.target.type === "text" && !open) {
|
|
201
203
|
setOpen(true);
|
|
@@ -205,6 +207,11 @@ const DateInput = ({
|
|
|
205
207
|
}
|
|
206
208
|
};
|
|
207
209
|
|
|
210
|
+
const handleIconMouseDown = e => {
|
|
211
|
+
isBlurBlocked.current = true;
|
|
212
|
+
handleMouseDown(e);
|
|
213
|
+
};
|
|
214
|
+
|
|
208
215
|
const handlePickerMouseDown = () => {
|
|
209
216
|
isBlurBlocked.current = true;
|
|
210
217
|
};
|
|
@@ -247,7 +254,7 @@ const DateInput = ({
|
|
|
247
254
|
|
|
248
255
|
if (matchedFormat && matchedValue && isDateValid(parseDate(matchedFormat, matchedValue))) {
|
|
249
256
|
setSelectedDays(parseDate(...additionalYears(matchedFormat, matchedValue)));
|
|
250
|
-
} else if (checkISOFormatAndLength(value)) {
|
|
257
|
+
} else if (checkISOFormatAndLength(value) && isInitialValue.current) {
|
|
251
258
|
setSelectedDays(parseISODate(value));
|
|
252
259
|
} else {
|
|
253
260
|
setSelectedDays(undefined);
|
|
@@ -255,7 +262,7 @@ const DateInput = ({
|
|
|
255
262
|
}, [value, formats]);
|
|
256
263
|
|
|
257
264
|
const computedValue = () => {
|
|
258
|
-
if (checkISOFormatAndLength(value)) {
|
|
265
|
+
if (checkISOFormatAndLength(value) && isInitialValue.current) {
|
|
259
266
|
return formattedValue(format, parseISODate(value));
|
|
260
267
|
}
|
|
261
268
|
|
|
@@ -265,6 +272,7 @@ const DateInput = ({
|
|
|
265
272
|
const replaceSeparators = () => value.split("").map(char => char === valueSeparator ? formatSeparator : char).join("");
|
|
266
273
|
|
|
267
274
|
if (isInitialValue.current && valueSeparator !== formatSeparator && isDateValid(parseDate(format, replaceSeparators()))) {
|
|
275
|
+
isInitialValue.current = false;
|
|
268
276
|
const [matchedFormat, matchedValue] = findMatchedFormatAndValue(replaceSeparators(), formats);
|
|
269
277
|
return formattedValue(format, parseDate(...additionalYears(matchedFormat, matchedValue)));
|
|
270
278
|
}
|
|
@@ -289,7 +297,7 @@ const DateInput = ({
|
|
|
289
297
|
onKeyDown: handleKeyDown,
|
|
290
298
|
iconOnClick: handleClick,
|
|
291
299
|
onMouseDown: handleMouseDown,
|
|
292
|
-
iconOnMouseDown:
|
|
300
|
+
iconOnMouseDown: handleIconMouseDown,
|
|
293
301
|
inputIcon: "calendar",
|
|
294
302
|
labelInline: labelInline,
|
|
295
303
|
inputRef: assignInput,
|
|
@@ -75,7 +75,7 @@ const StyledFlatTable = styled.table`
|
|
|
75
75
|
${StyledFlatTableRow}:hover {
|
|
76
76
|
${StyledFlatTableCell},
|
|
77
77
|
${StyledFlatTableRowHeader},
|
|
78
|
-
${StyledFlatTableCheckbox} {
|
|
78
|
+
${StyledFlatTableCheckbox}:not(th) {
|
|
79
79
|
background-color: var(--colorsUtilityMajor025);
|
|
80
80
|
}
|
|
81
81
|
}
|
|
@@ -198,6 +198,7 @@ const StyledFlatTableFooter = styled.div`
|
|
|
198
198
|
}) => hasStickyFooter && css`
|
|
199
199
|
position: sticky;
|
|
200
200
|
bottom: 0px;
|
|
201
|
+
z-index: ${baseTheme.zIndex.overlay + 1};
|
|
201
202
|
`}
|
|
202
203
|
`;
|
|
203
204
|
export { StyledFlatTableWrapper, StyledFlatTable, StyledFlatTableFooter, StyledTableContainer };
|
|
@@ -108,7 +108,6 @@ const getWeight = variant => {
|
|
|
108
108
|
case "h1":
|
|
109
109
|
case "segment-header":
|
|
110
110
|
case "segment-header-small":
|
|
111
|
-
case "strong":
|
|
112
111
|
return "900";
|
|
113
112
|
|
|
114
113
|
case "h2":
|
|
@@ -117,6 +116,7 @@ const getWeight = variant => {
|
|
|
117
116
|
case "segment-subheader-alt":
|
|
118
117
|
case "b":
|
|
119
118
|
case "em":
|
|
119
|
+
case "strong":
|
|
120
120
|
return "700";
|
|
121
121
|
|
|
122
122
|
case "h4":
|
|
@@ -4,42 +4,110 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.default = void 0;
|
|
7
|
-
// The order of this array is important
|
|
8
|
-
const EU_FORMATS = ["d M yyyy", "dd M yyyy", "d MM yyyy", "dd MM yyyy", "d M yy", "dd M yy", "d MM yy", "dd MM yy", "d", "d M", "dd", "d MM", "dd M", "dd MM"]; // The order of this array is important
|
|
7
|
+
// The order of this array is important, when an input value matches more than one format the last one is used
|
|
8
|
+
const EU_FORMATS = ["d M yyyy", "dd M yyyy", "d MM yyyy", "dd MM yyyy", "d M yy", "dd M yy", "d MM yy", "dd MM yy", "d", "d M", "dd", "d MM", "dd M", "dd MM"]; // The order of this array is important, when an input value matches more than one format the last one is used
|
|
9
9
|
|
|
10
|
-
const NA_FORMATS = ["M", "M d", "MM", "M dd", "MM d", "MM dd", "M d yy", "MM d yy", "M dd yy", "MM dd yy", "M d yyyy", "MM d yyyy", "M dd yyyy", "MM dd yyyy"];
|
|
10
|
+
const NA_FORMATS = ["M", "M d", "MM", "M dd", "MM d", "MM dd", "M d yy", "MM d yy", "M dd yy", "MM dd yy", "M d yyyy", "MM d yyyy", "M dd yyyy", "MM dd yyyy"]; // The order of this array is important, when an input value matches more than one format the last one is used
|
|
11
|
+
|
|
12
|
+
const CN_FORMATS = ["yyyy M", "yyyy M d", "yyyy MM d", "yyyy M dd", "yyyy MM dd", "yy M", "yy MM", "yy M d", "yy MM d", "yy M dd", "yy MM dd", "M", "M d", "MM", "M dd", "MM d", "MM dd"];
|
|
11
13
|
const SEPARATORS = ["", ".", ",", "-", "/", ":"];
|
|
14
|
+
const STANDARD_FORMAT_LENGTH = 10;
|
|
15
|
+
|
|
16
|
+
const generateFormats = (formatArray, separator, trailingChar) => {
|
|
17
|
+
const separators = SEPARATORS.includes(separator) ? SEPARATORS : [...SEPARATORS, separator];
|
|
18
|
+
return formatArray.reduce((arr, formatString) => {
|
|
19
|
+
const array = [...arr, formatString];
|
|
20
|
+
|
|
21
|
+
if (formatString.includes(" ")) {
|
|
22
|
+
separators.forEach(char => {
|
|
23
|
+
if (separator === char && trailingChar) {
|
|
24
|
+
array.push(`${formatString.replace(/ /g, char)}${trailingChar}`);
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
array.push(formatString.replace(/ /g, char));
|
|
28
|
+
});
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
return array;
|
|
32
|
+
}, []);
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
const getOutputFormatForLocale = localeCode => {
|
|
36
|
+
const formatMap = {
|
|
37
|
+
day: "dd",
|
|
38
|
+
month: "MM",
|
|
39
|
+
year: "yyyy"
|
|
40
|
+
};
|
|
41
|
+
const formatter = new Intl.DateTimeFormat(localeCode);
|
|
42
|
+
let separator;
|
|
43
|
+
const format = formatter.formatToParts(new Date()).map(({
|
|
44
|
+
type,
|
|
45
|
+
value
|
|
46
|
+
}) => {
|
|
47
|
+
if (type !== "literal") {
|
|
48
|
+
return formatMap[type];
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
if (!separator) {
|
|
52
|
+
separator = value;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
return value;
|
|
56
|
+
}).join("");
|
|
57
|
+
|
|
58
|
+
if (localeCode.startsWith("bg")) {
|
|
59
|
+
// this locale adds an additional char that has no effect on the output formatting
|
|
60
|
+
return {
|
|
61
|
+
format: format.substring(0, STANDARD_FORMAT_LENGTH),
|
|
62
|
+
separator
|
|
63
|
+
};
|
|
64
|
+
}
|
|
12
65
|
|
|
13
|
-
|
|
14
|
-
|
|
66
|
+
return {
|
|
67
|
+
format,
|
|
68
|
+
separator
|
|
69
|
+
};
|
|
70
|
+
};
|
|
15
71
|
|
|
16
|
-
|
|
17
|
-
|
|
72
|
+
const getInputFormatsArrayForLocale = format => {
|
|
73
|
+
if (format.startsWith("y")) {
|
|
74
|
+
return CN_FORMATS;
|
|
18
75
|
}
|
|
19
76
|
|
|
20
|
-
|
|
21
|
-
|
|
77
|
+
if (format.startsWith("M")) {
|
|
78
|
+
return NA_FORMATS;
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
return EU_FORMATS;
|
|
82
|
+
}; // we need this to handle for formats that add extra chars at the end of the format
|
|
83
|
+
|
|
84
|
+
|
|
85
|
+
const getTrailingChar = format => {
|
|
86
|
+
const lastChar = format.split("").pop();
|
|
87
|
+
return ["y", "M", "d"].includes(lastChar) ? "" : lastChar;
|
|
88
|
+
};
|
|
22
89
|
|
|
23
90
|
const getFormatData = ({
|
|
24
91
|
code
|
|
25
92
|
}) => {
|
|
26
93
|
if (["en-CA", "en-US"].includes(code)) {
|
|
94
|
+
const format = "MM/dd/yyyy";
|
|
95
|
+
const formats = getInputFormatsArrayForLocale(format);
|
|
27
96
|
return {
|
|
28
|
-
format
|
|
29
|
-
formats: generateFormats(
|
|
30
|
-
};
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
if (code === "de") {
|
|
34
|
-
return {
|
|
35
|
-
format: "dd.MM.yyyy",
|
|
36
|
-
formats: generateFormats(EU_FORMATS)
|
|
97
|
+
format,
|
|
98
|
+
formats: generateFormats(formats, "/")
|
|
37
99
|
};
|
|
38
100
|
}
|
|
39
101
|
|
|
102
|
+
const {
|
|
103
|
+
format,
|
|
104
|
+
separator
|
|
105
|
+
} = getOutputFormatForLocale(code);
|
|
106
|
+
const outputFormat = ["fr-CA", "en-ZA", "ar-EG"].includes(code) ? "dd/MM/yyyy" : format;
|
|
107
|
+
const formatsForLocale = getInputFormatsArrayForLocale(outputFormat);
|
|
40
108
|
return {
|
|
41
|
-
format:
|
|
42
|
-
formats: generateFormats(
|
|
109
|
+
format: outputFormat,
|
|
110
|
+
formats: generateFormats(formatsForLocale, separator, getTrailingChar(format))
|
|
43
111
|
};
|
|
44
112
|
};
|
|
45
113
|
|
|
@@ -48,21 +48,32 @@ function hasMatchedFormat(formatString, valueString, fullFormat, fullValue) {
|
|
|
48
48
|
return formatString.length === valueString.length && (0, _fp.isMatch)(formatString, valueString);
|
|
49
49
|
}
|
|
50
50
|
|
|
51
|
+
const THRESHOLD_FOR_ADDITIONAL_YEARS = 69;
|
|
52
|
+
|
|
51
53
|
function additionalYears(formatString, value) {
|
|
52
54
|
if (formatString.split("y").length - 1 !== 2) {
|
|
53
55
|
return [formatString, value];
|
|
54
56
|
}
|
|
55
57
|
|
|
56
|
-
|
|
57
|
-
const
|
|
58
|
+
const formatStartWithYear = formatString.startsWith("yy");
|
|
59
|
+
const yearStringStartIndex = formatStartWithYear ? 0 : value.length - 2;
|
|
60
|
+
const yearStringEndIndex = formatStartWithYear ? 2 : value.length;
|
|
61
|
+
const dayAndMonthStringStartIndex = formatStartWithYear ? yearStringEndIndex : 0;
|
|
62
|
+
const dayAndMonthStringEndIndex = formatStartWithYear ? value.length : value.length - 2;
|
|
63
|
+
let year = value.substring(yearStringStartIndex, yearStringEndIndex);
|
|
64
|
+
const dayAndMonth = value.substring(dayAndMonthStringStartIndex, dayAndMonthStringEndIndex);
|
|
58
65
|
const yearAsNumber = Number(year);
|
|
59
66
|
|
|
60
|
-
if (yearAsNumber <
|
|
67
|
+
if (yearAsNumber < THRESHOLD_FOR_ADDITIONAL_YEARS) {
|
|
61
68
|
year = String(2000 + yearAsNumber);
|
|
62
69
|
} else {
|
|
63
70
|
year = String(1900 + yearAsNumber);
|
|
64
71
|
}
|
|
65
72
|
|
|
73
|
+
if (formatStartWithYear) {
|
|
74
|
+
return [`yyyy${formatString.substring(2, formatString.length)}`, `${year}${dayAndMonth}`];
|
|
75
|
+
}
|
|
76
|
+
|
|
66
77
|
return [`${formatString.substring(0, formatString.length - 2)}yyyy`, `${dayAndMonth}${year}`];
|
|
67
78
|
}
|
|
68
79
|
|
|
@@ -97,7 +97,7 @@ const DateInput = ({
|
|
|
97
97
|
} = ev.target;
|
|
98
98
|
const [matchedFormat, matchedValue] = (0, _utils.findMatchedFormatAndValue)(ev.target.value, formats);
|
|
99
99
|
const formattedValueString = ev.type === "blur" ? (0, _utils.formattedValue)(format, selectedDays) : ev.target.value;
|
|
100
|
-
const rawValue = (0, _utils.isDateValid)((0, _utils.parseDate)(matchedFormat, matchedValue)) ? (0, _utils.formatToISO)(matchedFormat, matchedValue) : computeInvalidRawValue(ev.target.value);
|
|
100
|
+
const rawValue = (0, _utils.isDateValid)((0, _utils.parseDate)(matchedFormat, matchedValue)) ? (0, _utils.formatToISO)(...(0, _utils.additionalYears)(matchedFormat, matchedValue)) : computeInvalidRawValue(ev.target.value);
|
|
101
101
|
ev.target = { ...(name && {
|
|
102
102
|
name
|
|
103
103
|
}),
|
|
@@ -220,7 +220,9 @@ const DateInput = ({
|
|
|
220
220
|
return;
|
|
221
221
|
}
|
|
222
222
|
|
|
223
|
-
|
|
223
|
+
if (setInputRefMap) {
|
|
224
|
+
isBlurBlocked.current = true;
|
|
225
|
+
}
|
|
224
226
|
|
|
225
227
|
if (ev.target.type === "text" && !open) {
|
|
226
228
|
setOpen(true);
|
|
@@ -230,6 +232,11 @@ const DateInput = ({
|
|
|
230
232
|
}
|
|
231
233
|
};
|
|
232
234
|
|
|
235
|
+
const handleIconMouseDown = e => {
|
|
236
|
+
isBlurBlocked.current = true;
|
|
237
|
+
handleMouseDown(e);
|
|
238
|
+
};
|
|
239
|
+
|
|
233
240
|
const handlePickerMouseDown = () => {
|
|
234
241
|
isBlurBlocked.current = true;
|
|
235
242
|
};
|
|
@@ -272,7 +279,7 @@ const DateInput = ({
|
|
|
272
279
|
|
|
273
280
|
if (matchedFormat && matchedValue && (0, _utils.isDateValid)((0, _utils.parseDate)(matchedFormat, matchedValue))) {
|
|
274
281
|
setSelectedDays((0, _utils.parseDate)(...(0, _utils.additionalYears)(matchedFormat, matchedValue)));
|
|
275
|
-
} else if ((0, _utils.checkISOFormatAndLength)(value)) {
|
|
282
|
+
} else if ((0, _utils.checkISOFormatAndLength)(value) && isInitialValue.current) {
|
|
276
283
|
setSelectedDays((0, _utils.parseISODate)(value));
|
|
277
284
|
} else {
|
|
278
285
|
setSelectedDays(undefined);
|
|
@@ -280,7 +287,7 @@ const DateInput = ({
|
|
|
280
287
|
}, [value, formats]);
|
|
281
288
|
|
|
282
289
|
const computedValue = () => {
|
|
283
|
-
if ((0, _utils.checkISOFormatAndLength)(value)) {
|
|
290
|
+
if ((0, _utils.checkISOFormatAndLength)(value) && isInitialValue.current) {
|
|
284
291
|
return (0, _utils.formattedValue)(format, (0, _utils.parseISODate)(value));
|
|
285
292
|
}
|
|
286
293
|
|
|
@@ -290,6 +297,7 @@ const DateInput = ({
|
|
|
290
297
|
const replaceSeparators = () => value.split("").map(char => char === valueSeparator ? formatSeparator : char).join("");
|
|
291
298
|
|
|
292
299
|
if (isInitialValue.current && valueSeparator !== formatSeparator && (0, _utils.isDateValid)((0, _utils.parseDate)(format, replaceSeparators()))) {
|
|
300
|
+
isInitialValue.current = false;
|
|
293
301
|
const [matchedFormat, matchedValue] = (0, _utils.findMatchedFormatAndValue)(replaceSeparators(), formats);
|
|
294
302
|
return (0, _utils.formattedValue)(format, (0, _utils.parseDate)(...(0, _utils.additionalYears)(matchedFormat, matchedValue)));
|
|
295
303
|
}
|
|
@@ -314,7 +322,7 @@ const DateInput = ({
|
|
|
314
322
|
onKeyDown: handleKeyDown,
|
|
315
323
|
iconOnClick: handleClick,
|
|
316
324
|
onMouseDown: handleMouseDown,
|
|
317
|
-
iconOnMouseDown:
|
|
325
|
+
iconOnMouseDown: handleIconMouseDown,
|
|
318
326
|
inputIcon: "calendar",
|
|
319
327
|
labelInline: labelInline,
|
|
320
328
|
inputRef: assignInput,
|
|
@@ -99,7 +99,7 @@ const StyledFlatTable = _styledComponents.default.table`
|
|
|
99
99
|
${_flatTableRow.default}:hover {
|
|
100
100
|
${_flatTableCell.StyledFlatTableCell},
|
|
101
101
|
${_flatTableRowHeader.StyledFlatTableRowHeader},
|
|
102
|
-
${_flatTableCheckbox.default} {
|
|
102
|
+
${_flatTableCheckbox.default}:not(th) {
|
|
103
103
|
background-color: var(--colorsUtilityMajor025);
|
|
104
104
|
}
|
|
105
105
|
}
|
|
@@ -224,6 +224,7 @@ const StyledFlatTableFooter = _styledComponents.default.div`
|
|
|
224
224
|
}) => hasStickyFooter && (0, _styledComponents.css)`
|
|
225
225
|
position: sticky;
|
|
226
226
|
bottom: 0px;
|
|
227
|
+
z-index: ${_themes.baseTheme.zIndex.overlay + 1};
|
|
227
228
|
`}
|
|
228
229
|
`;
|
|
229
230
|
exports.StyledFlatTableFooter = StyledFlatTableFooter;
|
|
@@ -126,7 +126,6 @@ const getWeight = variant => {
|
|
|
126
126
|
case "h1":
|
|
127
127
|
case "segment-header":
|
|
128
128
|
case "segment-header-small":
|
|
129
|
-
case "strong":
|
|
130
129
|
return "900";
|
|
131
130
|
|
|
132
131
|
case "h2":
|
|
@@ -135,6 +134,7 @@ const getWeight = variant => {
|
|
|
135
134
|
case "segment-subheader-alt":
|
|
136
135
|
case "b":
|
|
137
136
|
case "em":
|
|
137
|
+
case "strong":
|
|
138
138
|
return "700";
|
|
139
139
|
|
|
140
140
|
case "h4":
|