carbon-react 149.0.2 → 150.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.
@@ -1,7 +1,7 @@
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 isValid } from "date-fns/fp/isValid";
5
- export { default as parse } from "date-fns/fp/parse";
6
- export { default as parseWithOptions } from "date-fns/fp/parseWithOptions";
7
- export { default as parseISO } from "date-fns/fp/parseISO";
1
+ export { format } from "date-fns/fp/format";
2
+ export { formatISO } from "date-fns/fp/formatISO";
3
+ export { isMatch } from "date-fns/fp/isMatch";
4
+ export { isValid } from "date-fns/fp/isValid";
5
+ export { parse } from "date-fns/fp/parse";
6
+ export { parseWithOptions } from "date-fns/fp/parseWithOptions";
7
+ export { parseISO } from "date-fns/fp/parseISO";
@@ -1,9 +1,9 @@
1
1
  // Separate index.ts to export only required sub-modules from date-fns/fp
2
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 isValid } from "date-fns/fp/isValid";
7
- export { default as parse } from "date-fns/fp/parse";
8
- export { default as parseWithOptions } from "date-fns/fp/parseWithOptions";
9
- export { default as parseISO } from "date-fns/fp/parseISO";
3
+ export { format } from "date-fns/fp/format";
4
+ export { formatISO } from "date-fns/fp/formatISO";
5
+ export { isMatch } from "date-fns/fp/isMatch";
6
+ export { isValid } from "date-fns/fp/isValid";
7
+ export { parse } from "date-fns/fp/parse";
8
+ export { parseWithOptions } from "date-fns/fp/parseWithOptions";
9
+ export { parseISO } from "date-fns/fp/parseISO";
@@ -3,5 +3,5 @@ interface LocaleFormats {
3
3
  formats: string[];
4
4
  format: string;
5
5
  }
6
- declare const getFormatData: ({ code }: DateFnsLocale, dateFormatOverride?: string) => LocaleFormats;
6
+ declare const getFormatData: (locale?: Partial<Pick<DateFnsLocale, "code">>, dateFormatOverride?: string) => LocaleFormats;
7
7
  export default getFormatData;
@@ -70,9 +70,8 @@ const getTrailingChar = format => {
70
70
  const lastChar = format.split("").pop();
71
71
  return ["y", "M", "d"].includes(lastChar) ? "" : lastChar;
72
72
  };
73
- const getFormatData = ({
74
- code = "en-GB"
75
- }, dateFormatOverride) => {
73
+ const getFormatData = (locale, dateFormatOverride) => {
74
+ const code = locale?.code || "en-GB";
76
75
  if (dateFormatOverride) {
77
76
  const {
78
77
  format
@@ -40,12 +40,6 @@ export const DatePicker = ({
40
40
  const {
41
41
  weekStartsOn
42
42
  } = options || /* istanbul ignore next */{};
43
- const monthsLong = useMemo(() => Array.from({
44
- length: 12
45
- }).map((_, i) => {
46
- const month = localize?.month(i);
47
- return month[0].toUpperCase() + month.slice(1);
48
- }), [localize]);
49
43
  const weekdaysLong = useMemo(() => Array.from({
50
44
  length: 7
51
45
  }).map((_, i) => localize?.day(i)), [localize]);
@@ -156,10 +150,7 @@ export const DatePicker = ({
156
150
  disabled: getDisabledDays(minDate, maxDate),
157
151
  locale: {
158
152
  localize: {
159
- ...defaultLocale.localize,
160
- months: monthsLong,
161
- weekdaysLong,
162
- weekdaysShort
153
+ ...defaultLocale.localize
163
154
  }
164
155
  },
165
156
  selected: selectedDays,
@@ -1,4 +1,4 @@
1
- import { Matcher } from "react-day-picker";
1
+ import type { Locale, Matcher } from "react-day-picker";
2
2
  export declare function isValidLocaleDate(date: string, locale: Locale): boolean;
3
3
  export declare function parseDate(formatString?: string, valueString?: string): Date | undefined;
4
4
  export declare function isDateValid(date?: Date): boolean | undefined;
@@ -1,4 +1,4 @@
1
- import deDEDateLocale from "date-fns/locale/de";
1
+ import { de as deDEDateLocale } from "date-fns/locale/de";
2
2
  const isSingular = count => (typeof count === "string" ? parseInt(count) : count) === 1;
3
3
  const deDE = {
4
4
  locale: () => "de-DE",
@@ -1,4 +1,4 @@
1
- import enCADateLocale from "date-fns/locale/en-CA";
1
+ import { enCA as enCADateLocale } from "date-fns/locale/en-CA";
2
2
  const enCA = {
3
3
  locale: () => "en-CA",
4
4
  date: {
@@ -1,4 +1,4 @@
1
- import enGBDateLocale from "date-fns/locale/en-GB";
1
+ import { enGB as enGBDateLocale } from "date-fns/locale/en-GB";
2
2
  const isSingular = count => (typeof count === "string" ? parseInt(count) : count) === 1;
3
3
  const enGB = {
4
4
  locale: () => "en-GB",
@@ -1,4 +1,4 @@
1
- import enUSDateLocale from "date-fns/locale/en-US";
1
+ import { enUS as enUSDateLocale } from "date-fns/locale/en-US";
2
2
  const enUS = {
3
3
  locale: () => "en-US",
4
4
  date: {
@@ -1,4 +1,4 @@
1
- import esESDateLocale from "date-fns/locale/es";
1
+ import { es as esESDateLocale } from "date-fns/locale/es";
2
2
  const isSingular = count => (typeof count === "string" ? parseInt(count) : count) === 1;
3
3
  const esES = {
4
4
  locale: () => "es-ES",
@@ -1,4 +1,4 @@
1
- import frCADateLocale from "date-fns/locale/fr-CA";
1
+ import { frCA as frCADateLocale } from "date-fns/locale/fr-CA";
2
2
  const isSingular = count => (typeof count === "string" ? parseInt(count) : count) === 1;
3
3
  const frCA = {
4
4
  locale: () => "fr-CA",
@@ -1,4 +1,4 @@
1
- import frFRDateLocale from "date-fns/locale/fr";
1
+ import { fr as frFRDateLocale } from "date-fns/locale/fr";
2
2
  const isSingular = count => (typeof count === "string" ? parseInt(count) : count) === 1;
3
3
  const frFR = {
4
4
  locale: () => "fr-FR",
@@ -1,7 +1,7 @@
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 isValid } from "date-fns/fp/isValid";
5
- export { default as parse } from "date-fns/fp/parse";
6
- export { default as parseWithOptions } from "date-fns/fp/parseWithOptions";
7
- export { default as parseISO } from "date-fns/fp/parseISO";
1
+ export { format } from "date-fns/fp/format";
2
+ export { formatISO } from "date-fns/fp/formatISO";
3
+ export { isMatch } from "date-fns/fp/isMatch";
4
+ export { isValid } from "date-fns/fp/isValid";
5
+ export { parse } from "date-fns/fp/parse";
6
+ export { parseWithOptions } from "date-fns/fp/parseWithOptions";
7
+ export { parseISO } from "date-fns/fp/parseISO";
@@ -6,50 +6,49 @@ Object.defineProperty(exports, "__esModule", {
6
6
  Object.defineProperty(exports, "format", {
7
7
  enumerable: true,
8
8
  get: function () {
9
- return _format.default;
9
+ return _format.format;
10
10
  }
11
11
  });
12
12
  Object.defineProperty(exports, "formatISO", {
13
13
  enumerable: true,
14
14
  get: function () {
15
- return _formatISO.default;
15
+ return _formatISO.formatISO;
16
16
  }
17
17
  });
18
18
  Object.defineProperty(exports, "isMatch", {
19
19
  enumerable: true,
20
20
  get: function () {
21
- return _isMatch.default;
21
+ return _isMatch.isMatch;
22
22
  }
23
23
  });
24
24
  Object.defineProperty(exports, "isValid", {
25
25
  enumerable: true,
26
26
  get: function () {
27
- return _isValid.default;
27
+ return _isValid.isValid;
28
28
  }
29
29
  });
30
30
  Object.defineProperty(exports, "parse", {
31
31
  enumerable: true,
32
32
  get: function () {
33
- return _parse.default;
33
+ return _parse.parse;
34
34
  }
35
35
  });
36
36
  Object.defineProperty(exports, "parseISO", {
37
37
  enumerable: true,
38
38
  get: function () {
39
- return _parseISO.default;
39
+ return _parseISO.parseISO;
40
40
  }
41
41
  });
42
42
  Object.defineProperty(exports, "parseWithOptions", {
43
43
  enumerable: true,
44
44
  get: function () {
45
- return _parseWithOptions.default;
45
+ return _parseWithOptions.parseWithOptions;
46
46
  }
47
47
  });
48
- var _format = _interopRequireDefault(require("date-fns/fp/format"));
49
- var _formatISO = _interopRequireDefault(require("date-fns/fp/formatISO"));
50
- var _isMatch = _interopRequireDefault(require("date-fns/fp/isMatch"));
51
- var _isValid = _interopRequireDefault(require("date-fns/fp/isValid"));
52
- var _parse = _interopRequireDefault(require("date-fns/fp/parse"));
53
- var _parseWithOptions = _interopRequireDefault(require("date-fns/fp/parseWithOptions"));
54
- var _parseISO = _interopRequireDefault(require("date-fns/fp/parseISO"));
55
- function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
48
+ var _format = require("date-fns/fp/format");
49
+ var _formatISO = require("date-fns/fp/formatISO");
50
+ var _isMatch = require("date-fns/fp/isMatch");
51
+ var _isValid = require("date-fns/fp/isValid");
52
+ var _parse = require("date-fns/fp/parse");
53
+ var _parseWithOptions = require("date-fns/fp/parseWithOptions");
54
+ var _parseISO = require("date-fns/fp/parseISO");
@@ -3,5 +3,5 @@ interface LocaleFormats {
3
3
  formats: string[];
4
4
  format: string;
5
5
  }
6
- declare const getFormatData: ({ code }: DateFnsLocale, dateFormatOverride?: string) => LocaleFormats;
6
+ declare const getFormatData: (locale?: Partial<Pick<DateFnsLocale, "code">>, dateFormatOverride?: string) => LocaleFormats;
7
7
  export default getFormatData;
@@ -76,9 +76,8 @@ const getTrailingChar = format => {
76
76
  const lastChar = format.split("").pop();
77
77
  return ["y", "M", "d"].includes(lastChar) ? "" : lastChar;
78
78
  };
79
- const getFormatData = ({
80
- code = "en-GB"
81
- }, dateFormatOverride) => {
79
+ const getFormatData = (locale, dateFormatOverride) => {
80
+ const code = locale?.code || "en-GB";
82
81
  if (dateFormatOverride) {
83
82
  const {
84
83
  format
@@ -49,12 +49,6 @@ const DatePicker = ({
49
49
  const {
50
50
  weekStartsOn
51
51
  } = options || /* istanbul ignore next */{};
52
- const monthsLong = (0, _react.useMemo)(() => Array.from({
53
- length: 12
54
- }).map((_, i) => {
55
- const month = localize?.month(i);
56
- return month[0].toUpperCase() + month.slice(1);
57
- }), [localize]);
58
52
  const weekdaysLong = (0, _react.useMemo)(() => Array.from({
59
53
  length: 7
60
54
  }).map((_, i) => localize?.day(i)), [localize]);
@@ -165,10 +159,7 @@ const DatePicker = ({
165
159
  disabled: (0, _utils.getDisabledDays)(minDate, maxDate),
166
160
  locale: {
167
161
  localize: {
168
- ..._reactDayPicker.defaultLocale.localize,
169
- months: monthsLong,
170
- weekdaysLong,
171
- weekdaysShort
162
+ ..._reactDayPicker.defaultLocale.localize
172
163
  }
173
164
  },
174
165
  selected: selectedDays,
@@ -1,4 +1,4 @@
1
- import { Matcher } from "react-day-picker";
1
+ import type { Locale, Matcher } from "react-day-picker";
2
2
  export declare function isValidLocaleDate(date: string, locale: Locale): boolean;
3
3
  export declare function parseDate(formatString?: string, valueString?: string): Date | undefined;
4
4
  export declare function isDateValid(date?: Date): boolean | undefined;
@@ -4,8 +4,7 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.default = void 0;
7
- var _de = _interopRequireDefault(require("date-fns/locale/de"));
8
- function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
7
+ var _de = require("date-fns/locale/de");
9
8
  const isSingular = count => (typeof count === "string" ? parseInt(count) : count) === 1;
10
9
  const deDE = {
11
10
  locale: () => "de-DE",
@@ -37,7 +36,7 @@ const deDE = {
37
36
  visuallyHiddenHint: formattedCount => `Sie können bis zu ${formattedCount} Zeichen eingeben.`
38
37
  },
39
38
  date: {
40
- dateFnsLocale: () => _de.default,
39
+ dateFnsLocale: () => _de.de,
41
40
  ariaLabels: {
42
41
  previousMonthButton: () => "Vorheriger Monat",
43
42
  nextMonthButton: () => "Nächster Monat"
@@ -4,12 +4,11 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.default = void 0;
7
- var _enCA = _interopRequireDefault(require("date-fns/locale/en-CA"));
8
- function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
7
+ var _enCA = require("date-fns/locale/en-CA");
9
8
  const enCA = {
10
9
  locale: () => "en-CA",
11
10
  date: {
12
- dateFnsLocale: () => _enCA.default,
11
+ dateFnsLocale: () => _enCA.enCA,
13
12
  ariaLabels: {
14
13
  previousMonthButton: () => "Previous month",
15
14
  nextMonthButton: () => "Next month"
@@ -4,8 +4,7 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.default = void 0;
7
- var _enGB = _interopRequireDefault(require("date-fns/locale/en-GB"));
8
- function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
7
+ var _enGB = require("date-fns/locale/en-GB");
9
8
  const isSingular = count => (typeof count === "string" ? parseInt(count) : count) === 1;
10
9
  const enGB = {
11
10
  locale: () => "en-GB",
@@ -37,7 +36,7 @@ const enGB = {
37
36
  visuallyHiddenHint: formattedCount => `You can enter up to ${formattedCount} characters`
38
37
  },
39
38
  date: {
40
- dateFnsLocale: () => _enGB.default,
39
+ dateFnsLocale: () => _enGB.enGB,
41
40
  ariaLabels: {
42
41
  previousMonthButton: () => "Previous month",
43
42
  nextMonthButton: () => "Next month"
@@ -4,12 +4,11 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.default = void 0;
7
- var _enUS = _interopRequireDefault(require("date-fns/locale/en-US"));
8
- function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
7
+ var _enUS = require("date-fns/locale/en-US");
9
8
  const enUS = {
10
9
  locale: () => "en-US",
11
10
  date: {
12
- dateFnsLocale: () => _enUS.default,
11
+ dateFnsLocale: () => _enUS.enUS,
13
12
  ariaLabels: {
14
13
  previousMonthButton: () => "Previous month",
15
14
  nextMonthButton: () => "Next month"
@@ -4,8 +4,7 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.default = void 0;
7
- var _es = _interopRequireDefault(require("date-fns/locale/es"));
8
- function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
7
+ var _es = require("date-fns/locale/es");
9
8
  const isSingular = count => (typeof count === "string" ? parseInt(count) : count) === 1;
10
9
  const esES = {
11
10
  locale: () => "es-ES",
@@ -37,7 +36,7 @@ const esES = {
37
36
  visuallyHiddenHint: formattedCount => `Puedes introducir hasta ${formattedCount} caracteres.`
38
37
  },
39
38
  date: {
40
- dateFnsLocale: () => _es.default,
39
+ dateFnsLocale: () => _es.es,
41
40
  ariaLabels: {
42
41
  previousMonthButton: () => "Mes anterior",
43
42
  nextMonthButton: () => "Mes siguiente"
@@ -4,8 +4,7 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.default = void 0;
7
- var _frCA = _interopRequireDefault(require("date-fns/locale/fr-CA"));
8
- function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
7
+ var _frCA = require("date-fns/locale/fr-CA");
9
8
  const isSingular = count => (typeof count === "string" ? parseInt(count) : count) === 1;
10
9
  const frCA = {
11
10
  locale: () => "fr-CA",
@@ -37,7 +36,7 @@ const frCA = {
37
36
  visuallyHiddenHint: formattedCount => `vous pouvez saisir jusqu'à ${formattedCount} caractères.`
38
37
  },
39
38
  date: {
40
- dateFnsLocale: () => _frCA.default,
39
+ dateFnsLocale: () => _frCA.frCA,
41
40
  ariaLabels: {
42
41
  previousMonthButton: () => "Mois précédent",
43
42
  nextMonthButton: () => "Mois suivant"
@@ -4,8 +4,7 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.default = void 0;
7
- var _fr = _interopRequireDefault(require("date-fns/locale/fr"));
8
- function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
7
+ var _fr = require("date-fns/locale/fr");
9
8
  const isSingular = count => (typeof count === "string" ? parseInt(count) : count) === 1;
10
9
  const frFR = {
11
10
  locale: () => "fr-FR",
@@ -37,7 +36,7 @@ const frFR = {
37
36
  visuallyHiddenHint: formattedCount => `vous pouvez saisir jusqu'à ${formattedCount} caractères.`
38
37
  },
39
38
  date: {
40
- dateFnsLocale: () => _fr.default,
39
+ dateFnsLocale: () => _fr.fr,
41
40
  ariaLabels: {
42
41
  previousMonthButton: () => "Mois précédent",
43
42
  nextMonthButton: () => "Mois suivant"
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "carbon-react",
3
- "version": "149.0.2",
3
+ "version": "150.0.0",
4
4
  "description": "A library of reusable React components for easily building user interfaces.",
5
5
  "files": [
6
6
  "lib",
@@ -116,7 +116,6 @@
116
116
  "core-js": "^3.33.3",
117
117
  "css-loader": "^6.8.1",
118
118
  "cz-conventional-changelog": "^3.3.0",
119
- "date-fns-tz": "^1.3.8",
120
119
  "dayjs": "^1.11.10",
121
120
  "eslint": "^8.55.0",
122
121
  "eslint-config-airbnb": "^19.0.0",
@@ -179,7 +178,7 @@
179
178
  "chalk": "^4.1.2",
180
179
  "classnames": "~2.3.2",
181
180
  "crypto-js": "^4.2.0",
182
- "date-fns": "^2.30.0",
181
+ "date-fns": "^4.1.0",
183
182
  "immutable": "~3.8.2",
184
183
  "invariant": "^2.2.4",
185
184
  "lexical": "^0.21.0",