carbon-react 128.1.2 → 128.3.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 (112) hide show
  1. package/esm/__internal__/checkable-input/checkable-input.component.d.ts +2 -0
  2. package/esm/__internal__/checkable-input/checkable-input.component.js +4 -2
  3. package/esm/__internal__/fieldset/fieldset.style.js +7 -6
  4. package/esm/__internal__/form-field/form-field.component.d.ts +1 -1
  5. package/esm/__internal__/form-field/form-field.component.js +1 -0
  6. package/esm/__internal__/label/label.style.js +6 -5
  7. package/esm/components/checkbox/checkbox-group/checkbox-group.component.d.ts +2 -0
  8. package/esm/components/checkbox/checkbox-group/checkbox-group.component.js +5 -2
  9. package/esm/components/checkbox/checkbox.component.js +3 -0
  10. package/esm/components/date-range/date-range.component.d.ts +5 -1
  11. package/esm/components/date-range/date-range.component.js +5 -1
  12. package/esm/components/decimal/decimal.component.d.ts +0 -2
  13. package/esm/components/decimal/decimal.component.js +1 -2
  14. package/esm/components/fieldset/fieldset.component.d.ts +8 -3
  15. package/esm/components/fieldset/fieldset.component.js +16 -2
  16. package/esm/components/fieldset/fieldset.style.d.ts +4 -0
  17. package/esm/components/fieldset/fieldset.style.js +29 -2
  18. package/esm/components/file-input/file-input.component.d.ts +4 -0
  19. package/esm/components/file-input/file-input.component.js +3 -0
  20. package/esm/components/form/index.d.ts +1 -0
  21. package/esm/components/form/index.js +2 -1
  22. package/esm/components/form/required-fields-indicator/index.d.ts +1 -0
  23. package/esm/components/form/required-fields-indicator/index.js +1 -0
  24. package/esm/components/form/required-fields-indicator/required-fields-indicator.component.d.ts +7 -0
  25. package/esm/components/form/required-fields-indicator/required-fields-indicator.component.js +20 -0
  26. package/esm/components/inline-inputs/inline-inputs.component.d.ts +3 -1
  27. package/esm/components/inline-inputs/inline-inputs.component.js +13 -3
  28. package/esm/components/menu/menu-full-screen/menu-full-screen.component.d.ts +8 -4
  29. package/esm/components/menu/menu-full-screen/menu-full-screen.component.js +70 -43
  30. package/esm/components/menu/menu-full-screen/menu-full-screen.style.d.ts +10 -6
  31. package/esm/components/menu/menu-full-screen/menu-full-screen.style.js +43 -20
  32. package/esm/components/numeral-date/numeral-date.component.d.ts +3 -1
  33. package/esm/components/numeral-date/numeral-date.component.js +4 -3
  34. package/esm/components/radio-button/radio-button-group/radio-button-group.component.d.ts +2 -0
  35. package/esm/components/radio-button/radio-button-group/radio-button-group.component.js +5 -3
  36. package/esm/components/radio-button/radio-button.component.d.ts +1 -2
  37. package/esm/components/radio-button/radio-button.component.js +1 -3
  38. package/esm/components/select/filterable-select/filterable-select.component.d.ts +4 -0
  39. package/esm/components/select/filterable-select/filterable-select.component.js +5 -0
  40. package/esm/components/select/multi-select/multi-select.component.d.ts +2 -0
  41. package/esm/components/select/multi-select/multi-select.component.js +5 -0
  42. package/esm/components/select/select-textbox/select-textbox.component.d.ts +2 -0
  43. package/esm/components/select/select-textbox/select-textbox.component.js +3 -0
  44. package/esm/components/select/simple-select/simple-select.component.d.ts +4 -0
  45. package/esm/components/select/simple-select/simple-select.component.js +6 -0
  46. package/esm/components/switch/switch.component.js +1 -0
  47. package/esm/components/text-editor/text-editor.component.d.ts +3 -1
  48. package/esm/components/text-editor/text-editor.component.js +16 -2
  49. package/esm/components/textarea/textarea.component.d.ts +2 -2
  50. package/esm/components/textarea/textarea.component.js +7 -2
  51. package/esm/components/textbox/textbox.component.d.ts +2 -2
  52. package/esm/components/tile-select/tile-select.style.d.ts +1 -1
  53. package/esm/locales/__internal__/es-es.js +5 -0
  54. package/esm/locales/en-gb.js +5 -0
  55. package/esm/locales/locale.d.ts +5 -0
  56. package/lib/__internal__/checkable-input/checkable-input.component.d.ts +2 -0
  57. package/lib/__internal__/checkable-input/checkable-input.component.js +4 -2
  58. package/lib/__internal__/fieldset/fieldset.style.js +7 -6
  59. package/lib/__internal__/form-field/form-field.component.d.ts +1 -1
  60. package/lib/__internal__/form-field/form-field.component.js +1 -0
  61. package/lib/__internal__/label/label.style.js +6 -5
  62. package/lib/components/checkbox/checkbox-group/checkbox-group.component.d.ts +2 -0
  63. package/lib/components/checkbox/checkbox-group/checkbox-group.component.js +5 -2
  64. package/lib/components/checkbox/checkbox.component.js +3 -0
  65. package/lib/components/date-range/date-range.component.d.ts +5 -1
  66. package/lib/components/date-range/date-range.component.js +5 -1
  67. package/lib/components/decimal/decimal.component.d.ts +0 -2
  68. package/lib/components/decimal/decimal.component.js +1 -2
  69. package/lib/components/fieldset/fieldset.component.d.ts +8 -3
  70. package/lib/components/fieldset/fieldset.component.js +18 -2
  71. package/lib/components/fieldset/fieldset.style.d.ts +4 -0
  72. package/lib/components/fieldset/fieldset.style.js +31 -2
  73. package/lib/components/file-input/file-input.component.d.ts +4 -0
  74. package/lib/components/file-input/file-input.component.js +3 -0
  75. package/lib/components/form/index.d.ts +1 -0
  76. package/lib/components/form/index.js +7 -0
  77. package/lib/components/form/required-fields-indicator/index.d.ts +1 -0
  78. package/lib/components/form/required-fields-indicator/index.js +13 -0
  79. package/lib/components/form/required-fields-indicator/package.json +6 -0
  80. package/lib/components/form/required-fields-indicator/required-fields-indicator.component.d.ts +7 -0
  81. package/lib/components/form/required-fields-indicator/required-fields-indicator.component.js +28 -0
  82. package/lib/components/inline-inputs/inline-inputs.component.d.ts +3 -1
  83. package/lib/components/inline-inputs/inline-inputs.component.js +14 -4
  84. package/lib/components/menu/menu-full-screen/menu-full-screen.component.d.ts +8 -4
  85. package/lib/components/menu/menu-full-screen/menu-full-screen.component.js +68 -41
  86. package/lib/components/menu/menu-full-screen/menu-full-screen.style.d.ts +10 -6
  87. package/lib/components/menu/menu-full-screen/menu-full-screen.style.js +43 -20
  88. package/lib/components/numeral-date/numeral-date.component.d.ts +3 -1
  89. package/lib/components/numeral-date/numeral-date.component.js +4 -3
  90. package/lib/components/radio-button/radio-button-group/radio-button-group.component.d.ts +2 -0
  91. package/lib/components/radio-button/radio-button-group/radio-button-group.component.js +5 -3
  92. package/lib/components/radio-button/radio-button.component.d.ts +1 -2
  93. package/lib/components/radio-button/radio-button.component.js +1 -3
  94. package/lib/components/select/filterable-select/filterable-select.component.d.ts +4 -0
  95. package/lib/components/select/filterable-select/filterable-select.component.js +5 -0
  96. package/lib/components/select/multi-select/multi-select.component.d.ts +2 -0
  97. package/lib/components/select/multi-select/multi-select.component.js +5 -0
  98. package/lib/components/select/select-textbox/select-textbox.component.d.ts +2 -0
  99. package/lib/components/select/select-textbox/select-textbox.component.js +3 -0
  100. package/lib/components/select/simple-select/simple-select.component.d.ts +4 -0
  101. package/lib/components/select/simple-select/simple-select.component.js +6 -0
  102. package/lib/components/switch/switch.component.js +1 -0
  103. package/lib/components/text-editor/text-editor.component.d.ts +3 -1
  104. package/lib/components/text-editor/text-editor.component.js +16 -2
  105. package/lib/components/textarea/textarea.component.d.ts +2 -2
  106. package/lib/components/textarea/textarea.component.js +7 -2
  107. package/lib/components/textbox/textbox.component.d.ts +2 -2
  108. package/lib/components/tile-select/tile-select.style.d.ts +1 -1
  109. package/lib/locales/__internal__/es-es.js +5 -0
  110. package/lib/locales/en-gb.js +5 -0
  111. package/lib/locales/locale.d.ts +5 -0
  112. package/package.json +1 -1
@@ -27,6 +27,8 @@ export interface CommonCheckableInputProps extends ValidationProps, CommonHidden
27
27
  labelWidth?: number;
28
28
  /** Flag to configure component as mandatory */
29
29
  required?: boolean;
30
+ /** Flag to configure component as optional. */
31
+ isOptional?: boolean;
30
32
  /** If true the label switches position with the input */
31
33
  reverse?: boolean;
32
34
  /** Size of the component */
@@ -32,6 +32,7 @@ const CheckableInput = /*#__PURE__*/React.forwardRef(({
32
32
  onChange,
33
33
  onFocus,
34
34
  required,
35
+ isOptional,
35
36
  reverse = false,
36
37
  validationOnLabel,
37
38
  warning,
@@ -53,7 +54,6 @@ const CheckableInput = /*#__PURE__*/React.forwardRef(({
53
54
  label,
54
55
  fieldHelp
55
56
  });
56
- const isRadio = type === "radio";
57
57
  const formFieldProps = {
58
58
  disabled,
59
59
  loading,
@@ -74,7 +74,8 @@ const CheckableInput = /*#__PURE__*/React.forwardRef(({
74
74
  validationIconId: validationId,
75
75
  // We don't want an asterisk on each radio control, only the legend
76
76
  // However, we still want the input element to receive the required prop
77
- isRequired: isRadio ? undefined : required,
77
+ isRequired: required,
78
+ isOptional,
78
79
  useValidationIcon: validationOnLabel
79
80
  };
80
81
  const inputProps = {
@@ -203,6 +204,7 @@ if (process.env.NODE_ENV !== "production") {
203
204
  "inputMode": PropTypes.oneOf(["decimal", "email", "none", "numeric", "search", "tel", "text", "url"]),
204
205
  "inputWidth": PropTypes.number,
205
206
  "is": PropTypes.string,
207
+ "isOptional": PropTypes.bool,
206
208
  "itemID": PropTypes.string,
207
209
  "itemProp": PropTypes.string,
208
210
  "itemRef": PropTypes.string,
@@ -26,11 +26,10 @@ const StyledLegendContent = styled.span`
26
26
  content: "*";
27
27
  line-height: 24px;
28
28
  color: var(--colorsSemanticNegative500);
29
- font-weight: 700;
30
- margin-left: var(--spacing100);
29
+ font-weight: var(--fontWeights700);
30
+ margin-left: var(--spacing050);
31
31
  position: relative;
32
32
  top: 1px;
33
- left: -4px;
34
33
  }
35
34
  `}
36
35
 
@@ -39,8 +38,9 @@ const StyledLegendContent = styled.span`
39
38
  }) => isOptional && css`
40
39
  ::after {
41
40
  content: "(optional)";
42
- font-weight: 350; //TODO: (tokens) use token var(--fontWeights400) - FE-6022
43
- margin-left: 4px;
41
+ color: var(--colorsUtilityYin055);
42
+ font-weight: var(--fontWeights400);
43
+ margin-left: var(--spacing050);
44
44
  }
45
45
  `}
46
46
 
@@ -58,7 +58,8 @@ const StyledLegend = styled.legend`
58
58
  align-items: center;
59
59
  margin-bottom: var(--spacing100);
60
60
  padding: 0;
61
- font-weight: 600;
61
+ font-weight: var(--fontWeights700);
62
+ color: var(--colorsUtilityYin090);
62
63
  ${({
63
64
  inline,
64
65
  width,
@@ -53,7 +53,7 @@ export interface FormFieldProps extends CommonFormFieldProps, TagProps {
53
53
  fieldHelpInline?: boolean;
54
54
  /** Id of the element a label should be bound to */
55
55
  id: string;
56
- /** [Legacy] Flag to configure component as optional in Form */
56
+ /** Flag to configure component as optional in Form */
57
57
  isOptional?: boolean;
58
58
  /** Flag to configure component as mandatory */
59
59
  isRequired?: boolean;
@@ -50,6 +50,7 @@ const FormField = ({
50
50
  return Object.keys(validationProps).find(propName => validationProps[propName]);
51
51
  }, [error, warning, info, disabled]);
52
52
  !(invalidValidationProp === undefined) ? process.env.NODE_ENV !== "production" ? invariant(false, `Prop \`${invalidValidationProp}\` cannot be used in conjunction with \`disabled\`. ` + "Use `readOnly` if you require users to see validations with a non-interactive field") : invariant(false) : void 0;
53
+ !!(isRequired && isOptional) ? process.env.NODE_ENV !== "production" ? invariant(false, "an input cannot be set to both required and optional at the same time") : invariant(false) : void 0;
53
54
  const largeScreen = useIsAboveBreakpoint(adaptiveLabelBreakpoint);
54
55
  let inlineLabel = labelInline;
55
56
  if (adaptiveLabelBreakpoint) {
@@ -2,7 +2,7 @@ import styled, { css } from "styled-components";
2
2
  const StyledLabel = styled.label`
3
3
  color: var(--colorsUtilityYin090);
4
4
  display: block;
5
- font-weight: 600; //TODO: (tokens) use token var(--fontWeights500)
5
+ font-weight: var(--fontWeights700);
6
6
 
7
7
  ${({
8
8
  isRequired
@@ -10,8 +10,8 @@ const StyledLabel = styled.label`
10
10
  ::after {
11
11
  content: "*";
12
12
  color: var(--colorsSemanticNegative500);
13
- font-weight: 700;
14
- margin-left: var(--spacing100);
13
+ font-weight: var(--fontWeights700);
14
+ margin-left: var(--spacing050);
15
15
  }
16
16
  `}
17
17
 
@@ -51,8 +51,9 @@ export const StyledLabelContainer = styled.div`
51
51
  }) => optional && css`
52
52
  ::after {
53
53
  content: "(optional)";
54
- font-weight: 350; //TODO: (tokens) use token var(--fontWeights400)
55
- margin-left: 4px;
54
+ font-weight: var(--fontWeights400);
55
+ margin-left: var(--spacing050);
56
+ color: var(--colorsUtilityYin055);
56
57
  }
57
58
  `}
58
59
  `;
@@ -20,6 +20,8 @@ export interface CheckboxGroupProps extends ValidationProps, MarginProps {
20
20
  labelSpacing?: 1 | 2;
21
21
  /** Flag to configure component as mandatory */
22
22
  required?: boolean;
23
+ /** Flag to configure component as optional. */
24
+ isOptional?: boolean;
23
25
  /** Overrides the default tooltip */
24
26
  tooltipPosition?: "top" | "bottom" | "left" | "right";
25
27
  /** When true, Checkboxes are in line */
@@ -23,6 +23,7 @@ export const CheckboxGroup = props => {
23
23
  warning,
24
24
  info,
25
25
  required,
26
+ isOptional,
26
27
  legendInline,
27
28
  legendWidth,
28
29
  legendAlign,
@@ -40,7 +41,8 @@ export const CheckboxGroup = props => {
40
41
  error: error,
41
42
  warning: warning,
42
43
  info: info,
43
- isRequired: required
44
+ isRequired: required,
45
+ isOptional: isOptional
44
46
  }, tagComponent("checkboxgroup", props), {
45
47
  blockGroupBehaviour: !(error || warning)
46
48
  }, filterStyledSystemMarginProps(props)), legendHelp && /*#__PURE__*/React.createElement(StyledHintText, null, legendHelp), /*#__PURE__*/React.createElement(Box, {
@@ -73,7 +75,8 @@ export const CheckboxGroup = props => {
73
75
  error: error,
74
76
  warning: warning,
75
77
  info: info,
76
- isRequired: required
78
+ isRequired: required,
79
+ isOptional: isOptional
77
80
  }, tagComponent("checkboxgroup", props), {
78
81
  blockGroupBehaviour: !(error || warning || info)
79
82
  }, filterStyledSystemMarginProps(props)), /*#__PURE__*/React.createElement(StyledCheckboxGroup, {
@@ -30,6 +30,7 @@ const Checkbox = /*#__PURE__*/React.forwardRef(({
30
30
  labelWidth,
31
31
  adaptiveSpacingBreakpoint,
32
32
  required,
33
+ isOptional,
33
34
  error,
34
35
  warning,
35
36
  info,
@@ -84,6 +85,7 @@ const Checkbox = /*#__PURE__*/React.forwardRef(({
84
85
  labelHelp,
85
86
  labelSpacing,
86
87
  required,
88
+ isOptional,
87
89
  fieldHelpInline,
88
90
  checked,
89
91
  disabled,
@@ -225,6 +227,7 @@ if (process.env.NODE_ENV !== "production") {
225
227
  })]),
226
228
  "inputWidth": PropTypes.number,
227
229
  "is": PropTypes.string,
230
+ "isOptional": PropTypes.bool,
228
231
  "itemID": PropTypes.string,
229
232
  "itemProp": PropTypes.string,
230
233
  "itemRef": PropTypes.string,
@@ -80,9 +80,13 @@ export interface DateRangeProps extends StyledDateRangeProps, MarginProps, TagPr
80
80
  validationOnLabel?: boolean;
81
81
  /** Overrides the default tooltip position */
82
82
  tooltipPosition?: "top" | "bottom" | "left" | "right";
83
+ /** Flag to configure component as mandatory. */
84
+ required?: boolean;
85
+ /** Flag to configure component as optional. */
86
+ isOptional?: boolean;
83
87
  }
84
88
  export declare const DateRange: {
85
- ({ endDateProps, id, labelsInline, name, onBlur, onChange, startDateProps, tooltipPosition, validationOnLabel, value, startRef, endRef, ...rest }: DateRangeProps): React.JSX.Element;
89
+ ({ endDateProps, id, labelsInline, name, onBlur, onChange, startDateProps, tooltipPosition, validationOnLabel, value, startRef, endRef, required, isOptional, ...rest }: DateRangeProps): React.JSX.Element;
86
90
  displayName: string;
87
91
  };
88
92
  export default DateRange;
@@ -24,6 +24,8 @@ export const DateRange = ({
24
24
  value,
25
25
  startRef,
26
26
  endRef,
27
+ required,
28
+ isOptional,
27
29
  ...rest
28
30
  }) => {
29
31
  const l = useLocale();
@@ -186,7 +188,9 @@ export const DateRange = ({
186
188
  onBlur: handleOnBlur,
187
189
  onChange: onChangeCallback,
188
190
  onKeyDown: ev => handleOnKeyDown(ev, propsKey),
189
- ...props
191
+ ...props,
192
+ required,
193
+ isOptional
190
194
  };
191
195
  };
192
196
  return /*#__PURE__*/React.createElement(StyledDateRange, _extends({}, tagComponent("date-range", rest), {
@@ -33,8 +33,6 @@ export interface DecimalProps extends Omit<CommonTextboxProps, "onChange" | "onB
33
33
  precision?: 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15;
34
34
  /** If true, the component will be read-only */
35
35
  readOnly?: boolean;
36
- /** Flag to configure component as mandatory */
37
- required?: boolean;
38
36
  /** The value of the input if it's used as a controlled component */
39
37
  value?: string;
40
38
  /** The locale string - default en */
@@ -20,7 +20,6 @@ const Decimal = /*#__PURE__*/React.forwardRef(({
20
20
  id,
21
21
  name,
22
22
  allowEmptyValue = false,
23
- required,
24
23
  locale,
25
24
  value,
26
25
  inputRef,
@@ -177,7 +176,6 @@ const Decimal = /*#__PURE__*/React.forwardRef(({
177
176
  onKeyPress: onKeyPress,
178
177
  align: align,
179
178
  readOnly: readOnly,
180
- required: required,
181
179
  inputWidth: inputWidth,
182
180
  onChange: handleOnChange,
183
181
  onBlur: handleOnBlur,
@@ -304,6 +302,7 @@ if (process.env.NODE_ENV !== "production") {
304
302
  "inputRef": PropTypes.func,
305
303
  "inputWidth": PropTypes.number,
306
304
  "is": PropTypes.string,
305
+ "isOptional": PropTypes.bool,
307
306
  "itemID": PropTypes.string,
308
307
  "itemProp": PropTypes.string,
309
308
  "itemRef": PropTypes.string,
@@ -1,14 +1,19 @@
1
1
  import React from "react";
2
2
  import { MarginProps } from "styled-system";
3
- import { StyledFieldsetProps } from "./fieldset.style";
4
- export interface FieldsetProps extends StyledFieldsetProps, MarginProps {
3
+ export interface FieldsetProps extends MarginProps {
4
+ /** When true, legend is placed in line with the children */
5
+ inline?: boolean;
5
6
  /** Child elements */
6
7
  children?: React.ReactNode;
7
8
  /** The text for the fieldsets legend element. */
8
9
  legend?: string;
10
+ /** Flag to configure fields as mandatory. */
11
+ required?: boolean;
12
+ /** Flag to configure fields as optional. */
13
+ isOptional?: boolean;
9
14
  }
10
15
  export declare const Fieldset: {
11
- ({ children, inline, legend, ...rest }: FieldsetProps): React.JSX.Element;
16
+ ({ children, inline, legend, required, isOptional, ...rest }: FieldsetProps): React.JSX.Element;
12
17
  displayName: string;
13
18
  };
14
19
  export default Fieldset;
@@ -1,5 +1,5 @@
1
1
  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); }
2
- import React from "react";
2
+ import React, { useState, useEffect } from "react";
3
3
  import PropTypes from "prop-types";
4
4
  import tagComponent from "../../__internal__/utils/helpers/tags/tags";
5
5
  import { FieldsetStyle, LegendContainerStyle, FieldsetContentStyle } from "./fieldset.style";
@@ -10,11 +10,16 @@ export const Fieldset = ({
10
10
  children,
11
11
  inline = false,
12
12
  legend,
13
+ required,
14
+ isOptional,
13
15
  ...rest
14
16
  }) => {
17
+ const [ref, setRef] = useState(null);
15
18
  const getLegend = () => {
16
19
  if (!legend) return null;
17
20
  return /*#__PURE__*/React.createElement(LegendContainerStyle, {
21
+ isRequired: required,
22
+ isOptional: isOptional,
18
23
  inline: inline,
19
24
  "data-component": "legend-style"
20
25
  }, /*#__PURE__*/React.createElement("legend", {
@@ -22,11 +27,20 @@ export const Fieldset = ({
22
27
  }, legend));
23
28
  };
24
29
  const marginProps = useFormSpacing(rest);
30
+ useEffect(() => {
31
+ if (ref && required) {
32
+ Array.from(ref.querySelectorAll("input") || /* istanbul ignore next */[]).forEach(el => {
33
+ el.setAttribute("required", "");
34
+ });
35
+ }
36
+ }, [ref, required]);
25
37
  return /*#__PURE__*/React.createElement(NewValidationContext.Provider, {
26
38
  value: {
27
39
  validationRedesignOptIn: false
28
40
  }
29
- }, /*#__PURE__*/React.createElement(FieldsetStyle, _extends({}, tagComponent("fieldset", rest), rest, marginProps), /*#__PURE__*/React.createElement(FieldsetContentStyle, {
41
+ }, /*#__PURE__*/React.createElement(FieldsetStyle, _extends({
42
+ ref: setRef
43
+ }, tagComponent("fieldset", rest), rest, marginProps), /*#__PURE__*/React.createElement(FieldsetContentStyle, {
30
44
  "data-component": "fieldset-style",
31
45
  inline: inline
32
46
  }, getLegend(), /*#__PURE__*/React.createElement(FormSpacingProvider, {
@@ -1,6 +1,10 @@
1
1
  export interface StyledFieldsetProps {
2
2
  /** When true, legend is placed in line with the children */
3
3
  inline?: boolean;
4
+ /** Flag to configure fields as mandatory. */
5
+ isRequired?: boolean;
6
+ /** Flag to configure fields as optional. */
7
+ isOptional?: boolean;
4
8
  }
5
9
  declare const FieldsetStyle: import("styled-components").StyledComponent<"fieldset", any, {}, never>;
6
10
  declare const LegendContainerStyle: import("styled-components").StyledComponent<"div", any, StyledFieldsetProps, never>;
@@ -1,4 +1,4 @@
1
- import styled from "styled-components";
1
+ import styled, { css } from "styled-components";
2
2
  import { margin } from "styled-system";
3
3
  import FormFieldStyle from "../../__internal__/form-field/form-field.style";
4
4
  import ValidationIconStyle from "../../__internal__/validations/validation-icon.style";
@@ -37,9 +37,36 @@ const LegendContainerStyle = styled.div`
37
37
 
38
38
  legend {
39
39
  font-size: 20px;
40
- font-weight: 600;
40
+ font-weight: var(--fontWeights700);
41
+ color: var(--colorsUtilityYin090);
41
42
  line-height: 24px;
42
43
  margin-right: 4px;
44
+
45
+ ${({
46
+ isRequired
47
+ }) => isRequired && css`
48
+ ::after {
49
+ content: "*";
50
+ line-height: 24px;
51
+ color: var(--colorsSemanticNegative500);
52
+ font-weight: var(--fontWeights700);
53
+ margin-left: var(--spacing100);
54
+ position: relative;
55
+ top: 1px;
56
+ left: -4px;
57
+ }
58
+ `}
59
+
60
+ ${({
61
+ isOptional
62
+ }) => isOptional && css`
63
+ ::after {
64
+ content: "(optional)";
65
+ color: var(--colorsUtilityYin055);
66
+ font-weight: var(--fontWeights400);
67
+ margin-left: var(--spacing050);
68
+ }
69
+ `}
43
70
  }
44
71
 
45
72
  ${ValidationIconStyle} ${StyledIcon}:focus {
@@ -31,6 +31,10 @@ export interface FileInputProps extends Pick<ValidationProps, "error">, Pick<Inp
31
31
  onChange: (files: FileList) => void;
32
32
  /** used to control how to display the progress of uploaded file(s) within the component */
33
33
  uploadStatus?: FileUploadStatusProps | FileUploadStatusProps[];
34
+ /** Flag to configure component as mandatory. */
35
+ required?: boolean;
36
+ /** Flag to configure component as optional. */
37
+ isOptional?: boolean;
34
38
  }
35
39
  export declare const FileInput: React.ForwardRefExoticComponent<FileInputProps & React.RefAttributes<HTMLInputElement>>;
36
40
  export default FileInput;
@@ -32,6 +32,7 @@ const FileInput = /*#__PURE__*/React.forwardRef(({
32
32
  name,
33
33
  onChange,
34
34
  required,
35
+ isOptional,
35
36
  uploadStatus = [],
36
37
  ...rest
37
38
  }, ref) => {
@@ -149,6 +150,7 @@ const FileInput = /*#__PURE__*/React.forwardRef(({
149
150
  labelId: labelId,
150
151
  id: uniqueId,
151
152
  isRequired: required,
153
+ isOptional: isOptional,
152
154
  "data-component": "file-input",
153
155
  "data-role": dataRole,
154
156
  "data-element": dataElement,
@@ -170,6 +172,7 @@ if (process.env.NODE_ENV !== "production") {
170
172
  "error": PropTypes.oneOfType([PropTypes.string, PropTypes.bool]),
171
173
  "id": PropTypes.string,
172
174
  "inputHint": PropTypes.node,
175
+ "isOptional": PropTypes.bool,
173
176
  "isVertical": PropTypes.bool,
174
177
  "label": PropTypes.string,
175
178
  "m": PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.oneOf([null]), PropTypes.number, PropTypes.shape({
@@ -1,2 +1,3 @@
1
1
  export { default } from "./form.component";
2
2
  export type { FormProps } from "./form.component";
3
+ export { default as RequiredFieldsIndicator } from "./required-fields-indicator";
@@ -1 +1,2 @@
1
- export { default } from "./form.component";
1
+ export { default } from "./form.component";
2
+ export { default as RequiredFieldsIndicator } from "./required-fields-indicator";
@@ -0,0 +1 @@
1
+ export { default } from "./required-fields-indicator.component";
@@ -0,0 +1 @@
1
+ export { default } from "./required-fields-indicator.component";
@@ -0,0 +1,7 @@
1
+ import React from "react";
2
+ import { MarginProps } from "styled-system";
3
+ export interface RequiredIndicatorProps extends MarginProps {
4
+ children: React.ReactNode;
5
+ }
6
+ declare const _default: ({ children, ...rest }: RequiredIndicatorProps) => React.JSX.Element;
7
+ export default _default;
@@ -0,0 +1,20 @@
1
+ import React from "react";
2
+ import PropTypes from "prop-types";
3
+ import styled from "styled-components";
4
+ import Box from "../../box";
5
+ import StyledTypography from "../../typography/typography.style";
6
+ const StyledIndicatorContainer = styled(Box)`
7
+ ${StyledTypography} {
8
+ color: var(--colorsUtilityYin090);
9
+ }
10
+ ::after {
11
+ content: "*";
12
+ color: var(--colorsSemanticNegative500);
13
+ font-weight: 700;
14
+ margin-left: var(--spacing050);
15
+ }
16
+ `;
17
+ export default (({
18
+ children,
19
+ ...rest
20
+ }) => /*#__PURE__*/React.createElement(StyledIndicatorContainer, rest, children));
@@ -21,9 +21,11 @@ export interface InlineInputsProps extends MarginProps, StyledContentContainerPr
21
21
  labelId?: string;
22
22
  /** Flag to configure component as mandatory. */
23
23
  required?: boolean;
24
+ /** Flag to configure component as optional. */
25
+ isOptional?: boolean;
24
26
  }
25
27
  declare const InlineInputs: {
26
- ({ adaptiveLabelBreakpoint, label, labelAlign, labelId, htmlFor, children, className, gutter, inputWidth, labelInline, labelWidth, required, ...rest }: InlineInputsProps): React.JSX.Element;
28
+ ({ adaptiveLabelBreakpoint, label, labelAlign, labelId, htmlFor, children, className, gutter, inputWidth, labelInline, labelWidth, required, isOptional, ...rest }: InlineInputsProps): React.JSX.Element;
27
29
  displayName: string;
28
30
  };
29
31
  export default InlineInputs;
@@ -1,5 +1,5 @@
1
1
  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); }
2
- import React from "react";
2
+ import React, { useRef, useEffect } from "react";
3
3
  import PropTypes from "prop-types";
4
4
  import Label from "../../__internal__/label";
5
5
  import StyledInlineInputs, { StyledContentContainer, StyledInlineInput } from "./inline-inputs.style";
@@ -27,9 +27,11 @@ const InlineInputs = ({
27
27
  labelInline = true,
28
28
  labelWidth,
29
29
  required,
30
+ isOptional,
30
31
  ...rest
31
32
  }) => {
32
33
  const largeScreen = useIsAboveBreakpoint(adaptiveLabelBreakpoint);
34
+ const ref = useRef(null);
33
35
  let inlineLabel = labelInline;
34
36
  if (adaptiveLabelBreakpoint) {
35
37
  inlineLabel = largeScreen;
@@ -41,16 +43,24 @@ const InlineInputs = ({
41
43
  labelId: labelId,
42
44
  inline: inlineLabel,
43
45
  htmlFor: htmlFor,
44
- isRequired: required
46
+ isRequired: required,
47
+ optional: isOptional
45
48
  }, label);
46
49
  }
47
50
  const marginProps = useFormSpacing(rest);
51
+ useEffect(() => {
52
+ if (required) {
53
+ const elements = Array.from(ref.current?.querySelectorAll("input") || /* istanbul ignore next */[]);
54
+ elements.forEach(el => el.setAttribute("required", ""));
55
+ }
56
+ }, [required]);
48
57
  return /*#__PURE__*/React.createElement(StyledInlineInputs, _extends({
49
58
  gutter: gutter,
50
59
  "data-component": "inline-inputs",
51
60
  className: className,
52
61
  labelWidth: labelWidth,
53
- labelInline: inlineLabel
62
+ labelInline: inlineLabel,
63
+ ref: ref
54
64
  }, marginProps), renderLabel(), /*#__PURE__*/React.createElement(StyledContentContainer, {
55
65
  gutter: gutter,
56
66
  "data-element": "inline-inputs-container",
@@ -1,6 +1,8 @@
1
1
  import React from "react";
2
- import { TagProps } from "../../../__internal__/utils/helpers/tags";
3
- export interface MenuFullscreenProps extends TagProps {
2
+ import type { TagProps } from "../../../__internal__/utils/helpers/tags";
3
+ export interface MenuFullscreenProps extends Omit<TagProps, "data-component"> {
4
+ /** Accessible name that conveys the purpose of the menu */
5
+ "aria-label"?: string;
4
6
  /** The child elements to render */
5
7
  children?: React.ReactNode;
6
8
  /** Sets whether the component is open or closed */
@@ -8,7 +10,9 @@ export interface MenuFullscreenProps extends TagProps {
8
10
  /** The start position for the component to open from */
9
11
  startPosition?: "left" | "right";
10
12
  /** A callback to be called when the close icon is clicked or enter is pressed when focused */
11
- onClose: (ev: React.KeyboardEvent<HTMLElement> | React.MouseEvent<HTMLButtonElement>) => void;
13
+ onClose: (ev: React.KeyboardEvent<HTMLButtonElement> | React.MouseEvent<HTMLButtonElement> | KeyboardEvent) => void;
14
+ /** Manually override the internal modal stacking order to set this as top */
15
+ topModalOverride?: boolean;
12
16
  }
13
- export declare const MenuFullscreen: ({ children, isOpen, startPosition, onClose, ...rest }: MenuFullscreenProps) => React.JSX.Element;
17
+ export declare const MenuFullscreen: ({ "aria-label": ariaLabel, "data-element": dataElement, "data-role": dataRole, children, isOpen, onClose, startPosition, topModalOverride, }: MenuFullscreenProps) => React.JSX.Element;
14
18
  export default MenuFullscreen;