carbon-react 124.4.0 → 124.5.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
1
  import React from "react";
2
2
  import { MarginProps } from "styled-system";
3
3
  import { ValidationProps } from "../../__internal__/validations";
4
- export declare const ALLOWED_DATE_FORMATS: readonly [readonly ["dd", "mm", "yyyy"], readonly ["mm", "dd", "yyyy"], readonly ["dd", "mm"], readonly ["mm", "dd"], readonly ["mm", "yyyy"]];
4
+ export declare const ALLOWED_DATE_FORMATS: readonly [readonly ["dd", "mm", "yyyy"], readonly ["mm", "dd", "yyyy"], readonly ["yyyy", "mm", "dd"], readonly ["dd", "mm"], readonly ["mm", "dd"], readonly ["mm", "yyyy"]];
5
5
  export interface DayMonthDate {
6
6
  dd: string;
7
7
  mm: string;
@@ -6,7 +6,9 @@ import { filterStyledSystemMarginProps } from "../../style/utils";
6
6
  import Events from "../../__internal__/utils/helpers/events";
7
7
  import { StyledNumeralDate, StyledDateField } from "./numeral-date.style";
8
8
  import Textbox from "../textbox";
9
- import { StyledHintText } from "../textbox/textbox.style";
9
+ import Box from "../box";
10
+ import Typography from "../typography";
11
+ import { ErrorBorder, StyledHintText } from "../textbox/textbox.style";
10
12
  import ValidationMessage from "../../__internal__/validation-message";
11
13
  import guid from "../../__internal__/utils/helpers/guid";
12
14
  import useLocale from "../../hooks/__internal__/useLocale";
@@ -18,8 +20,8 @@ import NumeralDateContext from "./numeral-date-context";
18
20
  import FormSpacingProvider from "../../__internal__/form-spacing-provider";
19
21
  import Logger from "../../__internal__/utils/logger";
20
22
  let deprecateUncontrolledWarnTriggered = false;
21
- export const ALLOWED_DATE_FORMATS = [["dd", "mm", "yyyy"], ["mm", "dd", "yyyy"], ["dd", "mm"], ["mm", "dd"], ["mm", "yyyy"]];
22
- const incorrectDateFormatMessage = "Forbidden prop dateFormat supplied to NumeralDate. " + "Only one of these date formats is allowed: " + "['dd', 'mm', 'yyyy'], " + "['mm', 'dd', 'yyyy'], " + "['dd', 'mm'], " + "['mm', 'dd'], " + "['mm', 'yyyy']";
23
+ export const ALLOWED_DATE_FORMATS = [["dd", "mm", "yyyy"], ["mm", "dd", "yyyy"], ["yyyy", "mm", "dd"], ["dd", "mm"], ["mm", "dd"], ["mm", "yyyy"]];
24
+ const incorrectDateFormatMessage = "Forbidden prop dateFormat supplied to NumeralDate. " + "Only one of these date formats is allowed: " + "['dd', 'mm', 'yyyy'], " + "['mm', 'dd', 'yyyy'], " + "['yyyy', 'mm', 'dd'], " + "['dd', 'mm'], " + "['mm', 'dd'], " + "['mm', 'yyyy']";
23
25
  const isDayValid = day => day ? +day > 0 && +day < 32 : true;
24
26
  const isMonthValid = month => month ? +month > 0 && +month < 13 : true;
25
27
  const isYearValid = year => year ? +year > 1799 && +year < 2201 : true;
@@ -28,6 +30,16 @@ const validations = {
28
30
  mm: isMonthValid,
29
31
  yyyy: isYearValid
30
32
  };
33
+ const getDateLabel = (datePart, locale) => {
34
+ switch (datePart) {
35
+ case "mm":
36
+ return locale.numeralDate.labels.month();
37
+ case "yyyy":
38
+ return locale.numeralDate.labels.year();
39
+ default:
40
+ return locale.numeralDate.labels.day();
41
+ }
42
+ };
31
43
  export const NumeralDate = ({
32
44
  dateFormat = ["dd", "mm", "yyyy"],
33
45
  defaultValue,
@@ -64,7 +76,7 @@ export const NumeralDate = ({
64
76
  yearRef,
65
77
  ...rest
66
78
  }) => {
67
- const l = useLocale();
79
+ const locale = useLocale();
68
80
  const {
69
81
  validationRedesignOptIn
70
82
  } = useContext(NewValidationContext);
@@ -74,6 +86,7 @@ export const NumeralDate = ({
74
86
  const isControlled = useRef(value !== undefined);
75
87
  const initialValue = isControlled.current ? value : defaultValue;
76
88
  const refs = useRef(dateFormat.map(() => null));
89
+ const labelIds = useRef([guid(), guid(), guid()]);
77
90
  const [internalMessages, setInternalMessages] = useState({
78
91
  ...Object.fromEntries(dateFormat.map(datePart => [datePart, ""]))
79
92
  });
@@ -87,9 +100,9 @@ export const NumeralDate = ({
87
100
  !(isControlled.current === (value !== undefined)) ? process.env.NODE_ENV !== "production" ? invariant(false, modeSwitchedMessage) : invariant(false) : void 0;
88
101
  }, [value]);
89
102
  const validationMessages = {
90
- dd: l.numeralDate.validation.day(),
91
- mm: l.numeralDate.validation.month(),
92
- yyyy: l.numeralDate.validation.year()
103
+ dd: locale.numeralDate.validation.day(),
104
+ mm: locale.numeralDate.validation.month(),
105
+ yyyy: locale.numeralDate.validation.year()
93
106
  };
94
107
  const [dateValue, setDateValue] = useState({
95
108
  ...(initialValue || Object.fromEntries(dateFormat.map(datePart => [datePart, ""])))
@@ -101,7 +114,7 @@ export const NumeralDate = ({
101
114
  value: newValue
102
115
  }
103
116
  });
104
- const onKeyPress = event => {
117
+ const onKeyDown = event => {
105
118
  const isValidKey = Events.isNumberKey(event) || Events.isTabKey(event) || event.key === "Delete" || event.key === "Backspace";
106
119
  if (!isValidKey) {
107
120
  event.preventDefault();
@@ -166,24 +179,27 @@ export const NumeralDate = ({
166
179
  labelInline: labelInline,
167
180
  labelWidth: labelWidth,
168
181
  labelAlign: labelAlign,
169
- labelHelp: labelHelp,
182
+ labelHelp: !validationRedesignOptIn && labelHelp,
170
183
  labelSpacing: labelSpacing,
171
184
  fieldHelp: fieldHelp,
172
185
  adaptiveLabelBreakpoint: adaptiveLabelBreakpoint,
173
186
  isRequired: required,
174
187
  validationRedesignOptIn: validationRedesignOptIn
175
- }, filterStyledSystemMarginProps(rest)), validationRedesignOptIn && labelHelp && /*#__PURE__*/React.createElement(StyledHintText, null, labelHelp), validationRedesignOptIn && /*#__PURE__*/React.createElement(ValidationMessage, {
188
+ }, filterStyledSystemMarginProps(rest)), validationRedesignOptIn && labelHelp && /*#__PURE__*/React.createElement(StyledHintText, null, labelHelp), /*#__PURE__*/React.createElement(Box, {
189
+ position: "relative"
190
+ }, validationRedesignOptIn && /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(ValidationMessage, {
176
191
  error: internalError,
177
192
  warning: internalWarning
178
- }), /*#__PURE__*/React.createElement(StyledNumeralDate, {
193
+ }), (internalError || internalWarning) && /*#__PURE__*/React.createElement(ErrorBorder, {
194
+ warning: !!(!internalError && internalWarning)
195
+ })), /*#__PURE__*/React.createElement(StyledNumeralDate, {
179
196
  name: name,
180
- onKeyPress: onKeyPress,
197
+ onKeyDown: onKeyDown,
181
198
  "data-component": "numeral-date"
182
199
  }, dateFormat.map((datePart, index) => {
183
- const isStart = index === 0;
184
200
  const isEnd = index === dateFormat.length - 1;
185
- const isMiddle = index === 1;
186
- const validation = error || warning || info;
201
+ const labelId = labelIds.current[index];
202
+ const validation = internalError || internalWarning || info;
187
203
  const isStringValidation = typeof validation === "string";
188
204
  const hasValidationIcon = isStringValidation && !!validation.length;
189
205
  let inputRef;
@@ -203,24 +219,24 @@ export const NumeralDate = ({
203
219
  }
204
220
  return /*#__PURE__*/React.createElement(NumeralDateContext.Provider, {
205
221
  value: {
206
- disableErrorBorder: index !== 0
222
+ disableErrorBorder: true
207
223
  },
208
224
  key: datePart
209
225
  }, /*#__PURE__*/React.createElement(StyledDateField, {
210
226
  key: datePart,
211
227
  isYearInput: datePart.length === 4,
212
- isStart: isStart,
213
- isMiddle: isMiddle,
214
228
  isEnd: isEnd,
215
- hasValidationIcon: hasValidationIcon
229
+ hasValidationIconInField: hasValidationIcon && !validationOnLabel && !validationRedesignOptIn
216
230
  }, /*#__PURE__*/React.createElement(FormSpacingProvider, {
217
231
  marginBottom: undefined
218
- }, /*#__PURE__*/React.createElement(Textbox, _extends({}, index === 0 && {
232
+ }, /*#__PURE__*/React.createElement(Typography, {
233
+ mb: "4px",
234
+ id: labelId
235
+ }, getDateLabel(datePart, locale)), /*#__PURE__*/React.createElement(Textbox, _extends({}, index === 0 && {
219
236
  id: uniqueId
220
237
  }, {
221
238
  disabled: disabled,
222
239
  readOnly: readOnly,
223
- placeholder: datePart,
224
240
  value: dateValue[datePart],
225
241
  onChange: e => handleChange(e, datePart),
226
242
  ref: element => {
@@ -246,8 +262,9 @@ export const NumeralDate = ({
246
262
  info
247
263
  }, {
248
264
  size: size,
249
- tooltipPosition: tooltipPosition
265
+ tooltipPosition: tooltipPosition,
266
+ "aria-labelledby": labelId
250
267
  })))));
251
- })))));
268
+ }))))));
252
269
  };
253
270
  export default NumeralDate;
@@ -1,9 +1,7 @@
1
1
  interface StyledDateFieldProps {
2
- isStart?: boolean;
3
2
  isEnd?: boolean;
4
- isMiddle?: boolean;
5
3
  isYearInput?: boolean;
6
- hasValidationIcon?: boolean;
4
+ hasValidationIconInField?: boolean;
7
5
  }
8
6
  export declare const StyledNumeralDate: import("styled-components").StyledComponent<"div", any, {
9
7
  name?: string | undefined;
@@ -1,47 +1,44 @@
1
1
  import styled, { css } from "styled-components";
2
2
  import StyledValidationIcon from "../../__internal__/validations/validation-icon.style";
3
3
  import StyledIconSpan from "../../__internal__/input-icon-toggle/input-icon-toggle.style";
4
- import StyledInputPresentantion from "../../__internal__/input/input-presentation.style";
4
+ import StyledInputPresentation from "../../__internal__/input/input-presentation.style";
5
+ import StyledInput from "../../__internal__/input/input.style";
5
6
  import StyledFormField from "../../__internal__/form-field/form-field.style";
7
+ import StyledLabel from "../../__internal__/label/label.style";
8
+ import { StyledHintText } from "../textbox/textbox.style";
6
9
  export const StyledNumeralDate = styled.div`
7
10
  display: inline-flex;
8
- height: 40px;
9
11
  font-size: 14px;
10
12
  font-weight: 400;
11
13
 
12
14
  ${StyledFormField} {
13
15
  margin-top: 0px;
14
16
  }
17
+ ${StyledLabel} {
18
+ font-weight: 400;
19
+ }
20
+
21
+ ${StyledHintText} {
22
+ color: var(--colorsUtilityYin090);
23
+ }
15
24
  `;
16
25
  export const StyledDateField = styled.div`
17
26
  ${({
18
- isStart,
19
27
  isYearInput,
20
28
  isEnd,
21
- hasValidationIcon,
22
- isMiddle
29
+ hasValidationIconInField
23
30
  }) => {
24
- const yearInputOrError = isYearInput || isEnd && hasValidationIcon;
25
31
  return css`
26
- ${StyledInputPresentantion} {
32
+ ${StyledInputPresentation} {
27
33
  position: relative;
28
- width: ${yearInputOrError ? "78px;" : "58px;"};
29
- text-align: center;
30
- border-radius: var(--borderRadius000);
34
+ margin-right: ${isEnd ? "0" : "12px"};
35
+ min-width: ${isYearInput ? "80px" : "55px"};
31
36
 
32
- ${isStart && css`
33
- border-top-left-radius: var(--borderRadius050);
34
- border-bottom-left-radius: var(--borderRadius050);
35
- `}
36
-
37
- ${isEnd && css`
38
- border-top-right-radius: var(--borderRadius050);
39
- border-bottom-right-radius: var(--borderRadius050);
40
- `}
41
-
42
- ${(isMiddle || isEnd) && css`
43
- margin-left: -1px;
44
- `}
37
+ ${StyledInput} {
38
+ text-align: center;
39
+ padding: 0 12px;
40
+ ${hasValidationIconInField && isEnd && "padding-right: 0"}
41
+ }
45
42
 
46
43
  ${StyledIconSpan} {
47
44
  width: 32px;
@@ -51,6 +48,7 @@ export const StyledDateField = styled.div`
51
48
  ${StyledValidationIcon} {
52
49
  z-index: 9000;
53
50
  }
54
- `;
51
+ }
52
+ `;
55
53
  }}
56
54
  `;
@@ -184,6 +184,9 @@ const SelectList = /*#__PURE__*/React.forwardRef(({
184
184
  const lastOptionIndex = findLastIndex(childrenList, child => /*#__PURE__*/React.isValidElement(child) && (child.type === Option || child.type === OptionRow));
185
185
  const getNextHighlightableItemIndex = useCallback((key, indexOfHighlighted) => {
186
186
  const lastIndex = lastOptionIndex;
187
+ if (lastIndex === -1) {
188
+ return -1;
189
+ }
187
190
  let nextIndex = getNextIndexByKey(key, indexOfHighlighted, lastIndex, isLoading);
188
191
  const nextElement = childrenList[nextIndex];
189
192
  if ( /*#__PURE__*/React.isValidElement(nextElement) && nextElement.type !== Option && nextElement.type !== OptionRow) {
@@ -201,7 +204,7 @@ const SelectList = /*#__PURE__*/React.forwardRef(({
201
204
  currentIndex = indexOfHighlighted;
202
205
  }
203
206
  const nextIndex = getNextHighlightableItemIndex(key, currentIndex);
204
- if (currentIndex === nextIndex) {
207
+ if (nextIndex === -1 || currentIndex === nextIndex) {
205
208
  return;
206
209
  }
207
210
  const {
@@ -282,10 +285,10 @@ const SelectList = /*#__PURE__*/React.forwardRef(({
282
285
  const element = event.target;
283
286
 
284
287
  /* istanbul ignore else */
285
- if (onListScrollBottom && element.scrollHeight - element.scrollTop === element.clientHeight) {
288
+ if (isOpen && onListScrollBottom && element.scrollHeight - element.scrollTop === element.clientHeight) {
286
289
  onListScrollBottom();
287
290
  }
288
- }, [onListScrollBottom]);
291
+ }, [onListScrollBottom, isOpen]);
289
292
  useEffect(() => {
290
293
  const keyboardEvent = "keydown";
291
294
  const listElement = listContainerRef.current;
@@ -322,10 +325,6 @@ const SelectList = /*#__PURE__*/React.forwardRef(({
322
325
  }
323
326
  setCurrentOptionsListIndex(indexOfMatch);
324
327
  virtualizer.scrollToIndex(indexOfMatch, SCROLL_OPTIONS);
325
- // TODO: is there a better way than calling handleListScroll manually?
326
- handleListScroll({
327
- target: listContainerRef.current
328
- });
329
328
  }, [getIndexOfMatch, highlightedValue, virtualizer, handleListScroll, listContainerRef]);
330
329
  useEffect(() => {
331
330
  if (isLoading && currentOptionsListIndex === lastOptionIndex && lastOptionIndex > -1) {
@@ -94,6 +94,11 @@ const enGB = {
94
94
  day: () => "Day should be a number within a 1-31 range.",
95
95
  month: () => "Month should be a number within a 1-12 range.",
96
96
  year: () => "Year should be a number within a 1800-2200 range."
97
+ },
98
+ labels: {
99
+ day: () => "Day",
100
+ month: () => "Month",
101
+ year: () => "Year"
97
102
  }
98
103
  },
99
104
  pager: {
@@ -78,6 +78,11 @@ interface Locale {
78
78
  month: () => string;
79
79
  year: () => string;
80
80
  };
81
+ labels: {
82
+ day: () => string;
83
+ month: () => string;
84
+ year: () => string;
85
+ };
81
86
  };
82
87
  pager: {
83
88
  show: () => string;
@@ -129,6 +129,11 @@ const plPL = {
129
129
  day: () => "Dzień musi być liczbą w zakresie 1-31.",
130
130
  month: () => "Miesiąć musi być liczbą w zakresie 1-12.",
131
131
  year: () => "Rok musi być liczbą w zakresie 1800-2200."
132
+ },
133
+ labels: {
134
+ day: () => "Dzień",
135
+ month: () => "Miesiąć",
136
+ year: () => "Rok"
132
137
  }
133
138
  },
134
139
  pager: {
@@ -1,7 +1,7 @@
1
1
  import React from "react";
2
2
  import { MarginProps } from "styled-system";
3
3
  import { ValidationProps } from "../../__internal__/validations";
4
- export declare const ALLOWED_DATE_FORMATS: readonly [readonly ["dd", "mm", "yyyy"], readonly ["mm", "dd", "yyyy"], readonly ["dd", "mm"], readonly ["mm", "dd"], readonly ["mm", "yyyy"]];
4
+ export declare const ALLOWED_DATE_FORMATS: readonly [readonly ["dd", "mm", "yyyy"], readonly ["mm", "dd", "yyyy"], readonly ["yyyy", "mm", "dd"], readonly ["dd", "mm"], readonly ["mm", "dd"], readonly ["mm", "yyyy"]];
5
5
  export interface DayMonthDate {
6
6
  dd: string;
7
7
  mm: string;
@@ -11,6 +11,8 @@ var _utils = require("../../style/utils");
11
11
  var _events = _interopRequireDefault(require("../../__internal__/utils/helpers/events"));
12
12
  var _numeralDate = require("./numeral-date.style");
13
13
  var _textbox = _interopRequireDefault(require("../textbox"));
14
+ var _box = _interopRequireDefault(require("../box"));
15
+ var _typography = _interopRequireDefault(require("../typography"));
14
16
  var _textbox2 = require("../textbox/textbox.style");
15
17
  var _validationMessage = _interopRequireDefault(require("../../__internal__/validation-message"));
16
18
  var _guid = _interopRequireDefault(require("../../__internal__/utils/helpers/guid"));
@@ -27,8 +29,8 @@ function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return
27
29
  function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && Object.prototype.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
28
30
  function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
29
31
  let deprecateUncontrolledWarnTriggered = false;
30
- const ALLOWED_DATE_FORMATS = exports.ALLOWED_DATE_FORMATS = [["dd", "mm", "yyyy"], ["mm", "dd", "yyyy"], ["dd", "mm"], ["mm", "dd"], ["mm", "yyyy"]];
31
- const incorrectDateFormatMessage = "Forbidden prop dateFormat supplied to NumeralDate. " + "Only one of these date formats is allowed: " + "['dd', 'mm', 'yyyy'], " + "['mm', 'dd', 'yyyy'], " + "['dd', 'mm'], " + "['mm', 'dd'], " + "['mm', 'yyyy']";
32
+ const ALLOWED_DATE_FORMATS = exports.ALLOWED_DATE_FORMATS = [["dd", "mm", "yyyy"], ["mm", "dd", "yyyy"], ["yyyy", "mm", "dd"], ["dd", "mm"], ["mm", "dd"], ["mm", "yyyy"]];
33
+ const incorrectDateFormatMessage = "Forbidden prop dateFormat supplied to NumeralDate. " + "Only one of these date formats is allowed: " + "['dd', 'mm', 'yyyy'], " + "['mm', 'dd', 'yyyy'], " + "['yyyy', 'mm', 'dd'], " + "['dd', 'mm'], " + "['mm', 'dd'], " + "['mm', 'yyyy']";
32
34
  const isDayValid = day => day ? +day > 0 && +day < 32 : true;
33
35
  const isMonthValid = month => month ? +month > 0 && +month < 13 : true;
34
36
  const isYearValid = year => year ? +year > 1799 && +year < 2201 : true;
@@ -37,6 +39,16 @@ const validations = {
37
39
  mm: isMonthValid,
38
40
  yyyy: isYearValid
39
41
  };
42
+ const getDateLabel = (datePart, locale) => {
43
+ switch (datePart) {
44
+ case "mm":
45
+ return locale.numeralDate.labels.month();
46
+ case "yyyy":
47
+ return locale.numeralDate.labels.year();
48
+ default:
49
+ return locale.numeralDate.labels.day();
50
+ }
51
+ };
40
52
  const NumeralDate = ({
41
53
  dateFormat = ["dd", "mm", "yyyy"],
42
54
  defaultValue,
@@ -73,7 +85,7 @@ const NumeralDate = ({
73
85
  yearRef,
74
86
  ...rest
75
87
  }) => {
76
- const l = (0, _useLocale.default)();
88
+ const locale = (0, _useLocale.default)();
77
89
  const {
78
90
  validationRedesignOptIn
79
91
  } = (0, _react.useContext)(_carbonProvider.NewValidationContext);
@@ -83,6 +95,7 @@ const NumeralDate = ({
83
95
  const isControlled = (0, _react.useRef)(value !== undefined);
84
96
  const initialValue = isControlled.current ? value : defaultValue;
85
97
  const refs = (0, _react.useRef)(dateFormat.map(() => null));
98
+ const labelIds = (0, _react.useRef)([(0, _guid.default)(), (0, _guid.default)(), (0, _guid.default)()]);
86
99
  const [internalMessages, setInternalMessages] = (0, _react.useState)({
87
100
  ...Object.fromEntries(dateFormat.map(datePart => [datePart, ""]))
88
101
  });
@@ -96,9 +109,9 @@ const NumeralDate = ({
96
109
  !(isControlled.current === (value !== undefined)) ? process.env.NODE_ENV !== "production" ? (0, _invariant.default)(false, modeSwitchedMessage) : (0, _invariant.default)(false) : void 0;
97
110
  }, [value]);
98
111
  const validationMessages = {
99
- dd: l.numeralDate.validation.day(),
100
- mm: l.numeralDate.validation.month(),
101
- yyyy: l.numeralDate.validation.year()
112
+ dd: locale.numeralDate.validation.day(),
113
+ mm: locale.numeralDate.validation.month(),
114
+ yyyy: locale.numeralDate.validation.year()
102
115
  };
103
116
  const [dateValue, setDateValue] = (0, _react.useState)({
104
117
  ...(initialValue || Object.fromEntries(dateFormat.map(datePart => [datePart, ""])))
@@ -110,7 +123,7 @@ const NumeralDate = ({
110
123
  value: newValue
111
124
  }
112
125
  });
113
- const onKeyPress = event => {
126
+ const onKeyDown = event => {
114
127
  const isValidKey = _events.default.isNumberKey(event) || _events.default.isTabKey(event) || event.key === "Delete" || event.key === "Backspace";
115
128
  if (!isValidKey) {
116
129
  event.preventDefault();
@@ -175,24 +188,27 @@ const NumeralDate = ({
175
188
  labelInline: labelInline,
176
189
  labelWidth: labelWidth,
177
190
  labelAlign: labelAlign,
178
- labelHelp: labelHelp,
191
+ labelHelp: !validationRedesignOptIn && labelHelp,
179
192
  labelSpacing: labelSpacing,
180
193
  fieldHelp: fieldHelp,
181
194
  adaptiveLabelBreakpoint: adaptiveLabelBreakpoint,
182
195
  isRequired: required,
183
196
  validationRedesignOptIn: validationRedesignOptIn
184
- }, (0, _utils.filterStyledSystemMarginProps)(rest)), validationRedesignOptIn && labelHelp && /*#__PURE__*/_react.default.createElement(_textbox2.StyledHintText, null, labelHelp), validationRedesignOptIn && /*#__PURE__*/_react.default.createElement(_validationMessage.default, {
197
+ }, (0, _utils.filterStyledSystemMarginProps)(rest)), validationRedesignOptIn && labelHelp && /*#__PURE__*/_react.default.createElement(_textbox2.StyledHintText, null, labelHelp), /*#__PURE__*/_react.default.createElement(_box.default, {
198
+ position: "relative"
199
+ }, validationRedesignOptIn && /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, /*#__PURE__*/_react.default.createElement(_validationMessage.default, {
185
200
  error: internalError,
186
201
  warning: internalWarning
187
- }), /*#__PURE__*/_react.default.createElement(_numeralDate.StyledNumeralDate, {
202
+ }), (internalError || internalWarning) && /*#__PURE__*/_react.default.createElement(_textbox2.ErrorBorder, {
203
+ warning: !!(!internalError && internalWarning)
204
+ })), /*#__PURE__*/_react.default.createElement(_numeralDate.StyledNumeralDate, {
188
205
  name: name,
189
- onKeyPress: onKeyPress,
206
+ onKeyDown: onKeyDown,
190
207
  "data-component": "numeral-date"
191
208
  }, dateFormat.map((datePart, index) => {
192
- const isStart = index === 0;
193
209
  const isEnd = index === dateFormat.length - 1;
194
- const isMiddle = index === 1;
195
- const validation = error || warning || info;
210
+ const labelId = labelIds.current[index];
211
+ const validation = internalError || internalWarning || info;
196
212
  const isStringValidation = typeof validation === "string";
197
213
  const hasValidationIcon = isStringValidation && !!validation.length;
198
214
  let inputRef;
@@ -212,24 +228,24 @@ const NumeralDate = ({
212
228
  }
213
229
  return /*#__PURE__*/_react.default.createElement(_numeralDateContext.default.Provider, {
214
230
  value: {
215
- disableErrorBorder: index !== 0
231
+ disableErrorBorder: true
216
232
  },
217
233
  key: datePart
218
234
  }, /*#__PURE__*/_react.default.createElement(_numeralDate.StyledDateField, {
219
235
  key: datePart,
220
236
  isYearInput: datePart.length === 4,
221
- isStart: isStart,
222
- isMiddle: isMiddle,
223
237
  isEnd: isEnd,
224
- hasValidationIcon: hasValidationIcon
238
+ hasValidationIconInField: hasValidationIcon && !validationOnLabel && !validationRedesignOptIn
225
239
  }, /*#__PURE__*/_react.default.createElement(_formSpacingProvider.default, {
226
240
  marginBottom: undefined
227
- }, /*#__PURE__*/_react.default.createElement(_textbox.default, _extends({}, index === 0 && {
241
+ }, /*#__PURE__*/_react.default.createElement(_typography.default, {
242
+ mb: "4px",
243
+ id: labelId
244
+ }, getDateLabel(datePart, locale)), /*#__PURE__*/_react.default.createElement(_textbox.default, _extends({}, index === 0 && {
228
245
  id: uniqueId
229
246
  }, {
230
247
  disabled: disabled,
231
248
  readOnly: readOnly,
232
- placeholder: datePart,
233
249
  value: dateValue[datePart],
234
250
  onChange: e => handleChange(e, datePart),
235
251
  ref: element => {
@@ -255,9 +271,10 @@ const NumeralDate = ({
255
271
  info
256
272
  }, {
257
273
  size: size,
258
- tooltipPosition: tooltipPosition
274
+ tooltipPosition: tooltipPosition,
275
+ "aria-labelledby": labelId
259
276
  })))));
260
- })))));
277
+ }))))));
261
278
  };
262
279
  exports.NumeralDate = NumeralDate;
263
280
  var _default = exports.default = NumeralDate;
@@ -1,9 +1,7 @@
1
1
  interface StyledDateFieldProps {
2
- isStart?: boolean;
3
2
  isEnd?: boolean;
4
- isMiddle?: boolean;
5
3
  isYearInput?: boolean;
6
- hasValidationIcon?: boolean;
4
+ hasValidationIconInField?: boolean;
7
5
  }
8
6
  export declare const StyledNumeralDate: import("styled-components").StyledComponent<"div", any, {
9
7
  name?: string | undefined;
@@ -8,49 +8,46 @@ var _styledComponents = _interopRequireWildcard(require("styled-components"));
8
8
  var _validationIcon = _interopRequireDefault(require("../../__internal__/validations/validation-icon.style"));
9
9
  var _inputIconToggle = _interopRequireDefault(require("../../__internal__/input-icon-toggle/input-icon-toggle.style"));
10
10
  var _inputPresentation = _interopRequireDefault(require("../../__internal__/input/input-presentation.style"));
11
+ var _input = _interopRequireDefault(require("../../__internal__/input/input.style"));
11
12
  var _formField = _interopRequireDefault(require("../../__internal__/form-field/form-field.style"));
13
+ var _label = _interopRequireDefault(require("../../__internal__/label/label.style"));
14
+ var _textbox = require("../textbox/textbox.style");
12
15
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
13
16
  function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
14
17
  function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && Object.prototype.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
15
18
  const StyledNumeralDate = exports.StyledNumeralDate = _styledComponents.default.div`
16
19
  display: inline-flex;
17
- height: 40px;
18
20
  font-size: 14px;
19
21
  font-weight: 400;
20
22
 
21
23
  ${_formField.default} {
22
24
  margin-top: 0px;
23
25
  }
26
+ ${_label.default} {
27
+ font-weight: 400;
28
+ }
29
+
30
+ ${_textbox.StyledHintText} {
31
+ color: var(--colorsUtilityYin090);
32
+ }
24
33
  `;
25
34
  const StyledDateField = exports.StyledDateField = _styledComponents.default.div`
26
35
  ${({
27
- isStart,
28
36
  isYearInput,
29
37
  isEnd,
30
- hasValidationIcon,
31
- isMiddle
38
+ hasValidationIconInField
32
39
  }) => {
33
- const yearInputOrError = isYearInput || isEnd && hasValidationIcon;
34
40
  return (0, _styledComponents.css)`
35
41
  ${_inputPresentation.default} {
36
42
  position: relative;
37
- width: ${yearInputOrError ? "78px;" : "58px;"};
38
- text-align: center;
39
- border-radius: var(--borderRadius000);
43
+ margin-right: ${isEnd ? "0" : "12px"};
44
+ min-width: ${isYearInput ? "80px" : "55px"};
40
45
 
41
- ${isStart && (0, _styledComponents.css)`
42
- border-top-left-radius: var(--borderRadius050);
43
- border-bottom-left-radius: var(--borderRadius050);
44
- `}
45
-
46
- ${isEnd && (0, _styledComponents.css)`
47
- border-top-right-radius: var(--borderRadius050);
48
- border-bottom-right-radius: var(--borderRadius050);
49
- `}
50
-
51
- ${(isMiddle || isEnd) && (0, _styledComponents.css)`
52
- margin-left: -1px;
53
- `}
46
+ ${_input.default} {
47
+ text-align: center;
48
+ padding: 0 12px;
49
+ ${hasValidationIconInField && isEnd && "padding-right: 0"}
50
+ }
54
51
 
55
52
  ${_inputIconToggle.default} {
56
53
  width: 32px;
@@ -60,6 +57,7 @@ const StyledDateField = exports.StyledDateField = _styledComponents.default.div`
60
57
  ${_validationIcon.default} {
61
58
  z-index: 9000;
62
59
  }
63
- `;
60
+ }
61
+ `;
64
62
  }}
65
63
  `;
@@ -193,6 +193,9 @@ const SelectList = /*#__PURE__*/_react.default.forwardRef(({
193
193
  const lastOptionIndex = (0, _findLastIndex.default)(childrenList, child => /*#__PURE__*/_react.default.isValidElement(child) && (child.type === _option.default || child.type === _optionRow.default));
194
194
  const getNextHighlightableItemIndex = (0, _react.useCallback)((key, indexOfHighlighted) => {
195
195
  const lastIndex = lastOptionIndex;
196
+ if (lastIndex === -1) {
197
+ return -1;
198
+ }
196
199
  let nextIndex = (0, _getNextIndexByKey.default)(key, indexOfHighlighted, lastIndex, isLoading);
197
200
  const nextElement = childrenList[nextIndex];
198
201
  if ( /*#__PURE__*/_react.default.isValidElement(nextElement) && nextElement.type !== _option.default && nextElement.type !== _optionRow.default) {
@@ -210,7 +213,7 @@ const SelectList = /*#__PURE__*/_react.default.forwardRef(({
210
213
  currentIndex = indexOfHighlighted;
211
214
  }
212
215
  const nextIndex = getNextHighlightableItemIndex(key, currentIndex);
213
- if (currentIndex === nextIndex) {
216
+ if (nextIndex === -1 || currentIndex === nextIndex) {
214
217
  return;
215
218
  }
216
219
  const {
@@ -291,10 +294,10 @@ const SelectList = /*#__PURE__*/_react.default.forwardRef(({
291
294
  const element = event.target;
292
295
 
293
296
  /* istanbul ignore else */
294
- if (onListScrollBottom && element.scrollHeight - element.scrollTop === element.clientHeight) {
297
+ if (isOpen && onListScrollBottom && element.scrollHeight - element.scrollTop === element.clientHeight) {
295
298
  onListScrollBottom();
296
299
  }
297
- }, [onListScrollBottom]);
300
+ }, [onListScrollBottom, isOpen]);
298
301
  (0, _react.useEffect)(() => {
299
302
  const keyboardEvent = "keydown";
300
303
  const listElement = listContainerRef.current;
@@ -331,10 +334,6 @@ const SelectList = /*#__PURE__*/_react.default.forwardRef(({
331
334
  }
332
335
  setCurrentOptionsListIndex(indexOfMatch);
333
336
  virtualizer.scrollToIndex(indexOfMatch, SCROLL_OPTIONS);
334
- // TODO: is there a better way than calling handleListScroll manually?
335
- handleListScroll({
336
- target: listContainerRef.current
337
- });
338
337
  }, [getIndexOfMatch, highlightedValue, virtualizer, handleListScroll, listContainerRef]);
339
338
  (0, _react.useEffect)(() => {
340
339
  if (isLoading && currentOptionsListIndex === lastOptionIndex && lastOptionIndex > -1) {
@@ -100,6 +100,11 @@ const enGB = {
100
100
  day: () => "Day should be a number within a 1-31 range.",
101
101
  month: () => "Month should be a number within a 1-12 range.",
102
102
  year: () => "Year should be a number within a 1800-2200 range."
103
+ },
104
+ labels: {
105
+ day: () => "Day",
106
+ month: () => "Month",
107
+ year: () => "Year"
103
108
  }
104
109
  },
105
110
  pager: {
@@ -78,6 +78,11 @@ interface Locale {
78
78
  month: () => string;
79
79
  year: () => string;
80
80
  };
81
+ labels: {
82
+ day: () => string;
83
+ month: () => string;
84
+ year: () => string;
85
+ };
81
86
  };
82
87
  pager: {
83
88
  show: () => string;
@@ -136,6 +136,11 @@ const plPL = {
136
136
  day: () => "Dzień musi być liczbą w zakresie 1-31.",
137
137
  month: () => "Miesiąć musi być liczbą w zakresie 1-12.",
138
138
  year: () => "Rok musi być liczbą w zakresie 1800-2200."
139
+ },
140
+ labels: {
141
+ day: () => "Dzień",
142
+ month: () => "Miesiąć",
143
+ year: () => "Rok"
139
144
  }
140
145
  },
141
146
  pager: {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "carbon-react",
3
- "version": "124.4.0",
3
+ "version": "124.5.0",
4
4
  "description": "A library of reusable React components for easily building user interfaces.",
5
5
  "files": [
6
6
  "lib",