carbon-react 133.2.0 → 134.0.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-fns-fp/index.d.ts +5 -0
- package/esm/components/date/__internal__/date-fns-fp/index.js +7 -0
- package/esm/components/date/__internal__/utils.js +1 -1
- package/esm/locales/__internal__/es-es.js +1 -1
- package/esm/locales/en-gb.js +1 -1
- package/lib/components/date/__internal__/date-fns-fp/index.d.ts +5 -0
- package/lib/components/date/__internal__/date-fns-fp/index.js +41 -0
- package/lib/components/date/__internal__/date-fns-fp/package.json +6 -0
- package/lib/components/date/__internal__/utils.js +7 -7
- package/lib/locales/__internal__/es-es.js +3 -2
- package/lib/locales/en-gb.js +3 -2
- package/package.json +1 -1
- package/esm/locales/date-fns-locales/index.d.ts +0 -1
- package/esm/locales/date-fns-locales/index.js +0 -1
- package/lib/locales/date-fns-locales/index.d.ts +0 -1
- package/lib/locales/date-fns-locales/index.js +0 -16
- package/lib/locales/date-fns-locales/package.json +0 -6
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export { default as format } from "date-fns/fp/format";
|
|
2
|
+
export { default as formatISO } from "date-fns/fp/formatISO";
|
|
3
|
+
export { default as isMatch } from "date-fns/fp/isMatch";
|
|
4
|
+
export { default as parse } from "date-fns/fp/parse";
|
|
5
|
+
export { default as parseISO } from "date-fns/fp/parseISO";
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
// Separate index.ts to export only required sub-modules from date-fns/fp
|
|
2
|
+
// import { format, formatISO, isMatch, parse, parseISO } from "date-fns/fp" adds extra 300kb to bundle size.
|
|
3
|
+
export { default as format } from "date-fns/fp/format";
|
|
4
|
+
export { default as formatISO } from "date-fns/fp/formatISO";
|
|
5
|
+
export { default as isMatch } from "date-fns/fp/isMatch";
|
|
6
|
+
export { default as parse } from "date-fns/fp/parse";
|
|
7
|
+
export { default as parseISO } from "date-fns/fp/parseISO";
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { format, formatISO, isMatch, parse, parseISO } from "date-fns
|
|
1
|
+
import { format, formatISO, isMatch, parse, parseISO } from "./date-fns-fp";
|
|
2
2
|
const DATE_STRING_LENGTH = 10;
|
|
3
3
|
const THRESHOLD_FOR_ADDITIONAL_YEARS = 69;
|
|
4
4
|
export function parseDate(formatString, valueString) {
|
package/esm/locales/en-gb.js
CHANGED
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export { default as format } from "date-fns/fp/format";
|
|
2
|
+
export { default as formatISO } from "date-fns/fp/formatISO";
|
|
3
|
+
export { default as isMatch } from "date-fns/fp/isMatch";
|
|
4
|
+
export { default as parse } from "date-fns/fp/parse";
|
|
5
|
+
export { default as parseISO } from "date-fns/fp/parseISO";
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
Object.defineProperty(exports, "format", {
|
|
7
|
+
enumerable: true,
|
|
8
|
+
get: function () {
|
|
9
|
+
return _format.default;
|
|
10
|
+
}
|
|
11
|
+
});
|
|
12
|
+
Object.defineProperty(exports, "formatISO", {
|
|
13
|
+
enumerable: true,
|
|
14
|
+
get: function () {
|
|
15
|
+
return _formatISO.default;
|
|
16
|
+
}
|
|
17
|
+
});
|
|
18
|
+
Object.defineProperty(exports, "isMatch", {
|
|
19
|
+
enumerable: true,
|
|
20
|
+
get: function () {
|
|
21
|
+
return _isMatch.default;
|
|
22
|
+
}
|
|
23
|
+
});
|
|
24
|
+
Object.defineProperty(exports, "parse", {
|
|
25
|
+
enumerable: true,
|
|
26
|
+
get: function () {
|
|
27
|
+
return _parse.default;
|
|
28
|
+
}
|
|
29
|
+
});
|
|
30
|
+
Object.defineProperty(exports, "parseISO", {
|
|
31
|
+
enumerable: true,
|
|
32
|
+
get: function () {
|
|
33
|
+
return _parseISO.default;
|
|
34
|
+
}
|
|
35
|
+
});
|
|
36
|
+
var _format = _interopRequireDefault(require("date-fns/fp/format"));
|
|
37
|
+
var _formatISO = _interopRequireDefault(require("date-fns/fp/formatISO"));
|
|
38
|
+
var _isMatch = _interopRequireDefault(require("date-fns/fp/isMatch"));
|
|
39
|
+
var _parse = _interopRequireDefault(require("date-fns/fp/parse"));
|
|
40
|
+
var _parseISO = _interopRequireDefault(require("date-fns/fp/parseISO"));
|
|
41
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
@@ -13,12 +13,12 @@ exports.getSeparator = void 0;
|
|
|
13
13
|
exports.isDateValid = isDateValid;
|
|
14
14
|
exports.parseDate = parseDate;
|
|
15
15
|
exports.parseISODate = parseISODate;
|
|
16
|
-
var
|
|
16
|
+
var _dateFnsFp = require("./date-fns-fp");
|
|
17
17
|
const DATE_STRING_LENGTH = 10;
|
|
18
18
|
const THRESHOLD_FOR_ADDITIONAL_YEARS = 69;
|
|
19
19
|
function parseDate(formatString, valueString) {
|
|
20
20
|
if (!valueString || !formatString) return undefined;
|
|
21
|
-
return (0,
|
|
21
|
+
return (0, _dateFnsFp.parse)(new Date(), formatString, valueString);
|
|
22
22
|
}
|
|
23
23
|
function isDateValid(date) {
|
|
24
24
|
return date && date.toString() !== "Invalid Date";
|
|
@@ -28,18 +28,18 @@ function formatToISO(formatString, valueString) {
|
|
|
28
28
|
if (!dateValue || !isDateValid(dateValue)) {
|
|
29
29
|
return null;
|
|
30
30
|
}
|
|
31
|
-
return (0,
|
|
31
|
+
return (0, _dateFnsFp.formatISO)(dateValue).split("T")[0];
|
|
32
32
|
}
|
|
33
33
|
function formattedValue(formatString, value) {
|
|
34
34
|
if (!value) return "";
|
|
35
|
-
return (0,
|
|
35
|
+
return (0, _dateFnsFp.format)(formatString, value);
|
|
36
36
|
}
|
|
37
37
|
function hasMatchedFormat(formatString, valueString, fullFormat, fullValue) {
|
|
38
38
|
if (formatString.includes("d")) {
|
|
39
|
-
return formatString.length === valueString.length && (0,
|
|
39
|
+
return formatString.length === valueString.length && (0, _dateFnsFp.isMatch)(fullFormat.join("."), fullValue.join(".")) // need to check day value with month value
|
|
40
40
|
;
|
|
41
41
|
}
|
|
42
|
-
return formatString.length === valueString.length && (0,
|
|
42
|
+
return formatString.length === valueString.length && (0, _dateFnsFp.isMatch)(formatString, valueString);
|
|
43
43
|
}
|
|
44
44
|
function additionalYears(formatString, value) {
|
|
45
45
|
if (formatString.split("y").length - 1 !== 2) {
|
|
@@ -123,7 +123,7 @@ function findMatchedFormatAndValue(valueString, formats) {
|
|
|
123
123
|
return matchedFormatAndValue;
|
|
124
124
|
}
|
|
125
125
|
function parseISODate(value) {
|
|
126
|
-
return (0,
|
|
126
|
+
return (0, _dateFnsFp.parseISO)(value);
|
|
127
127
|
}
|
|
128
128
|
function isValidISODate(dateString) {
|
|
129
129
|
return parseISODate(dateString).toString() !== "Invalid Date";
|
|
@@ -4,7 +4,8 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.default = void 0;
|
|
7
|
-
var
|
|
7
|
+
var _es = _interopRequireDefault(require("date-fns/locale/es"));
|
|
8
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
8
9
|
const isSingular = count => (typeof count === "string" ? parseInt(count) : count) === 1;
|
|
9
10
|
const esES = {
|
|
10
11
|
locale: () => "es-ES",
|
|
@@ -36,7 +37,7 @@ const esES = {
|
|
|
36
37
|
visuallyHiddenHint: formattedCount => `Puede introducir hasta ${formattedCount} caracteres`
|
|
37
38
|
},
|
|
38
39
|
date: {
|
|
39
|
-
dateFnsLocale: () =>
|
|
40
|
+
dateFnsLocale: () => _es.default,
|
|
40
41
|
ariaLabels: {
|
|
41
42
|
previousMonthButton: () => "Mes anterior",
|
|
42
43
|
nextMonthButton: () => "Próximo mes"
|
package/lib/locales/en-gb.js
CHANGED
|
@@ -4,7 +4,8 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.default = void 0;
|
|
7
|
-
var
|
|
7
|
+
var _enGB = _interopRequireDefault(require("date-fns/locale/en-GB"));
|
|
8
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
8
9
|
const isSingular = count => (typeof count === "string" ? parseInt(count) : count) === 1;
|
|
9
10
|
const enGB = {
|
|
10
11
|
locale: () => "en-GB",
|
|
@@ -36,7 +37,7 @@ const enGB = {
|
|
|
36
37
|
visuallyHiddenHint: formattedCount => `You can enter up to ${formattedCount} characters`
|
|
37
38
|
},
|
|
38
39
|
date: {
|
|
39
|
-
dateFnsLocale: () =>
|
|
40
|
+
dateFnsLocale: () => _enGB.default,
|
|
40
41
|
ariaLabels: {
|
|
41
42
|
previousMonthButton: () => "Previous month",
|
|
42
43
|
nextMonthButton: () => "Next month"
|
package/package.json
CHANGED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from "date-fns/locale";
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from "date-fns/locale";
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from "date-fns/locale";
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
var _locale = require("date-fns/locale");
|
|
7
|
-
Object.keys(_locale).forEach(function (key) {
|
|
8
|
-
if (key === "default" || key === "__esModule") return;
|
|
9
|
-
if (key in exports && exports[key] === _locale[key]) return;
|
|
10
|
-
Object.defineProperty(exports, key, {
|
|
11
|
-
enumerable: true,
|
|
12
|
-
get: function () {
|
|
13
|
-
return _locale[key];
|
|
14
|
-
}
|
|
15
|
-
});
|
|
16
|
-
});
|