carbon-react 144.5.0 → 144.7.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.
@@ -3,5 +3,5 @@ interface LocaleFormats {
3
3
  formats: string[];
4
4
  format: string;
5
5
  }
6
- declare const getFormatData: ({ code }: DateFnsLocale) => LocaleFormats;
6
+ declare const getFormatData: ({ code }: DateFnsLocale, dateFormatOverride?: string) => LocaleFormats;
7
7
  export default getFormatData;
@@ -72,7 +72,31 @@ const getTrailingChar = format => {
72
72
  };
73
73
  const getFormatData = ({
74
74
  code = "en-GB"
75
- }) => {
75
+ }, dateFormatOverride) => {
76
+ if (dateFormatOverride) {
77
+ const {
78
+ format
79
+ } = getOutputFormatForLocale(code);
80
+ let formatFromLocale;
81
+ switch (code) {
82
+ case "en-CA":
83
+ case "en-US":
84
+ formatFromLocale = "MM/dd/yyyy";
85
+ break;
86
+ case "ar-EG":
87
+ case "en-ZA":
88
+ case "fr-CA":
89
+ formatFromLocale = "dd/MM/yyyy";
90
+ break;
91
+ default:
92
+ formatFromLocale = format;
93
+ }
94
+ const formatsForLocale = getInputFormatsArrayForLocale(formatFromLocale);
95
+ return {
96
+ format: dateFormatOverride,
97
+ formats: generateFormats(formatsForLocale, "/")
98
+ };
99
+ }
76
100
  if (["en-CA", "en-US"].includes(code)) {
77
101
  const format = "MM/dd/yyyy";
78
102
  const formats = getInputFormatsArrayForLocale(format);
@@ -42,6 +42,8 @@ export interface DateInputProps extends Omit<TextboxProps, "value" | "formattedV
42
42
  onPickerOpen?: () => void;
43
43
  /** Callback triggered when the picker is closed */
44
44
  onPickerClose?: () => void;
45
+ /** Date format string to be applied to the date inputs */
46
+ dateFormatOverride?: string;
45
47
  }
46
48
  export declare const DateInput: React.ForwardRefExoticComponent<DateInputProps & React.RefAttributes<HTMLInputElement>>;
47
49
  export default DateInput;
@@ -52,12 +52,13 @@ const DateInput = /*#__PURE__*/React.forwardRef(({
52
52
  const blockClose = useRef(false);
53
53
  const locale = useLocale();
54
54
  const {
55
- dateFnsLocale
55
+ dateFnsLocale,
56
+ dateFormatOverride
56
57
  } = locale.date;
57
58
  const {
58
59
  format,
59
60
  formats
60
- } = useMemo(() => getFormatData(dateFnsLocale()), [dateFnsLocale]);
61
+ } = useMemo(() => getFormatData(dateFnsLocale(), dateFormatOverride), [dateFnsLocale, dateFormatOverride]);
61
62
  const {
62
63
  inputRefMap,
63
64
  setInputRefMap
@@ -480,6 +481,7 @@ if (process.env.NODE_ENV !== "production") {
480
481
  "data-element": PropTypes.string,
481
482
  "data-role": PropTypes.string,
482
483
  "datatype": PropTypes.string,
484
+ "dateFormatOverride": PropTypes.string,
483
485
  "defaultChecked": PropTypes.bool,
484
486
  "defaultValue": PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.string), PropTypes.number, PropTypes.string]),
485
487
  "dir": PropTypes.string,
@@ -85,6 +85,8 @@ export interface DateRangeProps extends StyledDateRangeProps, MarginProps, TagPr
85
85
  required?: boolean;
86
86
  /** Flag to configure component as optional. */
87
87
  isOptional?: boolean;
88
+ /** Date format string to be applied to the date inputs */
89
+ dateFormatOverride?: string;
88
90
  }
89
91
  export declare const DateRange: {
90
92
  ({ endDateProps, id, labelsInline, name, onBlur, onChange, startDateProps, tooltipPosition, validationOnLabel, value, startRef, endRef, required, isOptional, ...rest }: DateRangeProps): React.JSX.Element;
@@ -35,11 +35,12 @@ export const DateRange = ({
35
35
  const labelsInlineWithNewValidation = validationRedesignOptIn ? false : labelsInline;
36
36
  const l = useLocale();
37
37
  const {
38
- dateFnsLocale
38
+ dateFnsLocale,
39
+ dateFormatOverride
39
40
  } = l.date;
40
41
  const {
41
42
  format
42
- } = useMemo(() => getFormatData(dateFnsLocale()), [dateFnsLocale]);
43
+ } = useMemo(() => getFormatData(dateFnsLocale(), dateFormatOverride), [dateFnsLocale, dateFormatOverride]);
43
44
  const inlineLabelWidth = 40;
44
45
  const [lastChangedDate, setLastChangedDate] = useState("");
45
46
  const computedValue = useCallback(valueString => {
@@ -1,6 +1,7 @@
1
1
  function _extends() { return _extends = Object.assign ? Object.assign.bind() : function (n) { for (var e = 1; e < arguments.length; e++) { var t = arguments[e]; for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]); } return n; }, _extends.apply(null, arguments); }
2
2
  import React, { useRef } from "react";
3
3
  import PropTypes from "prop-types";
4
+ import Typography from "../typography";
4
5
  import MessageStyle from "./message.style";
5
6
  import TypeIcon from "./__internal__/type-icon/type-icon.component";
6
7
  import MessageContent from "./__internal__/message-content/message-content.component";
@@ -47,7 +48,9 @@ const Message = /*#__PURE__*/React.forwardRef(({
47
48
  }), /*#__PURE__*/React.createElement(TypeIcon, {
48
49
  variant: variant,
49
50
  transparent: transparent
50
- }), /*#__PURE__*/React.createElement(MessageContent, {
51
+ }), /*#__PURE__*/React.createElement(Typography, {
52
+ screenReaderOnly: true
53
+ }, l.message[variant]()), /*#__PURE__*/React.createElement(MessageContent, {
51
54
  showCloseIcon: showCloseIcon,
52
55
  title: title,
53
56
  reduceLeftPadding: transparent
@@ -100,7 +100,12 @@ const deDE = {
100
100
  }
101
101
  },
102
102
  message: {
103
- closeButtonAriaLabel: () => "Schließen"
103
+ closeButtonAriaLabel: () => "Schließen",
104
+ error: () => "Fehler",
105
+ info: () => "Informationen",
106
+ success: () => "Erfolg",
107
+ warning: () => "Warnung",
108
+ neutral: () => "Informationen"
104
109
  },
105
110
  numeralDate: {
106
111
  validation: {
@@ -34,7 +34,8 @@ const enGB = {
34
34
  ariaLabels: {
35
35
  previousMonthButton: () => "Previous month",
36
36
  nextMonthButton: () => "Next month"
37
- }
37
+ },
38
+ dateFormatOverride: undefined
38
39
  },
39
40
  dialog: {
40
41
  ariaLabels: {
@@ -103,7 +104,12 @@ const enGB = {
103
104
  }
104
105
  },
105
106
  message: {
106
- closeButtonAriaLabel: () => "Close"
107
+ closeButtonAriaLabel: () => "Close",
108
+ error: () => "Error",
109
+ info: () => "Information",
110
+ success: () => "Success",
111
+ warning: () => "Warning",
112
+ neutral: () => "Information"
107
113
  },
108
114
  numeralDate: {
109
115
  validation: {
@@ -101,7 +101,12 @@ const esES = {
101
101
  }
102
102
  },
103
103
  message: {
104
- closeButtonAriaLabel: () => "Cerrar"
104
+ closeButtonAriaLabel: () => "Cerrar",
105
+ error: () => "Error",
106
+ info: () => "Información",
107
+ success: () => "Acción realizada",
108
+ warning: () => "Aviso",
109
+ neutral: () => "Información"
105
110
  },
106
111
  numeralDate: {
107
112
  validation: {
@@ -101,7 +101,12 @@ const frCA = {
101
101
  }
102
102
  },
103
103
  message: {
104
- closeButtonAriaLabel: () => "Fermer"
104
+ closeButtonAriaLabel: () => "Fermer",
105
+ error: () => "Erreur",
106
+ info: () => "Information",
107
+ success: () => "Opération réussie",
108
+ warning: () => "Avertissement",
109
+ neutral: () => "Information"
105
110
  },
106
111
  numeralDate: {
107
112
  validation: {
@@ -101,7 +101,12 @@ const frFR = {
101
101
  }
102
102
  },
103
103
  message: {
104
- closeButtonAriaLabel: () => "Fermer"
104
+ closeButtonAriaLabel: () => "Fermer",
105
+ error: () => "Erreur",
106
+ info: () => "Information",
107
+ success: () => "Action réussie",
108
+ warning: () => "Avertissement",
109
+ neutral: () => "Information"
105
110
  },
106
111
  numeralDate: {
107
112
  validation: {
@@ -34,6 +34,7 @@ interface Locale {
34
34
  previousMonthButton: () => string;
35
35
  nextMonthButton: () => string;
36
36
  };
37
+ dateFormatOverride?: string;
37
38
  };
38
39
  dialog: {
39
40
  ariaLabels: {
@@ -87,6 +88,11 @@ interface Locale {
87
88
  };
88
89
  message: {
89
90
  closeButtonAriaLabel: () => string;
91
+ error: () => string;
92
+ info: () => string;
93
+ success: () => string;
94
+ warning: () => string;
95
+ neutral: () => string;
90
96
  };
91
97
  numeralDate: {
92
98
  validation: {
@@ -3,5 +3,5 @@ interface LocaleFormats {
3
3
  formats: string[];
4
4
  format: string;
5
5
  }
6
- declare const getFormatData: ({ code }: DateFnsLocale) => LocaleFormats;
6
+ declare const getFormatData: ({ code }: DateFnsLocale, dateFormatOverride?: string) => LocaleFormats;
7
7
  export default getFormatData;
@@ -78,7 +78,31 @@ const getTrailingChar = format => {
78
78
  };
79
79
  const getFormatData = ({
80
80
  code = "en-GB"
81
- }) => {
81
+ }, dateFormatOverride) => {
82
+ if (dateFormatOverride) {
83
+ const {
84
+ format
85
+ } = getOutputFormatForLocale(code);
86
+ let formatFromLocale;
87
+ switch (code) {
88
+ case "en-CA":
89
+ case "en-US":
90
+ formatFromLocale = "MM/dd/yyyy";
91
+ break;
92
+ case "ar-EG":
93
+ case "en-ZA":
94
+ case "fr-CA":
95
+ formatFromLocale = "dd/MM/yyyy";
96
+ break;
97
+ default:
98
+ formatFromLocale = format;
99
+ }
100
+ const formatsForLocale = getInputFormatsArrayForLocale(formatFromLocale);
101
+ return {
102
+ format: dateFormatOverride,
103
+ formats: generateFormats(formatsForLocale, "/")
104
+ };
105
+ }
82
106
  if (["en-CA", "en-US"].includes(code)) {
83
107
  const format = "MM/dd/yyyy";
84
108
  const formats = getInputFormatsArrayForLocale(format);
@@ -42,6 +42,8 @@ export interface DateInputProps extends Omit<TextboxProps, "value" | "formattedV
42
42
  onPickerOpen?: () => void;
43
43
  /** Callback triggered when the picker is closed */
44
44
  onPickerClose?: () => void;
45
+ /** Date format string to be applied to the date inputs */
46
+ dateFormatOverride?: string;
45
47
  }
46
48
  export declare const DateInput: React.ForwardRefExoticComponent<DateInputProps & React.RefAttributes<HTMLInputElement>>;
47
49
  export default DateInput;
@@ -61,12 +61,13 @@ const DateInput = exports.DateInput = /*#__PURE__*/_react.default.forwardRef(({
61
61
  const blockClose = (0, _react.useRef)(false);
62
62
  const locale = (0, _useLocale.default)();
63
63
  const {
64
- dateFnsLocale
64
+ dateFnsLocale,
65
+ dateFormatOverride
65
66
  } = locale.date;
66
67
  const {
67
68
  format,
68
69
  formats
69
- } = (0, _react.useMemo)(() => (0, _dateFormats.default)(dateFnsLocale()), [dateFnsLocale]);
70
+ } = (0, _react.useMemo)(() => (0, _dateFormats.default)(dateFnsLocale(), dateFormatOverride), [dateFnsLocale, dateFormatOverride]);
70
71
  const {
71
72
  inputRefMap,
72
73
  setInputRefMap
@@ -489,6 +490,7 @@ if (process.env.NODE_ENV !== "production") {
489
490
  "data-element": _propTypes.default.string,
490
491
  "data-role": _propTypes.default.string,
491
492
  "datatype": _propTypes.default.string,
493
+ "dateFormatOverride": _propTypes.default.string,
492
494
  "defaultChecked": _propTypes.default.bool,
493
495
  "defaultValue": _propTypes.default.oneOfType([_propTypes.default.arrayOf(_propTypes.default.string), _propTypes.default.number, _propTypes.default.string]),
494
496
  "dir": _propTypes.default.string,
@@ -85,6 +85,8 @@ export interface DateRangeProps extends StyledDateRangeProps, MarginProps, TagPr
85
85
  required?: boolean;
86
86
  /** Flag to configure component as optional. */
87
87
  isOptional?: boolean;
88
+ /** Date format string to be applied to the date inputs */
89
+ dateFormatOverride?: string;
88
90
  }
89
91
  export declare const DateRange: {
90
92
  ({ endDateProps, id, labelsInline, name, onBlur, onChange, startDateProps, tooltipPosition, validationOnLabel, value, startRef, endRef, required, isOptional, ...rest }: DateRangeProps): React.JSX.Element;
@@ -44,11 +44,12 @@ const DateRange = ({
44
44
  const labelsInlineWithNewValidation = validationRedesignOptIn ? false : labelsInline;
45
45
  const l = (0, _useLocale.default)();
46
46
  const {
47
- dateFnsLocale
47
+ dateFnsLocale,
48
+ dateFormatOverride
48
49
  } = l.date;
49
50
  const {
50
51
  format
51
- } = (0, _react.useMemo)(() => (0, _dateFormats.default)(dateFnsLocale()), [dateFnsLocale]);
52
+ } = (0, _react.useMemo)(() => (0, _dateFormats.default)(dateFnsLocale(), dateFormatOverride), [dateFnsLocale, dateFormatOverride]);
52
53
  const inlineLabelWidth = 40;
53
54
  const [lastChangedDate, setLastChangedDate] = (0, _react.useState)("");
54
55
  const computedValue = (0, _react.useCallback)(valueString => {
@@ -6,6 +6,7 @@ Object.defineProperty(exports, "__esModule", {
6
6
  exports.default = exports.Message = void 0;
7
7
  var _react = _interopRequireWildcard(require("react"));
8
8
  var _propTypes = _interopRequireDefault(require("prop-types"));
9
+ var _typography = _interopRequireDefault(require("../typography"));
9
10
  var _message = _interopRequireDefault(require("./message.style"));
10
11
  var _typeIcon = _interopRequireDefault(require("./__internal__/type-icon/type-icon.component"));
11
12
  var _messageContent = _interopRequireDefault(require("./__internal__/message-content/message-content.component"));
@@ -56,7 +57,9 @@ const Message = exports.Message = /*#__PURE__*/_react.default.forwardRef(({
56
57
  }), /*#__PURE__*/_react.default.createElement(_typeIcon.default, {
57
58
  variant: variant,
58
59
  transparent: transparent
59
- }), /*#__PURE__*/_react.default.createElement(_messageContent.default, {
60
+ }), /*#__PURE__*/_react.default.createElement(_typography.default, {
61
+ screenReaderOnly: true
62
+ }, l.message[variant]()), /*#__PURE__*/_react.default.createElement(_messageContent.default, {
60
63
  showCloseIcon: showCloseIcon,
61
64
  title: title,
62
65
  reduceLeftPadding: transparent
@@ -107,7 +107,12 @@ const deDE = {
107
107
  }
108
108
  },
109
109
  message: {
110
- closeButtonAriaLabel: () => "Schließen"
110
+ closeButtonAriaLabel: () => "Schließen",
111
+ error: () => "Fehler",
112
+ info: () => "Informationen",
113
+ success: () => "Erfolg",
114
+ warning: () => "Warnung",
115
+ neutral: () => "Informationen"
111
116
  },
112
117
  numeralDate: {
113
118
  validation: {
@@ -41,7 +41,8 @@ const enGB = {
41
41
  ariaLabels: {
42
42
  previousMonthButton: () => "Previous month",
43
43
  nextMonthButton: () => "Next month"
44
- }
44
+ },
45
+ dateFormatOverride: undefined
45
46
  },
46
47
  dialog: {
47
48
  ariaLabels: {
@@ -110,7 +111,12 @@ const enGB = {
110
111
  }
111
112
  },
112
113
  message: {
113
- closeButtonAriaLabel: () => "Close"
114
+ closeButtonAriaLabel: () => "Close",
115
+ error: () => "Error",
116
+ info: () => "Information",
117
+ success: () => "Success",
118
+ warning: () => "Warning",
119
+ neutral: () => "Information"
114
120
  },
115
121
  numeralDate: {
116
122
  validation: {
@@ -108,7 +108,12 @@ const esES = {
108
108
  }
109
109
  },
110
110
  message: {
111
- closeButtonAriaLabel: () => "Cerrar"
111
+ closeButtonAriaLabel: () => "Cerrar",
112
+ error: () => "Error",
113
+ info: () => "Información",
114
+ success: () => "Acción realizada",
115
+ warning: () => "Aviso",
116
+ neutral: () => "Información"
112
117
  },
113
118
  numeralDate: {
114
119
  validation: {
@@ -108,7 +108,12 @@ const frCA = {
108
108
  }
109
109
  },
110
110
  message: {
111
- closeButtonAriaLabel: () => "Fermer"
111
+ closeButtonAriaLabel: () => "Fermer",
112
+ error: () => "Erreur",
113
+ info: () => "Information",
114
+ success: () => "Opération réussie",
115
+ warning: () => "Avertissement",
116
+ neutral: () => "Information"
112
117
  },
113
118
  numeralDate: {
114
119
  validation: {
@@ -108,7 +108,12 @@ const frFR = {
108
108
  }
109
109
  },
110
110
  message: {
111
- closeButtonAriaLabel: () => "Fermer"
111
+ closeButtonAriaLabel: () => "Fermer",
112
+ error: () => "Erreur",
113
+ info: () => "Information",
114
+ success: () => "Action réussie",
115
+ warning: () => "Avertissement",
116
+ neutral: () => "Information"
112
117
  },
113
118
  numeralDate: {
114
119
  validation: {
@@ -34,6 +34,7 @@ interface Locale {
34
34
  previousMonthButton: () => string;
35
35
  nextMonthButton: () => string;
36
36
  };
37
+ dateFormatOverride?: string;
37
38
  };
38
39
  dialog: {
39
40
  ariaLabels: {
@@ -87,6 +88,11 @@ interface Locale {
87
88
  };
88
89
  message: {
89
90
  closeButtonAriaLabel: () => string;
91
+ error: () => string;
92
+ info: () => string;
93
+ success: () => string;
94
+ warning: () => string;
95
+ neutral: () => string;
90
96
  };
91
97
  numeralDate: {
92
98
  validation: {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "carbon-react",
3
- "version": "144.5.0",
3
+ "version": "144.7.0",
4
4
  "description": "A library of reusable React components for easily building user interfaces.",
5
5
  "files": [
6
6
  "lib",