carbon-react 144.4.1 → 144.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.
Files changed (45) hide show
  1. package/esm/__internal__/checkable-input/checkable-input.style.js +5 -2
  2. package/esm/__internal__/label/label.component.d.ts +4 -2
  3. package/esm/__internal__/label/label.component.js +3 -1
  4. package/esm/__internal__/label/label.style.d.ts +2 -0
  5. package/esm/__internal__/label/label.style.js +5 -1
  6. package/esm/__internal__/validation-message/validation-message.component.d.ts +3 -1
  7. package/esm/__internal__/validation-message/validation-message.component.js +4 -2
  8. package/esm/__internal__/validation-message/validation-message.style.d.ts +1 -0
  9. package/esm/__internal__/validation-message/validation-message.style.js +11 -7
  10. package/esm/components/flat-table/flat-table.component.d.ts +3 -1
  11. package/esm/components/flat-table/flat-table.component.js +3 -1
  12. package/esm/components/switch/__internal__/switch-slider-panel.style.d.ts +1 -0
  13. package/esm/components/switch/__internal__/switch-slider-panel.style.js +6 -4
  14. package/esm/components/switch/__internal__/switch-slider.component.d.ts +2 -1
  15. package/esm/components/switch/__internal__/switch-slider.component.js +6 -3
  16. package/esm/components/switch/__internal__/switch-slider.style.d.ts +2 -1
  17. package/esm/components/switch/__internal__/switch-slider.style.js +7 -6
  18. package/esm/components/switch/switch.component.d.ts +2 -0
  19. package/esm/components/switch/switch.component.js +64 -18
  20. package/esm/components/switch/switch.style.d.ts +6 -1
  21. package/esm/components/switch/switch.style.js +29 -16
  22. package/esm/components/time/time.style.d.ts +1 -1
  23. package/lib/__internal__/checkable-input/checkable-input.style.js +5 -2
  24. package/lib/__internal__/label/label.component.d.ts +4 -2
  25. package/lib/__internal__/label/label.component.js +3 -1
  26. package/lib/__internal__/label/label.style.d.ts +2 -0
  27. package/lib/__internal__/label/label.style.js +5 -1
  28. package/lib/__internal__/validation-message/validation-message.component.d.ts +3 -1
  29. package/lib/__internal__/validation-message/validation-message.component.js +4 -2
  30. package/lib/__internal__/validation-message/validation-message.style.d.ts +1 -0
  31. package/lib/__internal__/validation-message/validation-message.style.js +11 -7
  32. package/lib/components/flat-table/flat-table.component.d.ts +3 -1
  33. package/lib/components/flat-table/flat-table.component.js +3 -1
  34. package/lib/components/switch/__internal__/switch-slider-panel.style.d.ts +1 -0
  35. package/lib/components/switch/__internal__/switch-slider-panel.style.js +6 -4
  36. package/lib/components/switch/__internal__/switch-slider.component.d.ts +2 -1
  37. package/lib/components/switch/__internal__/switch-slider.component.js +6 -3
  38. package/lib/components/switch/__internal__/switch-slider.style.d.ts +2 -1
  39. package/lib/components/switch/__internal__/switch-slider.style.js +7 -6
  40. package/lib/components/switch/switch.component.d.ts +2 -0
  41. package/lib/components/switch/switch.component.js +64 -18
  42. package/lib/components/switch/switch.style.d.ts +6 -1
  43. package/lib/components/switch/switch.style.js +29 -16
  44. package/lib/components/time/time.style.d.ts +1 -1
  45. package/package.json +1 -1
@@ -1,10 +1,10 @@
1
1
  import styled, { css } from "styled-components";
2
2
  import FieldHelpStyle from "../field-help/field-help.style";
3
3
  import { FieldLineStyle } from "../form-field/form-field.style";
4
- import HiddenCheckableInputStyle from "./hidden-checkable-input.style";
5
4
  import LabelStyle, { StyledLabelContainer } from "../label/label.style";
6
- import StyledHelp from "../../components/help/help.style";
7
5
  import StyledValidationIcon from "../validations/validation-icon.style";
6
+ import StyledHelp from "../../components/help/help.style";
7
+ import HiddenCheckableInputStyle from "./hidden-checkable-input.style";
8
8
  const StyledCheckableInput = styled.div`
9
9
  display: inline-block;
10
10
  position: relative;
@@ -18,6 +18,8 @@ const StyledCheckableInputWrapper = styled.div`
18
18
  labelInline,
19
19
  reverse
20
20
  }) => css`
21
+ width: 100% !important;
22
+
21
23
  ${FieldLineStyle} {
22
24
  display: flex;
23
25
  }
@@ -86,6 +88,7 @@ const StyledCheckableInputWrapper = styled.div`
86
88
  ${inputWidth !== undefined && inputWidth !== 0 && css`
87
89
  ${StyledCheckableInput} {
88
90
  width: ${inputWidth}% !important;
91
+ min-width: 67px;
89
92
  }
90
93
  `}
91
94
 
@@ -24,7 +24,9 @@ export interface LabelProps extends ValidationProps, StyledLabelProps, StyledLab
24
24
  className?: string;
25
25
  /** Sets aria-label for label element */
26
26
  "aria-label"?: string;
27
+ /** Whether this component is shown against a dark background */
28
+ isDarkBackground?: boolean;
27
29
  }
28
- export declare const Label: ({ align, as, children, disabled, error, help, helpIcon, htmlFor, info, inline, isRequired, labelId, optional, pr, pl, tooltipId, useValidationIcon, validationIconId, warning, width, className, "aria-label": ariaLabel, }: LabelProps) => React.JSX.Element;
29
- declare const _default: React.MemoExoticComponent<({ align, as, children, disabled, error, help, helpIcon, htmlFor, info, inline, isRequired, labelId, optional, pr, pl, tooltipId, useValidationIcon, validationIconId, warning, width, className, "aria-label": ariaLabel, }: LabelProps) => React.JSX.Element>;
30
+ export declare const Label: ({ align, as, children, disabled, error, help, helpIcon, htmlFor, info, inline, isDarkBackground, isRequired, labelId, optional, pr, pl, tooltipId, useValidationIcon, validationIconId, warning, width, className, "aria-label": ariaLabel, }: LabelProps) => React.JSX.Element;
31
+ declare const _default: React.MemoExoticComponent<({ align, as, children, disabled, error, help, helpIcon, htmlFor, info, inline, isDarkBackground, isRequired, labelId, optional, pr, pl, tooltipId, useValidationIcon, validationIconId, warning, width, className, "aria-label": ariaLabel, }: LabelProps) => React.JSX.Element>;
30
32
  export default _default;
@@ -34,6 +34,7 @@ export const Label = ({
34
34
  htmlFor,
35
35
  info,
36
36
  inline,
37
+ isDarkBackground = false,
37
38
  isRequired,
38
39
  labelId,
39
40
  optional,
@@ -116,7 +117,8 @@ export const Label = ({
116
117
  onMouseLeave: handleMouseLeave,
117
118
  isRequired: isRequired,
118
119
  as: as,
119
- "aria-label": ariaLabel
120
+ "aria-label": ariaLabel,
121
+ isDarkBackground: isDarkBackground
120
122
  }), children), icon());
121
123
  };
122
124
  export default /*#__PURE__*/React.memo(Label);
@@ -3,6 +3,8 @@ export interface StyledLabelProps {
3
3
  disabled?: boolean;
4
4
  /** Flag to configure component as mandatory */
5
5
  isRequired?: boolean;
6
+ /** Flag to determine whether to use colours for dark backgrounds */
7
+ isDarkBackground?: boolean;
6
8
  }
7
9
  declare const StyledLabel: import("styled-components").StyledComponent<"label", any, StyledLabelProps, never>;
8
10
  export interface StyledLabelContainerProps {
@@ -1,6 +1,10 @@
1
1
  import styled, { css } from "styled-components";
2
2
  const StyledLabel = styled.label`
3
- color: var(--colorsUtilityYin090);
3
+ ${({
4
+ isDarkBackground
5
+ }) => css`
6
+ color: ${isDarkBackground ? "var(--colorsUtilityYang100)" : "var(--colorsUtilityYin090)"};
7
+ `}
4
8
  display: block;
5
9
  font-weight: var(--fontWeights500);
6
10
 
@@ -8,6 +8,8 @@ export interface ValidationMessageProps {
8
8
  /** Indicate that warning has occurred
9
9
  Pass string to display hint with warning */
10
10
  warning?: boolean | string;
11
+ /** Whether this component resides on a dark background */
12
+ isDarkBackground?: boolean;
11
13
  }
12
- declare const ValidationMessage: ({ error, validationId, warning, }: ValidationMessageProps) => React.JSX.Element | null;
14
+ declare const ValidationMessage: ({ error, validationId, warning, isDarkBackground, }: ValidationMessageProps) => React.JSX.Element | null;
13
15
  export default ValidationMessage;
@@ -4,14 +4,16 @@ import StyledValidationMessage from "./validation-message.style";
4
4
  const ValidationMessage = ({
5
5
  error,
6
6
  validationId,
7
- warning
7
+ warning,
8
+ isDarkBackground
8
9
  }) => {
9
10
  const validation = error || warning;
10
11
  const isStringValidation = typeof validation === "string";
11
12
  return isStringValidation ? /*#__PURE__*/React.createElement(StyledValidationMessage, {
12
13
  id: validationId,
13
14
  isWarning: !!(!error && warning),
14
- "data-role": "validation-message"
15
+ "data-role": "validation-message",
16
+ isDarkBackground: isDarkBackground
15
17
  }, validation) : null;
16
18
  };
17
19
  export default ValidationMessage;
@@ -1,5 +1,6 @@
1
1
  interface StyledValidationMessageProps {
2
2
  isWarning?: boolean;
3
+ isDarkBackground?: boolean;
3
4
  }
4
5
  declare const StyledValidationMessage: import("styled-components").StyledComponent<"p", any, StyledValidationMessageProps, never>;
5
6
  export default StyledValidationMessage;
@@ -1,12 +1,16 @@
1
1
  import styled, { css } from "styled-components";
2
2
  const StyledValidationMessage = styled.p`
3
3
  ${({
4
- isWarning
5
- }) => css`
6
- color: ${isWarning ? "var(--colorsSemanticCaution600)" : "var(--colorsSemanticNegative500)"};
7
- font-weight: ${isWarning ? "normal" : "500"};
8
- margin-top: 0px;
9
- margin-bottom: 8px;
10
- `}
4
+ isWarning,
5
+ isDarkBackground
6
+ }) => {
7
+ const darkBgColour = isDarkBackground ? "var(--colorsSemanticNegative450)" : "var(--colorsSemanticNegative500)";
8
+ return css`
9
+ color: ${isWarning ? "var(--colorsSemanticCaution600)" : darkBgColour};
10
+ font-weight: ${isWarning ? "normal" : "500"};
11
+ margin-top: 0px;
12
+ margin-bottom: 8px;
13
+ `;
14
+ }}
11
15
  `;
12
16
  export default StyledValidationMessage;
@@ -35,9 +35,11 @@ export interface FlatTableProps extends MarginProps, Omit<TagProps, "data-compon
35
35
  overflowX?: string;
36
36
  /** Width of the table. Any valid CSS string */
37
37
  width?: string;
38
+ /** The title to describe the table when one or more tables are used on a single page */
39
+ title?: string;
38
40
  }
39
41
  export declare const FlatTable: {
40
- ({ caption, children, hasStickyHead, colorTheme, footer, hasStickyFooter, height, isZebra, size, hasMaxHeight, hasOuterVerticalBorders, bottomBorderRadius, ariaDescribedby, minHeight, overflowX, width, ...rest }: FlatTableProps): React.JSX.Element;
42
+ ({ caption, children, hasStickyHead, colorTheme, footer, hasStickyFooter, height, isZebra, size, hasMaxHeight, hasOuterVerticalBorders, bottomBorderRadius, ariaDescribedby, minHeight, overflowX, width, title, ...rest }: FlatTableProps): React.JSX.Element;
41
43
  displayName: string;
42
44
  };
43
45
  export default FlatTable;
@@ -23,6 +23,7 @@ export const FlatTable = ({
23
23
  minHeight,
24
24
  overflowX,
25
25
  width,
26
+ title,
26
27
  ...rest
27
28
  }) => {
28
29
  const wrapperRef = useRef(null);
@@ -162,7 +163,8 @@ export const FlatTable = ({
162
163
  onKeyDown: handleKeyDown,
163
164
  isFocused: focused
164
165
  }, rest, {
165
- "data-component": "flat-table-wrapper"
166
+ "data-component": "flat-table-wrapper",
167
+ title: title
166
168
  }), /*#__PURE__*/React.createElement(StyledTableContainer, {
167
169
  ref: container,
168
170
  onFocus: () => {
@@ -2,6 +2,7 @@ import { SwitchProps } from "../switch.component";
2
2
  export interface SwitchSliderPanelProps {
3
3
  isLoading?: boolean;
4
4
  size?: SwitchProps["size"];
5
+ isDarkBackground?: boolean;
5
6
  }
6
7
  declare const SwitchSliderPanel: import("styled-components").StyledComponent<"div", any, SwitchSliderPanelProps, never>;
7
8
  export default SwitchSliderPanel;
@@ -1,24 +1,26 @@
1
1
  import styled, { css } from "styled-components";
2
- import StyledLoader from "../../loader/loader.style";
3
2
  import StyledLoaderSquare from "../../loader/loader-square.style";
3
+ import StyledLoader from "../../loader/loader.style";
4
4
  const SwitchSliderPanel = styled.div`
5
5
  ${({
6
6
  isLoading,
7
- size
7
+ size,
8
+ isDarkBackground
8
9
  }) => css`
9
10
  border: 0;
10
- color: var(--colorsActionMinorYang100);
11
+ color: ${isDarkBackground ? "var(--colorsUtilityYin100)" : "var(--colorsActionMinorYang100)"};
11
12
  margin: auto;
12
13
  position: absolute;
13
14
  left: 0;
14
15
 
15
16
  &[type="on"] {
17
+ color: ${isDarkBackground ? "var(--colorsUtilityYin100)" : "var(--colorsUtilityYang100)"};
16
18
  margin-left: 9px;
17
19
  padding-right: ${size === "large" ? "43px" : "27px"};
18
20
  }
19
21
 
20
22
  &[type="off"] {
21
- color: var(--colorsActionMinor500);
23
+ color: ${isDarkBackground ? "var(--colorsUtilityYang100)" : "var(--colorsActionMinor500)"};
22
24
  margin-right: 9px;
23
25
  padding-left: ${size === "large" ? "43px" : "27px"};
24
26
  }
@@ -6,6 +6,7 @@ export interface SwitchSliderProps extends ValidationProps {
6
6
  loading?: boolean;
7
7
  size?: "small" | "large";
8
8
  useValidationIcon?: boolean;
9
+ isDarkBackground?: boolean;
9
10
  }
10
- declare const SwitchSlider: ({ checked, disabled, loading, size, error, warning, info, useValidationIcon, }: SwitchSliderProps) => React.JSX.Element;
11
+ declare const SwitchSlider: ({ checked, disabled, loading, size, error, warning, info, useValidationIcon, isDarkBackground, }: SwitchSliderProps) => React.JSX.Element;
11
12
  export default SwitchSlider;
@@ -14,7 +14,8 @@ const SwitchSlider = ({
14
14
  error,
15
15
  warning,
16
16
  info,
17
- useValidationIcon
17
+ useValidationIcon,
18
+ isDarkBackground
18
19
  }) => {
19
20
  const locale = useLocale();
20
21
  const onText = locale.switch.on();
@@ -31,13 +32,15 @@ const SwitchSlider = ({
31
32
  size,
32
33
  error,
33
34
  warning,
34
- info
35
+ info,
36
+ isDarkBackground
35
37
  };
36
38
  const sliderPanelStyleProps = {
37
39
  isLoading: loading,
38
40
  size,
39
41
  type: checked ? "on" : "off",
40
- disabled
42
+ disabled,
43
+ isDarkBackground
41
44
  };
42
45
  const loaderProps = {
43
46
  isInsideButton: true,
@@ -1,8 +1,9 @@
1
- import { SwitchSliderProps } from "./switch-slider.component";
2
1
  import { ThemeObject } from "../../../style/themes/base";
2
+ import { SwitchSliderProps } from "./switch-slider.component";
3
3
  interface StyledSwitchSliderProps extends Pick<SwitchSliderProps, "checked" | "disabled" | "size" | "error" | "warning"> {
4
4
  isLoading?: boolean;
5
5
  theme?: Partial<ThemeObject>;
6
+ isDarkBackground?: boolean;
6
7
  }
7
8
  declare const StyledSwitchSlider: import("styled-components").StyledComponent<"div", any, {}, never>;
8
9
  declare const HiddenContent: import("styled-components").StyledComponent<"div", any, Pick<StyledSwitchSliderProps, "size">, never>;
@@ -1,7 +1,7 @@
1
1
  import styled, { css } from "styled-components";
2
- import SwitchSliderPanel from "./switch-slider-panel.style";
3
2
  import StyledValidationIcon from "../../../__internal__/validations/validation-icon.style";
4
3
  import baseTheme from "../../../style/themes/base";
4
+ import SwitchSliderPanel from "./switch-slider-panel.style";
5
5
  const StyledSwitchSlider = styled.div`
6
6
  ${({
7
7
  checked,
@@ -10,7 +10,8 @@ const StyledSwitchSlider = styled.div`
10
10
  size,
11
11
  error,
12
12
  warning,
13
- theme
13
+ theme,
14
+ isDarkBackground
14
15
  }) => css`
15
16
  display: flex;
16
17
  font-size: 12px;
@@ -25,14 +26,14 @@ const StyledSwitchSlider = styled.div`
25
26
  z-index: 2;
26
27
  border-radius: ${theme?.roundedCornersOptOut ? "90px" : "var(--borderRadius400)"};
27
28
  border-style: solid;
28
- border-color: var(--colorsActionMinor400);
29
+ border-color: ${isDarkBackground ? "var(--colorsUtilityYang100)" : "var(--colorsActionMinor400)"};
29
30
  border-width: var(--borderWidth200);
30
31
  box-sizing: border-box;
31
32
  margin-top: ${size === "large" ? "-47px" : "-28px"};
32
33
  align-items: center;
33
34
 
34
35
  &::before {
35
- background-color: var(--colorsActionMinor400);
36
+ background-color: ${isDarkBackground ? "var(--colorsUtilityYang100)" : "var(--colorsActionMinor400)"};
36
37
  bottom: 4px;
37
38
  content: "";
38
39
  height: ${size === "large" ? "var(--spacing400)" : "var(--spacing200)"};
@@ -45,7 +46,7 @@ const StyledSwitchSlider = styled.div`
45
46
  }
46
47
 
47
48
  ${checked && css`
48
- background-color: var(--colorsActionMinor500);
49
+ background-color: ${isDarkBackground ? "var(--colorsUtilityYang100)" : "var(--colorsActionMinor500)"};
49
50
  border-color: var(--colorsActionMinorTransparent);
50
51
 
51
52
  &::before {
@@ -53,7 +54,7 @@ const StyledSwitchSlider = styled.div`
53
54
  100% -
54
55
  ${size === "large" ? "var(--spacing500)" : "var(--spacing300)"}
55
56
  );
56
- background-color: var(--colorsActionMinorYang100);
57
+ background-color: ${isDarkBackground ? "var(--colorsUtilityYin100)" : "var(--colorsActionMinorYang100)"};
57
58
  }
58
59
  `}
59
60
 
@@ -24,6 +24,8 @@ export interface SwitchProps extends CommonCheckableInputProps, MarginProps {
24
24
  tooltipPosition?: "top" | "bottom" | "left" | "right";
25
25
  /** [Legacy] Aria label for rendered help component */
26
26
  helpAriaLabel?: string;
27
+ /** Whether this component resides on a dark background */
28
+ isDarkBackground?: boolean;
27
29
  }
28
30
  export declare const Switch: React.ForwardRefExoticComponent<SwitchProps & React.RefAttributes<HTMLInputElement>>;
29
31
  export default Switch;
@@ -1,17 +1,17 @@
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, { useState, useCallback, useContext, useRef } from "react";
3
3
  import PropTypes from "prop-types";
4
- import StyledSwitch, { ErrorBorder, StyledHintText } from "./switch.style";
4
+ import Box from "../box";
5
5
  import CheckableInput from "../../__internal__/checkable-input";
6
- import SwitchSlider from "./__internal__/switch-slider.component";
7
- import useIsAboveBreakpoint from "../../hooks/__internal__/useIsAboveBreakpoint";
6
+ import Label from "../../__internal__/label";
8
7
  import { TooltipProvider } from "../../__internal__/tooltip-provider";
9
- import Logger from "../../__internal__/utils/logger";
10
- import useFormSpacing from "../../hooks/__internal__/useFormSpacing";
11
8
  import NewValidationContext from "../carbon-provider/__internal__/new-validation.context";
9
+ import Logger from "../../__internal__/utils/logger";
12
10
  import ValidationMessage from "../../__internal__/validation-message/validation-message.component";
13
- import Box from "../box";
14
- import Label from "../../__internal__/label";
11
+ import useFormSpacing from "../../hooks/__internal__/useFormSpacing";
12
+ import useIsAboveBreakpoint from "../../hooks/__internal__/useIsAboveBreakpoint";
13
+ import StyledSwitch, { ErrorBorder, StyledHintText } from "./switch.style";
14
+ import SwitchSlider from "./__internal__/switch-slider.component";
15
15
  import guid from "../../__internal__/utils/helpers/guid";
16
16
  let deprecateUncontrolledWarnTriggered = false;
17
17
  const Switch = /*#__PURE__*/React.forwardRef(({
@@ -45,6 +45,7 @@ const Switch = /*#__PURE__*/React.forwardRef(({
45
45
  "data-element": dataElement,
46
46
  "data-role": dataRole,
47
47
  helpAriaLabel,
48
+ isDarkBackground = false,
48
49
  ...rest
49
50
  }, ref) => {
50
51
  const isControlled = checked !== undefined;
@@ -77,6 +78,7 @@ const Switch = /*#__PURE__*/React.forwardRef(({
77
78
  "data-role": dataRole,
78
79
  "data-element": dataElement,
79
80
  checked: isControlled ? checked : checkedInternal,
81
+ isDarkBackground,
80
82
  fieldHelpInline,
81
83
  labelInline: shouldLabelBeInline,
82
84
  labelSpacing,
@@ -89,6 +91,7 @@ const Switch = /*#__PURE__*/React.forwardRef(({
89
91
  checked: isControlled ? checked : checkedInternal,
90
92
  disabled: disabled || loading,
91
93
  loading,
94
+ isDarkBackground,
92
95
  size,
93
96
  error,
94
97
  warning,
@@ -109,6 +112,7 @@ const Switch = /*#__PURE__*/React.forwardRef(({
109
112
  labelInline: shouldLabelBeInline,
110
113
  labelSpacing,
111
114
  onBlur,
115
+ isDarkBackground,
112
116
  onFocus,
113
117
  onChange: isControlled ? onChange : onChangeInternal,
114
118
  id,
@@ -132,6 +136,8 @@ const Switch = /*#__PURE__*/React.forwardRef(({
132
136
  "data-role": dataRole,
133
137
  "data-element": dataElement,
134
138
  checked: isControlled ? checked : checkedInternal,
139
+ labelInline: shouldLabelBeInline,
140
+ isDarkBackground,
135
141
  size,
136
142
  ...marginProps
137
143
  };
@@ -139,6 +145,7 @@ const Switch = /*#__PURE__*/React.forwardRef(({
139
145
  checked: isControlled ? checked : checkedInternal,
140
146
  disabled: disabled || loading,
141
147
  loading,
148
+ isDarkBackground,
142
149
  size,
143
150
  error,
144
151
  warning
@@ -147,10 +154,12 @@ const Switch = /*#__PURE__*/React.forwardRef(({
147
154
  autoFocus,
148
155
  // set aria-invalid but prevent validationIconId from being added to aria-describedby
149
156
  error: !!error,
157
+ warning,
150
158
  disabled: disabled || loading,
151
159
  loading,
152
160
  checked: isControlled ? checked : checkedInternal,
153
161
  onBlur,
162
+ isDarkBackground,
154
163
  onFocus,
155
164
  onChange: isControlled ? onChange : onChangeInternal,
156
165
  id,
@@ -165,30 +174,66 @@ const Switch = /*#__PURE__*/React.forwardRef(({
165
174
  };
166
175
  const applyValidation = error || warning;
167
176
  const ariaDescribedBy = [labelHelp && inputHintId.current, applyValidation && validationMessageId.current].filter(Boolean).join(" ");
168
- return /*#__PURE__*/React.createElement(React.Fragment, null, validationRedesignOptIn ? /*#__PURE__*/React.createElement(StyledSwitch, switchStylePropsForNewValidation, /*#__PURE__*/React.createElement(Label, {
177
+ if (!validationRedesignOptIn) {
178
+ return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(TooltipProvider, {
179
+ helpAriaLabel: helpAriaLabel,
180
+ tooltipPosition: tooltipPosition
181
+ }, /*#__PURE__*/React.createElement(StyledSwitch, switchStyleProps, /*#__PURE__*/React.createElement(CheckableInput, inputProps, /*#__PURE__*/React.createElement(SwitchSlider, switchSliderProps)))));
182
+ }
183
+ const defaultMargin = labelInline ? 1 : 0;
184
+ const defaultInputWrapperMargin = labelInline ? 3 : 0;
185
+ const errorMargin = error || warning ? defaultInputWrapperMargin : defaultMargin;
186
+ const direction = labelInline ? "row" : "column";
187
+ const reverseDirection = labelInline ? "row-reverse" : "column";
188
+ return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(StyledSwitch, switchStylePropsForNewValidation, /*#__PURE__*/React.createElement(Box, {
189
+ "data-role": "field-reverse-wrapper",
190
+ display: "flex",
191
+ flexWrap: "wrap",
192
+ alignItems: error || warning ? "flex-start" : undefined,
193
+ flexDirection: !reverse ? reverseDirection : direction,
194
+ width: labelInline ? "100%" : "auto"
195
+ }, /*#__PURE__*/React.createElement(Box, {
196
+ "data-role": "label-wrapper"
197
+ // width={labelInline ? rest.labelWidth : 30}
198
+ // minWidth={label && labelInline ? "32px" : 0}
199
+ }, /*#__PURE__*/React.createElement(Label, {
200
+ isDarkBackground: isDarkBackground,
169
201
  labelId: labelId.current,
170
202
  disabled: disabled,
171
203
  isRequired: required,
172
204
  optional: isOptional
173
- }, label), labelHelp && /*#__PURE__*/React.createElement(StyledHintText, {
205
+ }, label), labelHelp && /*#__PURE__*/React.createElement(Box, {
206
+ "data-role": "hint-text-wrapper",
207
+ mb: labelInline ? 0 : 1,
208
+ mr: reverse ? 0 : 1,
209
+ ml: reverse ? 0 : 1
210
+ }, /*#__PURE__*/React.createElement(StyledHintText, {
174
211
  "data-role": "hint-text",
175
- id: inputHintId.current
176
- }, labelHelp), /*#__PURE__*/React.createElement(Box, {
177
- position: "relative"
212
+ id: inputHintId.current,
213
+ isDarkBackground: isDarkBackground
214
+ }, labelHelp))), /*#__PURE__*/React.createElement(Box, {
215
+ ml: reverse ? errorMargin : defaultInputWrapperMargin,
216
+ mr: !reverse ? errorMargin : defaultInputWrapperMargin,
217
+ position: "relative",
218
+ id: "input-wrapper"
178
219
  }, /*#__PURE__*/React.createElement(ValidationMessage, {
179
220
  error: error,
180
221
  warning: warning,
181
- validationId: validationMessageId.current
222
+ validationId: validationMessageId.current,
223
+ isDarkBackground: isDarkBackground
182
224
  }), applyValidation && /*#__PURE__*/React.createElement(ErrorBorder, {
183
225
  "data-role": "error-border",
184
- warning: !!(!error && warning)
226
+ warning: !!(!error && warning),
227
+ reverse: !reverse,
228
+ isDarkBackground: isDarkBackground
185
229
  }), /*#__PURE__*/React.createElement(CheckableInput, _extends({
186
230
  ariaLabelledBy: `${label && labelId.current}`,
187
231
  ariaDescribedBy: ariaDescribedBy
188
- }, inputPropsForNewValidation), /*#__PURE__*/React.createElement(SwitchSlider, switchSliderPropsForNewValidation)))) : /*#__PURE__*/React.createElement(TooltipProvider, {
189
- helpAriaLabel: helpAriaLabel,
190
- tooltipPosition: tooltipPosition
191
- }, /*#__PURE__*/React.createElement(StyledSwitch, switchStyleProps, /*#__PURE__*/React.createElement(CheckableInput, inputProps, /*#__PURE__*/React.createElement(SwitchSlider, switchSliderProps)))));
232
+ }, inputPropsForNewValidation, {
233
+ fieldHelp: labelInline ? undefined : rest.fieldHelp
234
+ }), /*#__PURE__*/React.createElement(SwitchSlider, switchSliderPropsForNewValidation))))), labelInline && rest.fieldHelp && /*#__PURE__*/React.createElement(Box, {
235
+ color: isDarkBackground ? "var(--colorsUtilityYang100)" : "var(--colorsUtilityYin090)"
236
+ }, rest.fieldHelp));
192
237
  });
193
238
  if (process.env.NODE_ENV !== "production") {
194
239
  Switch.propTypes = {
@@ -341,6 +386,7 @@ if (process.env.NODE_ENV !== "production") {
341
386
  "inputMode": PropTypes.oneOf(["decimal", "email", "none", "numeric", "search", "tel", "text", "url"]),
342
387
  "inputWidth": PropTypes.number,
343
388
  "is": PropTypes.string,
389
+ "isDarkBackground": PropTypes.bool,
344
390
  "isOptional": PropTypes.bool,
345
391
  "itemID": PropTypes.string,
346
392
  "itemProp": PropTypes.string,
@@ -1,6 +1,11 @@
1
+ interface StyledHintTextProps {
2
+ isDarkBackground?: boolean;
3
+ }
1
4
  export declare const ErrorBorder: import("styled-components").StyledComponent<"span", any, {
5
+ reverse: boolean;
2
6
  warning: boolean;
7
+ isDarkBackground: boolean;
3
8
  }, never>;
4
- export declare const StyledHintText: import("styled-components").StyledComponent<"div", any, {}, never>;
9
+ export declare const StyledHintText: import("styled-components").StyledComponent<"div", any, StyledHintTextProps, never>;
5
10
  declare const StyledSwitch: import("styled-components").StyledComponent<"div", any, {}, never>;
6
11
  export default StyledSwitch;
@@ -1,36 +1,46 @@
1
1
  import styled, { css } from "styled-components";
2
2
  import { margin } from "styled-system";
3
- import baseTheme from "../../style/themes/base";
4
- import FieldHelpStyle from "../../__internal__/field-help/field-help.style";
3
+ import { StyledCheckableInput } from "../../__internal__/checkable-input/checkable-input.style";
5
4
  import HiddenCheckableInputStyle from "../../__internal__/checkable-input/hidden-checkable-input.style";
5
+ import FieldHelpStyle from "../../__internal__/field-help/field-help.style";
6
+ import { FieldLineStyle } from "../../__internal__/form-field/form-field.style";
6
7
  import { StyledLabelContainer } from "../../__internal__/label/label.style";
7
- import { StyledCheckableInput } from "../../__internal__/checkable-input/checkable-input.style";
8
- import StyledSwitchSlider from "./__internal__/switch-slider.style";
9
8
  import StyledValidationIcon from "../../__internal__/validations/validation-icon.style";
10
- import { FieldLineStyle } from "../../__internal__/form-field/form-field.style";
9
+ import baseTheme from "../../style/themes/base";
11
10
  import addFocusStyling from "../../style/utils/add-focus-styling";
11
+ import StyledSwitchSlider from "./__internal__/switch-slider.style";
12
12
  const oldFocusStyling = `
13
13
  outline: solid 3px var(--colorsSemanticFocus500);
14
14
  `;
15
15
  export const ErrorBorder = styled.span`
16
16
  ${({
17
- warning
18
- }) => css`
19
- position: absolute;
20
- z-index: 6;
21
- width: 2px;
22
- background-color: ${warning ? "var(--colorsSemanticCaution500)" : "var(--colorsSemanticNegative500)"};
23
- left: -12px;
24
- bottom: -4px;
25
- top: 2px;
26
- `}
17
+ reverse,
18
+ warning,
19
+ isDarkBackground
20
+ }) => {
21
+ const darkBgColour = isDarkBackground ? "var(--colorsSemanticNegative450)" : "var(--colorsSemanticNegative500)";
22
+ return css`
23
+ position: absolute;
24
+ z-index: 6;
25
+ width: 2px;
26
+ background-color: ${warning ? "var(--colorsSemanticCaution500)" : darkBgColour};
27
+ ${reverse ? "right" : "left"}: -12px;
28
+ bottom: -4px;
29
+ top: 2px;
30
+ `;
31
+ }}
27
32
  `;
28
33
  export const StyledHintText = styled.div`
29
34
  margin-top: 8px;
30
35
  margin-bottom: 8px;
31
- color: var(--colorsUtilityYin055);
32
36
  font-size: 14px;
33
37
  font-weight: 400;
38
+ max-width: 160px;
39
+ ${({
40
+ isDarkBackground
41
+ }) => css`
42
+ color: ${isDarkBackground ? "var(--colorsUtilityYang065)" : "var(--colorsUtilityYin055)"};
43
+ `}
34
44
  `;
35
45
  const StyledSwitch = styled.div`
36
46
  ${({
@@ -51,6 +61,9 @@ const StyledSwitch = styled.div`
51
61
  `}
52
62
  }
53
63
 
64
+ display: flex;
65
+ flex-flow: ${labelInline ? "row wrap" : "column wrap"};
66
+
54
67
  ${StyledCheckableInput}, ${HiddenCheckableInputStyle} {
55
68
  border: none;
56
69
  box-sizing: border-box;
@@ -1,5 +1,5 @@
1
1
  /// <reference types="react" />
2
- export declare const StyledLabel: import("styled-components").StyledComponent<import("react").MemoExoticComponent<({ align, as, children, disabled, error, help, helpIcon, htmlFor, info, inline, isRequired, labelId, optional, pr, pl, tooltipId, useValidationIcon, validationIconId, warning, width, className, "aria-label": ariaLabel, }: import("../../__internal__/label").LabelProps) => import("react").JSX.Element>, any, {}, never>;
2
+ export declare const StyledLabel: import("styled-components").StyledComponent<import("react").MemoExoticComponent<({ align, as, children, disabled, error, help, helpIcon, htmlFor, info, inline, isDarkBackground, isRequired, labelId, optional, pr, pl, tooltipId, useValidationIcon, validationIconId, warning, width, className, "aria-label": ariaLabel, }: import("../../__internal__/label").LabelProps) => import("react").JSX.Element>, any, {}, never>;
3
3
  export declare const StyledHintText: import("styled-components").StyledComponent<"div", any, {
4
4
  isDisabled?: boolean | undefined;
5
5
  hasError?: boolean | undefined;
@@ -7,10 +7,10 @@ exports.StyledCheckableInputWrapper = exports.StyledCheckableInput = void 0;
7
7
  var _styledComponents = _interopRequireWildcard(require("styled-components"));
8
8
  var _fieldHelp = _interopRequireDefault(require("../field-help/field-help.style"));
9
9
  var _formField = require("../form-field/form-field.style");
10
- var _hiddenCheckableInput = _interopRequireDefault(require("./hidden-checkable-input.style"));
11
10
  var _label = _interopRequireWildcard(require("../label/label.style"));
12
- var _help = _interopRequireDefault(require("../../components/help/help.style"));
13
11
  var _validationIcon = _interopRequireDefault(require("../validations/validation-icon.style"));
12
+ var _help = _interopRequireDefault(require("../../components/help/help.style"));
13
+ var _hiddenCheckableInput = _interopRequireDefault(require("./hidden-checkable-input.style"));
14
14
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
15
15
  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); }
16
16
  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 && {}.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; }
@@ -27,6 +27,8 @@ const StyledCheckableInputWrapper = exports.StyledCheckableInputWrapper = _style
27
27
  labelInline,
28
28
  reverse
29
29
  }) => (0, _styledComponents.css)`
30
+ width: 100% !important;
31
+
30
32
  ${_formField.FieldLineStyle} {
31
33
  display: flex;
32
34
  }
@@ -95,6 +97,7 @@ const StyledCheckableInputWrapper = exports.StyledCheckableInputWrapper = _style
95
97
  ${inputWidth !== undefined && inputWidth !== 0 && (0, _styledComponents.css)`
96
98
  ${StyledCheckableInput} {
97
99
  width: ${inputWidth}% !important;
100
+ min-width: 67px;
98
101
  }
99
102
  `}
100
103