carbon-react 104.56.0 → 104.58.1

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.
Files changed (66) hide show
  1. package/esm/__internal__/form-field/form-field.component.js +3 -3
  2. package/esm/__internal__/input/input-presentation.component.js +6 -1
  3. package/esm/__internal__/input/input-presentation.style.d.ts +1 -0
  4. package/esm/__internal__/input/input-presentation.style.js +3 -2
  5. package/esm/__internal__/validation-message/index.d.ts +1 -0
  6. package/esm/__internal__/validation-message/index.js +1 -0
  7. package/esm/__internal__/validation-message/validation-message.component.d.ts +11 -0
  8. package/esm/__internal__/validation-message/validation-message.component.js +15 -0
  9. package/esm/__internal__/validation-message/validation-message.style.d.ts +5 -0
  10. package/esm/__internal__/validation-message/validation-message.style.js +12 -0
  11. package/esm/__internal__/validations/validation-icon.component.js +3 -5
  12. package/esm/components/carbon-provider/carbon-provider.component.d.ts +5 -1
  13. package/esm/components/carbon-provider/carbon-provider.component.js +11 -4
  14. package/esm/components/carbon-provider/carbon-provider.d.ts +1 -0
  15. package/esm/components/date-range/date-range.style.js +1 -1
  16. package/esm/components/fieldset/fieldset.component.js +7 -2
  17. package/esm/components/icon/icon.component.js +6 -1
  18. package/esm/components/icon/icon.d.ts +2 -0
  19. package/esm/components/numeral-date/numeral-date-context.d.ts +3 -0
  20. package/esm/components/numeral-date/numeral-date-context.js +2 -0
  21. package/esm/components/numeral-date/numeral-date.component.js +22 -6
  22. package/esm/components/select/__internal__/select-text/select-text.component.d.ts +1 -1
  23. package/esm/components/select/__internal__/select-text/select-text.component.js +2 -5
  24. package/esm/components/select/select-textbox/select-textbox.component.js +5 -8
  25. package/esm/components/textarea/textarea.component.js +27 -12
  26. package/esm/components/textbox/textbox.component.js +36 -15
  27. package/esm/components/textbox/textbox.d.ts +1 -1
  28. package/esm/components/textbox/textbox.style.d.ts +2 -0
  29. package/esm/components/textbox/textbox.style.js +33 -0
  30. package/esm/style/themes/base/base-theme.config.d.ts +2 -0
  31. package/esm/style/themes/base/base-theme.config.js +3 -1
  32. package/esm/style/themes/base/index.d.ts +2 -0
  33. package/lib/__internal__/form-field/form-field.component.js +3 -3
  34. package/lib/__internal__/input/input-presentation.component.js +7 -1
  35. package/lib/__internal__/input/input-presentation.style.d.ts +1 -0
  36. package/lib/__internal__/input/input-presentation.style.js +3 -2
  37. package/lib/__internal__/validation-message/index.d.ts +1 -0
  38. package/lib/__internal__/validation-message/index.js +15 -0
  39. package/lib/__internal__/validation-message/package.json +6 -0
  40. package/lib/__internal__/validation-message/validation-message.component.d.ts +11 -0
  41. package/lib/__internal__/validation-message/validation-message.component.js +26 -0
  42. package/lib/__internal__/validation-message/validation-message.style.d.ts +5 -0
  43. package/lib/__internal__/validation-message/validation-message.style.js +25 -0
  44. package/lib/__internal__/validations/validation-icon.component.js +3 -5
  45. package/lib/components/carbon-provider/carbon-provider.component.d.ts +5 -1
  46. package/lib/components/carbon-provider/carbon-provider.component.js +18 -5
  47. package/lib/components/carbon-provider/carbon-provider.d.ts +1 -0
  48. package/lib/components/date-range/date-range.style.js +1 -1
  49. package/lib/components/fieldset/fieldset.component.js +8 -2
  50. package/lib/components/icon/icon.component.js +6 -1
  51. package/lib/components/icon/icon.d.ts +2 -0
  52. package/lib/components/numeral-date/numeral-date-context.d.ts +3 -0
  53. package/lib/components/numeral-date/numeral-date-context.js +14 -0
  54. package/lib/components/numeral-date/numeral-date.component.js +25 -5
  55. package/lib/components/select/__internal__/select-text/select-text.component.d.ts +1 -1
  56. package/lib/components/select/__internal__/select-text/select-text.component.js +2 -6
  57. package/lib/components/select/select-textbox/select-textbox.component.js +5 -8
  58. package/lib/components/textarea/textarea.component.js +30 -12
  59. package/lib/components/textbox/textbox.component.js +44 -15
  60. package/lib/components/textbox/textbox.d.ts +1 -1
  61. package/lib/components/textbox/textbox.style.d.ts +2 -0
  62. package/lib/components/textbox/textbox.style.js +49 -0
  63. package/lib/style/themes/base/base-theme.config.d.ts +2 -0
  64. package/lib/style/themes/base/base-theme.config.js +3 -1
  65. package/lib/style/themes/base/index.d.ts +2 -0
  66. package/package.json +1 -1
@@ -67,9 +67,9 @@ const FormField = ({
67
67
  labelId: labelId,
68
68
  align: labelAlign,
69
69
  disabled: disabled,
70
- error: error,
71
- warning: warning,
72
- info: info,
70
+ error: !rest.validationRedesignOptIn && error,
71
+ warning: !rest.validationRedesignOptIn && warning,
72
+ info: !rest.validationRedesignOptIn && info,
73
73
  help: labelHelp,
74
74
  tooltipId: tooltipId,
75
75
  helpTabIndex: helpTabIndex,
@@ -2,6 +2,7 @@ import React, { useContext } from "react";
2
2
  import PropTypes from "prop-types";
3
3
  import InputPresentationStyle, { StyledInputPresentationContainer } from "./input-presentation.style";
4
4
  import { InputContext, InputGroupContext } from "../input-behaviour";
5
+ import { NewValidationContext } from "../../components/carbon-provider/carbon-provider.component";
5
6
 
6
7
  const InputPresentation = ({
7
8
  children,
@@ -21,6 +22,9 @@ const InputPresentation = ({
21
22
  onMouseEnter,
22
23
  onMouseLeave
23
24
  } = useContext(InputContext);
25
+ const {
26
+ validationRedesignOptIn
27
+ } = useContext(NewValidationContext);
24
28
  const {
25
29
  onMouseEnter: onGroupMouseEnter,
26
30
  onMouseLeave: onGroupMouseLeave
@@ -50,7 +54,8 @@ const InputPresentation = ({
50
54
  size: size,
51
55
  warning: warning,
52
56
  error: error,
53
- info: info
57
+ info: info,
58
+ validationRedesignOptIn: validationRedesignOptIn
54
59
  }, children));
55
60
  };
56
61
 
@@ -5,4 +5,5 @@ declare const InputPresentationStyle: import("styled-components").StyledComponen
5
5
  warning: any;
6
6
  info: any;
7
7
  disabled: any;
8
+ validationRedesignOptIn: any;
8
9
  }, never>;
@@ -70,7 +70,8 @@ function stylingForValidations({
70
70
  error,
71
71
  warning,
72
72
  info,
73
- disabled
73
+ disabled,
74
+ validationRedesignOptIn
74
75
  }) {
75
76
  let validationColor;
76
77
 
@@ -81,7 +82,7 @@ function stylingForValidations({
81
82
  if (error) {
82
83
  validationColor = "var(--colorsSemanticNegative500)";
83
84
  } else if (warning) {
84
- validationColor = "var(--colorsSemanticCaution500)";
85
+ validationColor = validationRedesignOptIn ? "var(--colorsUtilityMajor300)" : "var(--colorsSemanticCaution500)";
85
86
  } else if (info) {
86
87
  validationColor = "var(--colorsSemanticInfo500)";
87
88
  } else {
@@ -0,0 +1 @@
1
+ export { default } from "./validation-message.component";
@@ -0,0 +1 @@
1
+ export { default } from "./validation-message.component";
@@ -0,0 +1,11 @@
1
+ /// <reference types="react" />
2
+ export interface ValidationMessageProps {
3
+ /** Indicate that error has occurred
4
+ Pass string to display hint with error */
5
+ error?: boolean | string;
6
+ /** Indicate that warning has occurred
7
+ Pass string to display hint with warning */
8
+ warning?: boolean | string;
9
+ }
10
+ declare const ValidationMessage: ({ error, warning }: ValidationMessageProps) => JSX.Element | null;
11
+ export default ValidationMessage;
@@ -0,0 +1,15 @@
1
+ import React from "react";
2
+ import StyledValidationMessage from "./validation-message.style";
3
+
4
+ const ValidationMessage = ({
5
+ error,
6
+ warning
7
+ }) => {
8
+ const validation = error || warning;
9
+ const isStringValidation = typeof validation === "string";
10
+ return isStringValidation ? /*#__PURE__*/React.createElement(StyledValidationMessage, {
11
+ isWarning: !!(!error && warning)
12
+ }, validation) : null;
13
+ };
14
+
15
+ export default ValidationMessage;
@@ -0,0 +1,5 @@
1
+ interface StyledValidationMessageProps {
2
+ isWarning?: boolean;
3
+ }
4
+ declare const StyledValidationMessage: import("styled-components").StyledComponent<"p", any, StyledValidationMessageProps, never>;
5
+ export default StyledValidationMessage;
@@ -0,0 +1,12 @@
1
+ import styled, { css } from "styled-components";
2
+ const StyledValidationMessage = styled.p`
3
+ ${({
4
+ isWarning
5
+ }) => css`
6
+ color: ${isWarning ? "var(--colorsSemanticCaution600)" : "var(--colorsSemanticNegative500)"};
7
+ font-weight: ${isWarning ? "regular" : "bold"};
8
+ margin-top: 0px;
9
+ margin-bottom: 8px;
10
+ `}
11
+ `;
12
+ export default StyledValidationMessage;
@@ -57,10 +57,7 @@ const ValidationIcon = ({
57
57
  }
58
58
 
59
59
  return /*#__PURE__*/React.createElement(ValidationIconStyle, _extends({
60
- id: iconId,
61
60
  validationType: validationType,
62
- role: "tooltip",
63
- "aria-label": validationMessage,
64
61
  onClick: onClick,
65
62
  onMouseOver: () => setTriggeredByIcon(true),
66
63
  onMouseLeave: () => setTriggeredByIcon(false),
@@ -84,8 +81,9 @@ const ValidationIcon = ({
84
81
  tooltipFlipOverrides: isPartOfInput && !tooltipFlipOverrides ? ["top", "bottom"] : tooltipFlipOverrides,
85
82
  isPartOfInput: isPartOfInput,
86
83
  inputSize: size,
87
- "aria-hidden": "true",
88
- focusable: false
84
+ id: iconId,
85
+ ariaLabel: validationMessage,
86
+ focusable: tabIndex !== -1
89
87
  }));
90
88
  };
91
89
 
@@ -1,12 +1,16 @@
1
+ export const NewValidationContext: React.Context<{}>;
1
2
  export default CarbonProvider;
2
- declare function CarbonProvider({ children, theme }: {
3
+ import React from "react";
4
+ declare function CarbonProvider({ children, theme, validationRedesignOptIn, }: {
3
5
  children: any;
4
6
  theme?: import("../../style/themes/base").ThemeObject | undefined;
7
+ validationRedesignOptIn?: boolean | undefined;
5
8
  }): JSX.Element;
6
9
  declare namespace CarbonProvider {
7
10
  namespace propTypes {
8
11
  const children: PropTypes.Validator<string | number | boolean | {} | PropTypes.ReactElementLike | PropTypes.ReactNodeArray>;
9
12
  const theme: PropTypes.Requireable<object>;
13
+ const validationRedesignOptIn: PropTypes.Requireable<boolean>;
10
14
  }
11
15
  }
12
16
  import PropTypes from "prop-types";
@@ -1,18 +1,25 @@
1
- import React from "react";
1
+ import React, { createContext } from "react";
2
2
  import PropTypes from "prop-types";
3
3
  import { ThemeProvider } from "styled-components";
4
4
  import mintTheme from "../../style/themes/mint";
5
5
  import CarbonScopedTokensProvider from "../../style/design-tokens/carbon-scoped-tokens-provider";
6
+ export const NewValidationContext = /*#__PURE__*/createContext({});
6
7
 
7
8
  const CarbonProvider = ({
8
9
  children,
9
- theme = mintTheme
10
+ theme = mintTheme,
11
+ validationRedesignOptIn = false
10
12
  }) => /*#__PURE__*/React.createElement(ThemeProvider, {
11
13
  theme: theme
12
- }, /*#__PURE__*/React.createElement(CarbonScopedTokensProvider, null, children));
14
+ }, /*#__PURE__*/React.createElement(CarbonScopedTokensProvider, null, /*#__PURE__*/React.createElement(NewValidationContext.Provider, {
15
+ value: {
16
+ validationRedesignOptIn
17
+ }
18
+ }, children)));
13
19
 
14
20
  CarbonProvider.propTypes = {
15
21
  children: PropTypes.node.isRequired,
16
- theme: PropTypes.object
22
+ theme: PropTypes.object,
23
+ validationRedesignOptIn: PropTypes.bool
17
24
  };
18
25
  export default CarbonProvider;
@@ -5,6 +5,7 @@ import { ThemeObject } from "../../style/themes/base";
5
5
  export interface CarbonProviderProps {
6
6
  theme?: ThemeObject;
7
7
  children: React.ReactNode;
8
+ validationRedesignOptIn?: boolean;
8
9
  }
9
10
 
10
11
  declare function CarbonProvider(props: CarbonProviderProps): JSX.Element;
@@ -16,7 +16,7 @@ const StyledDateRange = styled.div`
16
16
  }
17
17
 
18
18
  & ${StyledDateInput}:first-child {
19
- margin-right: var(--spacing150);
19
+ margin-right: var(--spacing300);
20
20
  }
21
21
 
22
22
  ${StyledLabelContainer} {
@@ -7,6 +7,7 @@ import { validProps } from "../../__internal__/utils/ether";
7
7
  import tagComponent from "../../__internal__/utils/helpers/tags/tags";
8
8
  import { filterStyledSystemMarginProps } from "../../style/utils";
9
9
  import { FieldsetStyle, LegendContainerStyle, FieldsetContentStyle } from "./fieldset.style";
10
+ import { NewValidationContext } from "../carbon-provider/carbon-provider.component";
10
11
  const marginPropTypes = filterStyledSystemMarginProps(styledSystemPropTypes.space);
11
12
 
12
13
  const Fieldset = props => {
@@ -25,12 +26,16 @@ const Fieldset = props => {
25
26
  propTypes: Fieldset.propTypes,
26
27
  props
27
28
  });
28
- return /*#__PURE__*/React.createElement(FieldsetStyle, _extends({}, tagComponent("fieldset", props), safeProps, {
29
+ return /*#__PURE__*/React.createElement(NewValidationContext.Provider, {
30
+ value: {
31
+ validationRedesignOptIn: false
32
+ }
33
+ }, /*#__PURE__*/React.createElement(FieldsetStyle, _extends({}, tagComponent("fieldset", props), safeProps, {
29
34
  m: 0
30
35
  }, filterStyledSystemMarginProps(props)), /*#__PURE__*/React.createElement(FieldsetContentStyle, {
31
36
  "data-component": "fieldset-style",
32
37
  inline: props.inline
33
- }, legend(), props.children));
38
+ }, legend(), props.children)));
34
39
  };
35
40
 
36
41
  Fieldset.propTypes = {
@@ -28,6 +28,7 @@ const Icon = /*#__PURE__*/React.forwardRef(({
28
28
  tooltipFlipOverrides,
29
29
  tooltipId,
30
30
  tabIndex,
31
+ id,
31
32
  isPartOfInput,
32
33
  inputSize,
33
34
  role,
@@ -87,6 +88,7 @@ const Icon = /*#__PURE__*/React.forwardRef(({
87
88
  "aria-hidden": ariaHidden,
88
89
  ref: ref,
89
90
  key: "icon",
91
+ id: id,
90
92
  className: className || null,
91
93
  "data-element": iconType()
92
94
  }, tagComponent("icon", rest), styleProps, {
@@ -199,7 +201,10 @@ Icon.propTypes = { ...marginPropTypes,
199
201
  tabIndex: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),
200
202
 
201
203
  /** @ignore @private */
202
- focusable: PropTypes.bool
204
+ focusable: PropTypes.bool,
205
+
206
+ /** Id passed to the icon. */
207
+ id: PropTypes.string
203
208
  };
204
209
  Icon.defaultProps = {
205
210
  bgSize: "small",
@@ -237,6 +237,8 @@ export interface IconProps extends MarginProps {
237
237
  tooltipFlipOverrides?: TooltipPositions[];
238
238
  /** Id passed to the tooltip container, used for accessibility purposes */
239
239
  tooltipId?: string;
240
+ /** Id passed to the icon. */
241
+ id?: string;
240
242
  }
241
243
 
242
244
  declare function Icon(
@@ -0,0 +1,3 @@
1
+ declare var _default: React.Context<{}>;
2
+ export default _default;
3
+ import React from "react";
@@ -0,0 +1,2 @@
1
+ import React from "react";
2
+ export default /*#__PURE__*/React.createContext({});
@@ -1,6 +1,6 @@
1
1
  function _extends() { _extends = Object.assign || 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); }
2
2
 
3
- import React, { useState, useEffect, useRef } from "react";
3
+ import React, { useContext, useState, useEffect, useRef } from "react";
4
4
  import PropTypes from "prop-types";
5
5
  import styledSystemPropTypes from "@styled-system/prop-types";
6
6
  import invariant from "invariant";
@@ -8,11 +8,15 @@ import { filterStyledSystemMarginProps } from "../../style/utils";
8
8
  import Events from "../../__internal__/utils/helpers/events";
9
9
  import { StyledNumeralDate, StyledDateField } from "./numeral-date.style";
10
10
  import Textbox from "../textbox";
11
+ import { StyledHintText } from "../textbox/textbox.style";
12
+ import ValidationMessage from "../../__internal__/validation-message";
11
13
  import guid from "../../__internal__/utils/helpers/guid";
12
14
  import useLocale from "../../hooks/__internal__/useLocale";
13
15
  import FormField from "../../__internal__/form-field";
14
16
  import { InputGroupBehaviour } from "../../__internal__/input-behaviour";
15
17
  import { TooltipProvider } from "../../__internal__/tooltip-provider";
18
+ import { NewValidationContext } from "../carbon-provider/carbon-provider.component";
19
+ import NumeralDateContext from "./numeral-date-context";
16
20
  const marginPropTypes = filterStyledSystemMarginProps(styledSystemPropTypes.space);
17
21
  const ALLOWED_DATE_FORMATS = [["dd", "mm", "yyyy"], ["mm", "dd", "yyyy"], ["dd", "mm"], ["mm", "dd"], ["mm", "yyyy"]];
18
22
 
@@ -62,6 +66,9 @@ const NumeralDate = ({
62
66
  ...rest
63
67
  }) => {
64
68
  const l = useLocale();
69
+ const {
70
+ validationRedesignOptIn
71
+ } = useContext(NewValidationContext);
65
72
  const {
66
73
  current: uniqueId
67
74
  } = useRef(id || guid());
@@ -162,8 +169,12 @@ const NumeralDate = ({
162
169
  labelSpacing: labelSpacing,
163
170
  fieldHelp: fieldHelp,
164
171
  adaptiveLabelBreakpoint: adaptiveLabelBreakpoint,
165
- isRequired: required
166
- }, filterStyledSystemMarginProps(rest)), /*#__PURE__*/React.createElement(StyledNumeralDate, {
172
+ isRequired: required,
173
+ validationRedesignOptIn: validationRedesignOptIn
174
+ }, filterStyledSystemMarginProps(rest)), validationRedesignOptIn && labelHelp && /*#__PURE__*/React.createElement(StyledHintText, null, labelHelp), validationRedesignOptIn && /*#__PURE__*/React.createElement(ValidationMessage, {
175
+ error: internalError,
176
+ warning: internalWarning
177
+ }), /*#__PURE__*/React.createElement(StyledNumeralDate, {
167
178
  name: name,
168
179
  onKeyPress: onKeyPress,
169
180
  "data-component": "numeral-date"
@@ -173,7 +184,12 @@ const NumeralDate = ({
173
184
  const validation = error || warning || info;
174
185
  const isStringValidation = typeof validation === "string";
175
186
  const hasValidationIcon = isStringValidation && validation.length;
176
- return /*#__PURE__*/React.createElement(StyledDateField, {
187
+ return /*#__PURE__*/React.createElement(NumeralDateContext.Provider, {
188
+ value: {
189
+ disableErrorBorder: index !== 0
190
+ },
191
+ key: datePart
192
+ }, /*#__PURE__*/React.createElement(StyledDateField, {
177
193
  key: datePart,
178
194
  isYearInput: datePart.length === 4,
179
195
  isMiddle: isMiddle,
@@ -196,14 +212,14 @@ const NumeralDate = ({
196
212
  info: !!info
197
213
  }, required && {
198
214
  required
199
- }, isEnd && !validationOnLabel && {
215
+ }, isEnd && !validationRedesignOptIn && !validationOnLabel && {
200
216
  error: internalError,
201
217
  warning: internalWarning,
202
218
  info
203
219
  }, {
204
220
  size: size,
205
221
  tooltipPosition: tooltipPosition
206
- })));
222
+ }))));
207
223
  })))));
208
224
  };
209
225
 
@@ -1,7 +1,7 @@
1
1
  export default SelectText;
2
2
  declare function SelectText({ disabled, formattedValue, onClick, onKeyDown, onFocus, onBlur, onMouseDown, placeholder, readOnly, textId, transparent, }: {
3
3
  disabled: any;
4
- formattedValue: any;
4
+ formattedValue?: string | undefined;
5
5
  onClick: any;
6
6
  onKeyDown: any;
7
7
  onFocus: any;
@@ -1,12 +1,11 @@
1
1
  import React, { useContext } from "react";
2
2
  import PropTypes from "prop-types";
3
3
  import StyledSelectText from "./select-text.style";
4
- import useLocale from "../../../../hooks/__internal__/useLocale";
5
4
  import { InputContext } from "../../../../__internal__/input-behaviour";
6
5
 
7
6
  const SelectText = ({
8
7
  disabled,
9
- formattedValue,
8
+ formattedValue = "",
10
9
  onClick,
11
10
  onKeyDown,
12
11
  onFocus,
@@ -17,10 +16,8 @@ const SelectText = ({
17
16
  textId,
18
17
  transparent
19
18
  }) => {
20
- const l = useLocale();
21
19
  const inputContext = useContext(InputContext);
22
20
  const hasPlaceholder = !disabled && !readOnly && !formattedValue;
23
- const placeholderText = hasPlaceholder ? placeholder || l.select.placeholder() : "";
24
21
 
25
22
  function handleFocus(event) {
26
23
  inputContext.onFocus(event);
@@ -53,7 +50,7 @@ const SelectText = ({
53
50
  role: "button",
54
51
  tabIndex: "-1",
55
52
  transparent: transparent
56
- }, formattedValue || placeholderText);
53
+ }, hasPlaceholder ? placeholder : formattedValue);
57
54
  };
58
55
 
59
56
  SelectText.propTypes = {
@@ -119,7 +119,6 @@ const SelectTextbox = ({
119
119
 
120
120
  function getTextboxProps() {
121
121
  return {
122
- placeholder: hasTextCursor ? placeholder || l.select.placeholder() : undefined,
123
122
  disabled,
124
123
  readOnly,
125
124
  required,
@@ -147,14 +146,11 @@ const SelectTextbox = ({
147
146
  }
148
147
 
149
148
  function renderSelectText() {
150
- if (hasTextCursor) {
151
- return null;
152
- }
153
-
154
149
  return /*#__PURE__*/React.createElement(SelectText, _extends({
155
150
  textId: textId.current,
156
151
  transparent: transparent,
157
- onKeyDown: handleSelectTextKeydown
152
+ onKeyDown: handleSelectTextKeydown,
153
+ placeholder: placeholder || l.select.placeholder()
158
154
  }, getTextboxProps()));
159
155
  }
160
156
 
@@ -174,8 +170,9 @@ const SelectTextbox = ({
174
170
  autoComplete: "off",
175
171
  size: size,
176
172
  onChange: onChange,
177
- value: selectedValue
178
- }, getInputAriaAttributes(), getTextboxProps()), renderSelectText());
173
+ value: selectedValue,
174
+ placeholder: hasTextCursor ? placeholder || l.select.placeholder() : undefined
175
+ }, getInputAriaAttributes(), getTextboxProps()), !hasTextCursor && renderSelectText());
179
176
  };
180
177
 
181
178
  const formInputPropTypes = {
@@ -15,6 +15,9 @@ import StyledTextarea from "./textarea.style";
15
15
  import LocaleContext from "../../__internal__/i18n-context";
16
16
  import { TooltipProvider } from "../../__internal__/tooltip-provider";
17
17
  import useInputAccessibility from "../../hooks/__internal__/useInputAccessibility";
18
+ import { NewValidationContext } from "../carbon-provider/carbon-provider.component";
19
+ import { ErrorBorder, StyledHintText } from "../textbox/textbox.style";
20
+ import ValidationMessage from "../../__internal__/validation-message";
18
21
 
19
22
  const getFormatNumber = (value, locale) => new Intl.NumberFormat(locale).format(value);
20
23
 
@@ -59,6 +62,12 @@ const Textarea = ({
59
62
  ...props
60
63
  }) => {
61
64
  const locale = useContext(LocaleContext);
65
+ const {
66
+ validationRedesignOptIn
67
+ } = useContext(NewValidationContext);
68
+
69
+ const computeLabelPropValues = prop => validationRedesignOptIn ? undefined : prop;
70
+
62
71
  const {
63
72
  current: id
64
73
  } = useRef(idProp || guid());
@@ -134,7 +143,7 @@ const Textarea = ({
134
143
  "data-role": dataRole,
135
144
  "data-element": dataElement
136
145
  }, filterStyledSystemMarginProps(props)), /*#__PURE__*/React.createElement(FormField, {
137
- fieldHelp: fieldHelp,
146
+ fieldHelp: computeLabelPropValues(fieldHelp),
138
147
  fieldHelpId: fieldHelpId,
139
148
  error: error,
140
149
  warning: warning,
@@ -143,15 +152,19 @@ const Textarea = ({
143
152
  labelId: labelId,
144
153
  disabled: disabled,
145
154
  id: id,
146
- labelInline: labelInline,
147
- labelAlign: labelAlign,
148
- labelWidth: labelWidth,
149
- labelHelp: labelHelp,
155
+ labelInline: computeLabelPropValues(labelInline),
156
+ labelAlign: computeLabelPropValues(labelAlign),
157
+ labelWidth: computeLabelPropValues(labelWidth),
158
+ labelHelp: computeLabelPropValues(labelHelp),
150
159
  labelSpacing: labelSpacing,
151
160
  isRequired: props.required,
152
- useValidationIcon: validationOnLabel,
153
- adaptiveLabelBreakpoint: adaptiveLabelBreakpoint
154
- }, /*#__PURE__*/React.createElement(InputPresentation, {
161
+ useValidationIcon: computeLabelPropValues(validationOnLabel),
162
+ adaptiveLabelBreakpoint: adaptiveLabelBreakpoint,
163
+ validationRedesignOptIn: validationRedesignOptIn
164
+ }, validationRedesignOptIn && labelHelp && /*#__PURE__*/React.createElement(StyledHintText, null, labelHelp), validationRedesignOptIn && /*#__PURE__*/React.createElement(ValidationMessage, {
165
+ error: error,
166
+ warning: warning
167
+ }), /*#__PURE__*/React.createElement(InputPresentation, {
155
168
  size: size,
156
169
  disabled: disabled,
157
170
  readOnly: readOnly,
@@ -159,10 +172,12 @@ const Textarea = ({
159
172
  error: error,
160
173
  warning: warning,
161
174
  info: info
162
- }, /*#__PURE__*/React.createElement(Input, _extends({
175
+ }, validationRedesignOptIn && (error || warning) && /*#__PURE__*/React.createElement(ErrorBorder, {
176
+ warning: !!(!error && warning)
177
+ }), /*#__PURE__*/React.createElement(Input, _extends({
163
178
  "aria-invalid": !!error,
164
179
  "aria-labelledby": ariaLabelledBy,
165
- "aria-describedby": ariaDescribedBy,
180
+ "aria-describedby": validationRedesignOptIn ? undefined : ariaDescribedBy,
166
181
  autoFocus: autoFocus,
167
182
  name: name,
168
183
  value: value,
@@ -185,8 +200,8 @@ const Textarea = ({
185
200
  error: error,
186
201
  warning: warning,
187
202
  info: info,
188
- validationIconId: validationIconId,
189
- useValidationIcon: !validationOnLabel
203
+ validationIconId: validationRedesignOptIn ? undefined : validationIconId,
204
+ useValidationIcon: !(validationRedesignOptIn || validationOnLabel)
190
205
  }))), characterCount())));
191
206
  };
192
207
 
@@ -1,6 +1,6 @@
1
1
  function _extends() { _extends = Object.assign || 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); }
2
2
 
3
- import React from "react";
3
+ import React, { useContext } from "react";
4
4
  import PropTypes from "prop-types";
5
5
  import styledSystemPropTypes from "@styled-system/prop-types";
6
6
  import { filterStyledSystemMarginProps } from "../../style/utils";
@@ -13,6 +13,10 @@ import StyledPrefix from "./__internal__/prefix.style";
13
13
  import { TooltipProvider } from "../../__internal__/tooltip-provider";
14
14
  import useCharacterCount from "../../hooks/__internal__/useCharacterCount";
15
15
  import useInputAccessibility from "../../hooks/__internal__/useInputAccessibility/useInputAccessibility";
16
+ import { ErrorBorder, StyledHintText } from "./textbox.style";
17
+ import ValidationMessage from "../../__internal__/validation-message";
18
+ import { NewValidationContext } from "../carbon-provider/carbon-provider.component";
19
+ import NumeralDateContext from "../numeral-date/numeral-date-context";
16
20
  const marginPropTypes = filterStyledSystemMarginProps(styledSystemPropTypes.space);
17
21
 
18
22
  const Textbox = ({
@@ -70,6 +74,15 @@ const Textbox = ({
70
74
  ...props
71
75
  }) => {
72
76
  const [maxLength, characterCount] = useCharacterCount(value, characterLimit, warnOverLimit, enforceCharacterLimit);
77
+ const {
78
+ validationRedesignOptIn
79
+ } = useContext(NewValidationContext);
80
+ const {
81
+ disableErrorBorder
82
+ } = useContext(NumeralDateContext);
83
+
84
+ const computeLabelPropValues = prop => validationRedesignOptIn ? undefined : prop;
85
+
73
86
  const {
74
87
  labelId: internalLabelId,
75
88
  validationIconId,
@@ -90,29 +103,35 @@ const Textbox = ({
90
103
  tooltipPosition: tooltipPosition
91
104
  }, /*#__PURE__*/React.createElement(InputBehaviour, null, /*#__PURE__*/React.createElement(FormField, _extends({
92
105
  disabled: disabled,
93
- fieldHelp: fieldHelp,
94
106
  fieldHelpId: fieldHelpId,
107
+ fieldHelp: computeLabelPropValues(fieldHelp),
95
108
  error: error,
96
109
  warning: warning,
97
110
  info: info,
98
111
  label: label,
99
112
  labelId: labelId,
100
- labelAlign: labelAlign,
101
- labelHelp: labelHelp,
102
- labelInline: labelInline,
113
+ labelAlign: computeLabelPropValues(labelAlign),
114
+ labelHelp: computeLabelPropValues(labelHelp),
115
+ labelInline: computeLabelPropValues(labelInline),
103
116
  labelSpacing: labelSpacing,
104
- labelWidth: labelWidth,
117
+ labelWidth: computeLabelPropValues(labelWidth),
105
118
  id: id,
106
- reverse: reverse,
119
+ reverse: computeLabelPropValues(reverse),
107
120
  isOptional: isOptional,
108
- useValidationIcon: validationOnLabel,
121
+ useValidationIcon: computeLabelPropValues(validationOnLabel),
109
122
  adaptiveLabelBreakpoint: adaptiveLabelBreakpoint,
110
123
  isRequired: required,
111
124
  "data-component": dataComponent,
112
125
  "data-role": dataRole,
113
126
  "data-element": dataElement,
114
- validationIconId: validationIconId
115
- }, filterStyledSystemMarginProps(props)), /*#__PURE__*/React.createElement(InputPresentation, {
127
+ validationIconId: validationRedesignOptIn ? undefined : validationIconId,
128
+ validationRedesignOptIn: validationRedesignOptIn,
129
+ size: size,
130
+ readOnly: readOnly
131
+ }, filterStyledSystemMarginProps(props)), validationRedesignOptIn && labelHelp && /*#__PURE__*/React.createElement(StyledHintText, null, labelHelp), validationRedesignOptIn && /*#__PURE__*/React.createElement(ValidationMessage, {
132
+ error: error,
133
+ warning: warning
134
+ }), /*#__PURE__*/React.createElement(InputPresentation, {
116
135
  align: align,
117
136
  disabled: disabled,
118
137
  readOnly: readOnly,
@@ -122,15 +141,17 @@ const Textbox = ({
122
141
  info: info,
123
142
  inputWidth: inputWidth || 100 - labelWidth,
124
143
  positionedChildren: positionedChildren
125
- }, leftChildren, prefix ? /*#__PURE__*/React.createElement(StyledPrefix, {
144
+ }, leftChildren, prefix && /*#__PURE__*/React.createElement(StyledPrefix, {
126
145
  "data-element": "textbox-prefix"
127
- }, prefix) : null, /*#__PURE__*/React.createElement(Input, _extends({}, required && {
146
+ }, prefix), validationRedesignOptIn && !disableErrorBorder && (error || warning) && /*#__PURE__*/React.createElement(ErrorBorder, {
147
+ warning: !!(!error && warning)
148
+ }), /*#__PURE__*/React.createElement(Input, _extends({}, required && {
128
149
  required
129
150
  }, {
130
151
  align: align,
131
152
  "aria-invalid": !!error,
132
153
  "aria-labelledby": labelId,
133
- "aria-describedby": ariaDescribedBy,
154
+ "aria-describedby": validationRedesignOptIn ? undefined : ariaDescribedBy,
134
155
  autoFocus: autoFocus,
135
156
  deferTimeout: deferTimeout,
136
157
  disabled: disabled,
@@ -158,9 +179,9 @@ const Textbox = ({
158
179
  onMouseDown: iconOnMouseDown || onMouseDown,
159
180
  readOnly: readOnly,
160
181
  size: size,
161
- useValidationIcon: !validationOnLabel,
182
+ useValidationIcon: !(validationRedesignOptIn || validationOnLabel),
162
183
  warning: warning,
163
- validationIconId: validationIconId
184
+ validationIconId: validationRedesignOptIn ? undefined : validationIconId
164
185
  }))), characterCount));
165
186
  };
166
187
 
@@ -20,7 +20,7 @@ export interface CommonTextboxProps
20
20
  "data-role"?: string;
21
21
  /** Breakpoint for adaptive label (inline labels change to top aligned). Enables the adaptive behaviour when set */
22
22
  adaptiveLabelBreakpoint?: number;
23
- /** Integer to determine a timeout for the defered callback */
23
+ /** Integer to determine a timeout for the deferred callback */
24
24
  deferTimeout?: number;
25
25
  /** If true, the component will be disabled */
26
26
  disabled?: boolean;