carbon-react 128.1.2 → 128.2.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 (98) 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/numeral-date/numeral-date.component.d.ts +3 -1
  29. package/esm/components/numeral-date/numeral-date.component.js +4 -3
  30. package/esm/components/radio-button/radio-button-group/radio-button-group.component.d.ts +2 -0
  31. package/esm/components/radio-button/radio-button-group/radio-button-group.component.js +5 -3
  32. package/esm/components/radio-button/radio-button.component.d.ts +1 -2
  33. package/esm/components/radio-button/radio-button.component.js +1 -3
  34. package/esm/components/select/filterable-select/filterable-select.component.d.ts +4 -0
  35. package/esm/components/select/filterable-select/filterable-select.component.js +5 -0
  36. package/esm/components/select/multi-select/multi-select.component.d.ts +2 -0
  37. package/esm/components/select/multi-select/multi-select.component.js +5 -0
  38. package/esm/components/select/select-textbox/select-textbox.component.d.ts +2 -0
  39. package/esm/components/select/select-textbox/select-textbox.component.js +3 -0
  40. package/esm/components/select/simple-select/simple-select.component.d.ts +4 -0
  41. package/esm/components/select/simple-select/simple-select.component.js +6 -0
  42. package/esm/components/switch/switch.component.js +1 -0
  43. package/esm/components/text-editor/text-editor.component.d.ts +3 -1
  44. package/esm/components/text-editor/text-editor.component.js +16 -2
  45. package/esm/components/textarea/textarea.component.d.ts +2 -2
  46. package/esm/components/textarea/textarea.component.js +7 -2
  47. package/esm/components/textbox/textbox.component.d.ts +2 -2
  48. package/esm/components/tile-select/tile-select.style.d.ts +1 -1
  49. package/lib/__internal__/checkable-input/checkable-input.component.d.ts +2 -0
  50. package/lib/__internal__/checkable-input/checkable-input.component.js +4 -2
  51. package/lib/__internal__/fieldset/fieldset.style.js +7 -6
  52. package/lib/__internal__/form-field/form-field.component.d.ts +1 -1
  53. package/lib/__internal__/form-field/form-field.component.js +1 -0
  54. package/lib/__internal__/label/label.style.js +6 -5
  55. package/lib/components/checkbox/checkbox-group/checkbox-group.component.d.ts +2 -0
  56. package/lib/components/checkbox/checkbox-group/checkbox-group.component.js +5 -2
  57. package/lib/components/checkbox/checkbox.component.js +3 -0
  58. package/lib/components/date-range/date-range.component.d.ts +5 -1
  59. package/lib/components/date-range/date-range.component.js +5 -1
  60. package/lib/components/decimal/decimal.component.d.ts +0 -2
  61. package/lib/components/decimal/decimal.component.js +1 -2
  62. package/lib/components/fieldset/fieldset.component.d.ts +8 -3
  63. package/lib/components/fieldset/fieldset.component.js +18 -2
  64. package/lib/components/fieldset/fieldset.style.d.ts +4 -0
  65. package/lib/components/fieldset/fieldset.style.js +31 -2
  66. package/lib/components/file-input/file-input.component.d.ts +4 -0
  67. package/lib/components/file-input/file-input.component.js +3 -0
  68. package/lib/components/form/index.d.ts +1 -0
  69. package/lib/components/form/index.js +7 -0
  70. package/lib/components/form/required-fields-indicator/index.d.ts +1 -0
  71. package/lib/components/form/required-fields-indicator/index.js +13 -0
  72. package/lib/components/form/required-fields-indicator/package.json +6 -0
  73. package/lib/components/form/required-fields-indicator/required-fields-indicator.component.d.ts +7 -0
  74. package/lib/components/form/required-fields-indicator/required-fields-indicator.component.js +28 -0
  75. package/lib/components/inline-inputs/inline-inputs.component.d.ts +3 -1
  76. package/lib/components/inline-inputs/inline-inputs.component.js +14 -4
  77. package/lib/components/numeral-date/numeral-date.component.d.ts +3 -1
  78. package/lib/components/numeral-date/numeral-date.component.js +4 -3
  79. package/lib/components/radio-button/radio-button-group/radio-button-group.component.d.ts +2 -0
  80. package/lib/components/radio-button/radio-button-group/radio-button-group.component.js +5 -3
  81. package/lib/components/radio-button/radio-button.component.d.ts +1 -2
  82. package/lib/components/radio-button/radio-button.component.js +1 -3
  83. package/lib/components/select/filterable-select/filterable-select.component.d.ts +4 -0
  84. package/lib/components/select/filterable-select/filterable-select.component.js +5 -0
  85. package/lib/components/select/multi-select/multi-select.component.d.ts +2 -0
  86. package/lib/components/select/multi-select/multi-select.component.js +5 -0
  87. package/lib/components/select/select-textbox/select-textbox.component.d.ts +2 -0
  88. package/lib/components/select/select-textbox/select-textbox.component.js +3 -0
  89. package/lib/components/select/simple-select/simple-select.component.d.ts +4 -0
  90. package/lib/components/select/simple-select/simple-select.component.js +6 -0
  91. package/lib/components/switch/switch.component.js +1 -0
  92. package/lib/components/text-editor/text-editor.component.d.ts +3 -1
  93. package/lib/components/text-editor/text-editor.component.js +16 -2
  94. package/lib/components/textarea/textarea.component.d.ts +2 -2
  95. package/lib/components/textarea/textarea.component.js +7 -2
  96. package/lib/components/textbox/textbox.component.d.ts +2 -2
  97. package/lib/components/tile-select/tile-select.style.d.ts +1 -1
  98. package/package.json +1 -1
@@ -4,7 +4,7 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.default = exports.Fieldset = void 0;
7
- var _react = _interopRequireDefault(require("react"));
7
+ var _react = _interopRequireWildcard(require("react"));
8
8
  var _propTypes = _interopRequireDefault(require("prop-types"));
9
9
  var _tags = _interopRequireDefault(require("../../__internal__/utils/helpers/tags/tags"));
10
10
  var _fieldset = require("./fieldset.style");
@@ -12,16 +12,23 @@ var _carbonProvider = require("../carbon-provider/carbon-provider.component");
12
12
  var _formSpacingProvider = _interopRequireDefault(require("../../__internal__/form-spacing-provider"));
13
13
  var _useFormSpacing = _interopRequireDefault(require("../../hooks/__internal__/useFormSpacing"));
14
14
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
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
+ function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && Object.prototype.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
15
17
  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); }
16
18
  const Fieldset = ({
17
19
  children,
18
20
  inline = false,
19
21
  legend,
22
+ required,
23
+ isOptional,
20
24
  ...rest
21
25
  }) => {
26
+ const [ref, setRef] = (0, _react.useState)(null);
22
27
  const getLegend = () => {
23
28
  if (!legend) return null;
24
29
  return /*#__PURE__*/_react.default.createElement(_fieldset.LegendContainerStyle, {
30
+ isRequired: required,
31
+ isOptional: isOptional,
25
32
  inline: inline,
26
33
  "data-component": "legend-style"
27
34
  }, /*#__PURE__*/_react.default.createElement("legend", {
@@ -29,11 +36,20 @@ const Fieldset = ({
29
36
  }, legend));
30
37
  };
31
38
  const marginProps = (0, _useFormSpacing.default)(rest);
39
+ (0, _react.useEffect)(() => {
40
+ if (ref && required) {
41
+ Array.from(ref.querySelectorAll("input") || /* istanbul ignore next */[]).forEach(el => {
42
+ el.setAttribute("required", "");
43
+ });
44
+ }
45
+ }, [ref, required]);
32
46
  return /*#__PURE__*/_react.default.createElement(_carbonProvider.NewValidationContext.Provider, {
33
47
  value: {
34
48
  validationRedesignOptIn: false
35
49
  }
36
- }, /*#__PURE__*/_react.default.createElement(_fieldset.FieldsetStyle, _extends({}, (0, _tags.default)("fieldset", rest), rest, marginProps), /*#__PURE__*/_react.default.createElement(_fieldset.FieldsetContentStyle, {
50
+ }, /*#__PURE__*/_react.default.createElement(_fieldset.FieldsetStyle, _extends({
51
+ ref: setRef
52
+ }, (0, _tags.default)("fieldset", rest), rest, marginProps), /*#__PURE__*/_react.default.createElement(_fieldset.FieldsetContentStyle, {
37
53
  "data-component": "fieldset-style",
38
54
  inline: inline
39
55
  }, getLegend(), /*#__PURE__*/_react.default.createElement(_formSpacingProvider.default, {
@@ -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>;
@@ -4,7 +4,7 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.LegendContainerStyle = exports.FieldsetStyle = exports.FieldsetContentStyle = void 0;
7
- var _styledComponents = _interopRequireDefault(require("styled-components"));
7
+ var _styledComponents = _interopRequireWildcard(require("styled-components"));
8
8
  var _styledSystem = require("styled-system");
9
9
  var _formField = _interopRequireDefault(require("../../__internal__/form-field/form-field.style"));
10
10
  var _validationIcon = _interopRequireDefault(require("../../__internal__/validations/validation-icon.style"));
@@ -12,6 +12,8 @@ var _icon = _interopRequireDefault(require("../icon/icon.style"));
12
12
  var _base = _interopRequireDefault(require("../../style/themes/base"));
13
13
  var _checkbox = _interopRequireDefault(require("../checkbox/checkbox.style"));
14
14
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
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
+ function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && Object.prototype.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
15
17
  const FieldsetStyle = exports.FieldsetStyle = _styledComponents.default.fieldset`
16
18
  margin: 0;
17
19
  ${_styledSystem.margin}
@@ -44,9 +46,36 @@ const LegendContainerStyle = exports.LegendContainerStyle = _styledComponents.de
44
46
 
45
47
  legend {
46
48
  font-size: 20px;
47
- font-weight: 600;
49
+ font-weight: var(--fontWeights700);
50
+ color: var(--colorsUtilityYin090);
48
51
  line-height: 24px;
49
52
  margin-right: 4px;
53
+
54
+ ${({
55
+ isRequired
56
+ }) => isRequired && (0, _styledComponents.css)`
57
+ ::after {
58
+ content: "*";
59
+ line-height: 24px;
60
+ color: var(--colorsSemanticNegative500);
61
+ font-weight: var(--fontWeights700);
62
+ margin-left: var(--spacing100);
63
+ position: relative;
64
+ top: 1px;
65
+ left: -4px;
66
+ }
67
+ `}
68
+
69
+ ${({
70
+ isOptional
71
+ }) => isOptional && (0, _styledComponents.css)`
72
+ ::after {
73
+ content: "(optional)";
74
+ color: var(--colorsUtilityYin055);
75
+ font-weight: var(--fontWeights400);
76
+ margin-left: var(--spacing050);
77
+ }
78
+ `}
50
79
  }
51
80
 
52
81
  ${_validationIcon.default} ${_icon.default}: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;
@@ -41,6 +41,7 @@ const FileInput = exports.FileInput = /*#__PURE__*/_react.default.forwardRef(({
41
41
  name,
42
42
  onChange,
43
43
  required,
44
+ isOptional,
44
45
  uploadStatus = [],
45
46
  ...rest
46
47
  }, ref) => {
@@ -158,6 +159,7 @@ const FileInput = exports.FileInput = /*#__PURE__*/_react.default.forwardRef(({
158
159
  labelId: labelId,
159
160
  id: uniqueId,
160
161
  isRequired: required,
162
+ isOptional: isOptional,
161
163
  "data-component": "file-input",
162
164
  "data-role": dataRole,
163
165
  "data-element": dataElement,
@@ -179,6 +181,7 @@ if (process.env.NODE_ENV !== "production") {
179
181
  "error": _propTypes.default.oneOfType([_propTypes.default.string, _propTypes.default.bool]),
180
182
  "id": _propTypes.default.string,
181
183
  "inputHint": _propTypes.default.node,
184
+ "isOptional": _propTypes.default.bool,
182
185
  "isVertical": _propTypes.default.bool,
183
186
  "label": _propTypes.default.string,
184
187
  "m": _propTypes.default.oneOfType([_propTypes.default.arrayOf(_propTypes.default.oneOfType([_propTypes.default.oneOf([null]), _propTypes.default.number, _propTypes.default.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";
@@ -3,6 +3,12 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
+ Object.defineProperty(exports, "RequiredFieldsIndicator", {
7
+ enumerable: true,
8
+ get: function () {
9
+ return _requiredFieldsIndicator.default;
10
+ }
11
+ });
6
12
  Object.defineProperty(exports, "default", {
7
13
  enumerable: true,
8
14
  get: function () {
@@ -10,4 +16,5 @@ Object.defineProperty(exports, "default", {
10
16
  }
11
17
  });
12
18
  var _form = _interopRequireDefault(require("./form.component"));
19
+ var _requiredFieldsIndicator = _interopRequireDefault(require("./required-fields-indicator"));
13
20
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
@@ -0,0 +1 @@
1
+ export { default } from "./required-fields-indicator.component";
@@ -0,0 +1,13 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ Object.defineProperty(exports, "default", {
7
+ enumerable: true,
8
+ get: function () {
9
+ return _requiredFieldsIndicator.default;
10
+ }
11
+ });
12
+ var _requiredFieldsIndicator = _interopRequireDefault(require("./required-fields-indicator.component"));
13
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
@@ -0,0 +1,6 @@
1
+ {
2
+ "sideEffects": false,
3
+ "module": "../../../../esm/components/form/required-fields-indicator/index.js",
4
+ "main": "./index.js",
5
+ "types": "./index.d.ts"
6
+ }
@@ -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,28 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = void 0;
7
+ var _react = _interopRequireDefault(require("react"));
8
+ var _propTypes = _interopRequireDefault(require("prop-types"));
9
+ var _styledComponents = _interopRequireDefault(require("styled-components"));
10
+ var _box = _interopRequireDefault(require("../../box"));
11
+ var _typography = _interopRequireDefault(require("../../typography/typography.style"));
12
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
13
+ const StyledIndicatorContainer = (0, _styledComponents.default)(_box.default)`
14
+ ${_typography.default} {
15
+ color: var(--colorsUtilityYin090);
16
+ }
17
+ ::after {
18
+ content: "*";
19
+ color: var(--colorsSemanticNegative500);
20
+ font-weight: 700;
21
+ margin-left: var(--spacing050);
22
+ }
23
+ `;
24
+ var _default = ({
25
+ children,
26
+ ...rest
27
+ }) => /*#__PURE__*/_react.default.createElement(StyledIndicatorContainer, rest, children);
28
+ exports.default = _default;
@@ -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;
@@ -4,16 +4,16 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.default = void 0;
7
- var _react = _interopRequireDefault(require("react"));
7
+ var _react = _interopRequireWildcard(require("react"));
8
8
  var _propTypes = _interopRequireDefault(require("prop-types"));
9
9
  var _label = _interopRequireDefault(require("../../__internal__/label"));
10
10
  var _inlineInputs = _interopRequireWildcard(require("./inline-inputs.style"));
11
11
  var _formSpacingProvider = _interopRequireDefault(require("../../__internal__/form-spacing-provider"));
12
12
  var _useIsAboveBreakpoint = _interopRequireDefault(require("../../hooks/__internal__/useIsAboveBreakpoint"));
13
13
  var _useFormSpacing = _interopRequireDefault(require("../../hooks/__internal__/useFormSpacing"));
14
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
14
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); }
15
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 && Object.prototype.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
16
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
17
17
  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); }
18
18
  const columnWrapper = (children, gutter) => {
19
19
  return _react.default.Children.map(children, input => {
@@ -36,9 +36,11 @@ const InlineInputs = ({
36
36
  labelInline = true,
37
37
  labelWidth,
38
38
  required,
39
+ isOptional,
39
40
  ...rest
40
41
  }) => {
41
42
  const largeScreen = (0, _useIsAboveBreakpoint.default)(adaptiveLabelBreakpoint);
43
+ const ref = (0, _react.useRef)(null);
42
44
  let inlineLabel = labelInline;
43
45
  if (adaptiveLabelBreakpoint) {
44
46
  inlineLabel = largeScreen;
@@ -50,16 +52,24 @@ const InlineInputs = ({
50
52
  labelId: labelId,
51
53
  inline: inlineLabel,
52
54
  htmlFor: htmlFor,
53
- isRequired: required
55
+ isRequired: required,
56
+ optional: isOptional
54
57
  }, label);
55
58
  }
56
59
  const marginProps = (0, _useFormSpacing.default)(rest);
60
+ (0, _react.useEffect)(() => {
61
+ if (required) {
62
+ const elements = Array.from(ref.current?.querySelectorAll("input") || /* istanbul ignore next */[]);
63
+ elements.forEach(el => el.setAttribute("required", ""));
64
+ }
65
+ }, [required]);
57
66
  return /*#__PURE__*/_react.default.createElement(_inlineInputs.default, _extends({
58
67
  gutter: gutter,
59
68
  "data-component": "inline-inputs",
60
69
  className: className,
61
70
  labelWidth: labelWidth,
62
- labelInline: inlineLabel
71
+ labelInline: inlineLabel,
72
+ ref: ref
63
73
  }, marginProps), renderLabel(), /*#__PURE__*/_react.default.createElement(_inlineInputs.StyledContentContainer, {
64
74
  gutter: gutter,
65
75
  "data-element": "inline-inputs-container",
@@ -87,7 +87,9 @@ export interface NumeralDateProps<DateType extends NumeralDateObject = FullDate>
87
87
  * A React ref to pass to the input corresponding to the year
88
88
  */
89
89
  yearRef?: React.ForwardedRef<HTMLInputElement>;
90
+ /** Flag to configure component as optional. */
91
+ isOptional?: boolean;
90
92
  }
91
93
  export declare type ValidDateFormat = typeof ALLOWED_DATE_FORMATS[number];
92
- export declare const NumeralDate: <DateType extends NumeralDateObject = FullDate>({ dateFormat, defaultValue, disabled, error, warning, "data-component": dataComponent, "data-element": dataElement, "data-role": dataRole, info, id, name, onBlur, onChange, value, validationOnLabel, label, labelInline, labelWidth, labelAlign, labelHelp, labelSpacing, fieldHelp, adaptiveLabelBreakpoint, required, readOnly, size, enableInternalError, enableInternalWarning, tooltipPosition, helpAriaLabel, dayRef, monthRef, yearRef, ...rest }: NumeralDateProps<DateType>) => React.JSX.Element;
94
+ export declare const NumeralDate: <DateType extends NumeralDateObject = FullDate>({ dateFormat, defaultValue, disabled, error, warning, "data-component": dataComponent, "data-element": dataElement, "data-role": dataRole, info, id, name, onBlur, onChange, value, validationOnLabel, label, labelInline, labelWidth, labelAlign, labelHelp, labelSpacing, fieldHelp, adaptiveLabelBreakpoint, required, isOptional, readOnly, size, enableInternalError, enableInternalWarning, tooltipPosition, helpAriaLabel, dayRef, monthRef, yearRef, ...rest }: NumeralDateProps<DateType>) => React.JSX.Element;
93
95
  export default NumeralDate;
@@ -112,6 +112,7 @@ const NumeralDate = ({
112
112
  fieldHelp,
113
113
  adaptiveLabelBreakpoint,
114
114
  required,
115
+ isOptional,
115
116
  readOnly,
116
117
  size,
117
118
  enableInternalError,
@@ -224,6 +225,7 @@ const NumeralDate = ({
224
225
  fieldHelp: fieldHelp,
225
226
  adaptiveLabelBreakpoint: adaptiveLabelBreakpoint,
226
227
  isRequired: required,
228
+ isOptional: isOptional,
227
229
  validationRedesignOptIn: validationRedesignOptIn
228
230
  }, (0, _utils.filterStyledSystemMarginProps)(rest)), validationRedesignOptIn && labelHelp && /*#__PURE__*/_react.default.createElement(_textbox2.StyledHintText, null, labelHelp), /*#__PURE__*/_react.default.createElement(_box.default, {
229
231
  position: "relative"
@@ -294,8 +296,6 @@ const NumeralDate = ({
294
296
  error: !!internalError,
295
297
  warning: !!internalWarning,
296
298
  info: !!info
297
- }, required && {
298
- required
299
299
  }, isEnd && !validationRedesignOptIn && !validationOnLabel && {
300
300
  error: internalError,
301
301
  warning: internalWarning,
@@ -303,7 +303,8 @@ const NumeralDate = ({
303
303
  }, {
304
304
  size: size,
305
305
  tooltipPosition: tooltipPosition,
306
- "aria-labelledby": labelId
306
+ "aria-labelledby": labelId,
307
+ required: required
307
308
  })))));
308
309
  }))))));
309
310
  };
@@ -32,6 +32,8 @@ export interface RadioButtonGroupProps extends ValidationProps, MarginProps {
32
32
  onChange?: (ev: React.ChangeEvent<HTMLInputElement>) => void;
33
33
  /** Flag to configure component as mandatory */
34
34
  required?: boolean;
35
+ /** Flag to configure component as optional. */
36
+ isOptional?: boolean;
35
37
  /** value of the selected RadioButton */
36
38
  value?: string;
37
39
  /** Overrides the default tooltip position */
@@ -44,6 +44,7 @@ const RadioButtonGroup = props => {
44
44
  adaptiveLegendBreakpoint,
45
45
  adaptiveSpacingBreakpoint,
46
46
  required,
47
+ isOptional,
47
48
  tooltipPosition
48
49
  } = props;
49
50
  const {
@@ -73,7 +74,8 @@ const RadioButtonGroup = props => {
73
74
  legendWidth: legendWidth,
74
75
  legendAlign: legendAlign,
75
76
  legendSpacing: legendSpacing,
76
- isRequired: required
77
+ isRequired: required,
78
+ isOptional: isOptional
77
79
  }, (0, _tags.default)("radiogroup", props), marginProps, {
78
80
  ml: marginLeft,
79
81
  blockGroupBehaviour: !(error || warning)
@@ -119,7 +121,8 @@ const RadioButtonGroup = props => {
119
121
  legendWidth: legendWidth,
120
122
  legendAlign: legendAlign,
121
123
  legendSpacing: legendSpacing,
122
- isRequired: required
124
+ isRequired: required,
125
+ isOptional: isOptional
123
126
  }, (0, _tags.default)("radiogroup", props), marginProps, {
124
127
  ml: marginLeft,
125
128
  blockGroupBehaviour: !(error || warning || info)
@@ -143,7 +146,6 @@ const RadioButtonGroup = props => {
143
146
  error: !!error,
144
147
  warning: !!warning,
145
148
  info: !!info,
146
- required,
147
149
  ...child.props
148
150
  });
149
151
  }))))));
@@ -3,9 +3,8 @@ import { MarginProps } from "styled-system";
3
3
  import { CommonCheckableInputProps } from "../../__internal__/checkable-input";
4
4
  interface InternalRadioButtonProps {
5
5
  inline?: boolean;
6
- required?: boolean;
7
6
  }
8
- export interface RadioButtonProps extends CommonCheckableInputProps, MarginProps {
7
+ export interface RadioButtonProps extends Omit<CommonCheckableInputProps, "required" | "IsOptional">, MarginProps {
9
8
  /** Identifier used for testing purposes, applied to the root element of the component. */
10
9
  "data-component"?: string;
11
10
  /** Identifier used for testing purposes, applied to the root element of the component. */
@@ -38,7 +38,6 @@ const RadioButton = exports.RadioButton = /*#__PURE__*/_react.default.forwardRef
38
38
  onFocus,
39
39
  value,
40
40
  reverse = false,
41
- required,
42
41
  size,
43
42
  error,
44
43
  warning,
@@ -106,7 +105,6 @@ const RadioButton = exports.RadioButton = /*#__PURE__*/_react.default.forwardRef
106
105
  * opposite way around by default)
107
106
  */
108
107
  reverse: !reverse,
109
- required,
110
108
  ref: ref || inputRef,
111
109
  ...props
112
110
  };
@@ -234,6 +232,7 @@ if (process.env.NODE_ENV !== "production") {
234
232
  })]),
235
233
  "inputWidth": _propTypes.default.number,
236
234
  "is": _propTypes.default.string,
235
+ "isOptional": _propTypes.default.bool,
237
236
  "itemID": _propTypes.default.string,
238
237
  "itemProp": _propTypes.default.string,
239
238
  "itemRef": _propTypes.default.string,
@@ -574,7 +573,6 @@ if (process.env.NODE_ENV !== "production") {
574
573
  "radioGroup": _propTypes.default.string,
575
574
  "readOnly": _propTypes.default.bool,
576
575
  "rel": _propTypes.default.string,
577
- "required": _propTypes.default.bool,
578
576
  "resource": _propTypes.default.string,
579
577
  "results": _propTypes.default.number,
580
578
  "rev": _propTypes.default.string,
@@ -61,6 +61,10 @@ export interface FilterableSelectProps extends Omit<FormInputPropTypes, "default
61
61
  /** Boolean to disable automatic filtering and highlighting of options.
62
62
  * This allows custom filtering and option styling to be performed outside of the component when the filter text changes. */
63
63
  disableDefaultFiltering?: boolean;
64
+ /** Flag to configure component as optional. */
65
+ isOptional?: boolean;
66
+ /** Flag to configure component as mandatory */
67
+ required?: boolean;
64
68
  }
65
69
  export declare const FilterableSelect: React.ForwardRefExoticComponent<FilterableSelectProps & React.RefAttributes<unknown>>;
66
70
  export default FilterableSelect;
@@ -63,6 +63,8 @@ const FilterableSelect = exports.FilterableSelect = /*#__PURE__*/_react.default.
63
63
  enableVirtualScroll,
64
64
  virtualScrollOverscan,
65
65
  disableDefaultFiltering = false,
66
+ isOptional,
67
+ required,
66
68
  ...textboxProps
67
69
  }, ref) => {
68
70
  const [activeDescendantId, setActiveDescendantId] = (0, _react.useState)();
@@ -406,6 +408,8 @@ const FilterableSelect = exports.FilterableSelect = /*#__PURE__*/_react.default.
406
408
  onMouseDown: handleTextboxMouseDown,
407
409
  tooltipPosition,
408
410
  inputRef,
411
+ required,
412
+ isOptional,
409
413
  ...(0, _utils.filterOutStyledSystemSpacingProps)(textboxProps)
410
414
  };
411
415
  }
@@ -574,6 +578,7 @@ if (process.env.NODE_ENV !== "production") {
574
578
  "inputWidth": _propTypes.default.number,
575
579
  "is": _propTypes.default.string,
576
580
  "isLoading": _propTypes.default.bool,
581
+ "isOptional": _propTypes.default.bool,
577
582
  "itemID": _propTypes.default.string,
578
583
  "itemProp": _propTypes.default.string,
579
584
  "itemRef": _propTypes.default.string,
@@ -55,6 +55,8 @@ export interface MultiSelectProps extends Omit<FormInputPropTypes, "defaultValue
55
55
  * Higher values make for smoother scrolling but may impact performance.
56
56
  * Only used if the `enableVirtualScroll` prop is set. */
57
57
  virtualScrollOverscan?: number;
58
+ /** Flag to configure component as optional. */
59
+ isOptional?: boolean;
58
60
  }
59
61
  export declare const MultiSelect: React.ForwardRefExoticComponent<MultiSelectProps & React.RefAttributes<unknown>>;
60
62
  export default MultiSelect;
@@ -64,6 +64,8 @@ const MultiSelect = exports.MultiSelect = /*#__PURE__*/_react.default.forwardRef
64
64
  inputRef,
65
65
  enableVirtualScroll,
66
66
  virtualScrollOverscan,
67
+ isOptional,
68
+ required,
67
69
  ...textboxProps
68
70
  }, ref) => {
69
71
  const [activeDescendantId, setActiveDescendantId] = (0, _react.useState)();
@@ -413,6 +415,8 @@ const MultiSelect = exports.MultiSelect = /*#__PURE__*/_react.default.forwardRef
413
415
  onChange: handleTextboxChange,
414
416
  tooltipPosition,
415
417
  size,
418
+ required,
419
+ isOptional,
416
420
  inputRef,
417
421
  ...(0, _utils.filterOutStyledSystemSpacingProps)(textboxProps)
418
422
  };
@@ -583,6 +587,7 @@ if (process.env.NODE_ENV !== "production") {
583
587
  "inputWidth": _propTypes.default.number,
584
588
  "is": _propTypes.default.string,
585
589
  "isLoading": _propTypes.default.bool,
590
+ "isOptional": _propTypes.default.bool,
586
591
  "itemID": _propTypes.default.string,
587
592
  "itemProp": _propTypes.default.string,
588
593
  "itemRef": _propTypes.default.string,
@@ -59,6 +59,8 @@ export interface FormInputPropTypes extends ValidationProps, Omit<CommonTextboxP
59
59
  *
60
60
  */
61
61
  labelId?: string;
62
+ /** Flag to configure component as optional in Form */
63
+ isOptional?: boolean;
62
64
  }
63
65
  export interface SelectTextboxProps extends FormInputPropTypes {
64
66
  /** Id attribute of the select list */
@@ -46,6 +46,7 @@ const SelectTextbox = /*#__PURE__*/_react.default.forwardRef(({
46
46
  onChange,
47
47
  selectedValue,
48
48
  required,
49
+ isOptional,
49
50
  textboxRef,
50
51
  hasTextCursor,
51
52
  transparent,
@@ -89,6 +90,7 @@ const SelectTextbox = /*#__PURE__*/_react.default.forwardRef(({
89
90
  id,
90
91
  readOnly,
91
92
  required,
93
+ isOptional,
92
94
  onClick: handleTextboxClick,
93
95
  onFocus: handleTextboxFocus,
94
96
  onBlur: handleTextboxBlur,
@@ -243,6 +245,7 @@ if (process.env.NODE_ENV !== "production") {
243
245
  "inputWidth": _propTypes.default.number,
244
246
  "is": _propTypes.default.string,
245
247
  "isOpen": _propTypes.default.bool,
248
+ "isOptional": _propTypes.default.bool,
246
249
  "itemID": _propTypes.default.string,
247
250
  "itemProp": _propTypes.default.string,
248
251
  "itemRef": _propTypes.default.string,
@@ -61,6 +61,10 @@ export interface SimpleSelectProps extends Omit<FormInputPropTypes, "defaultValu
61
61
  * Higher values make for smoother scrolling but may impact performance.
62
62
  * Only used if the `enableVirtualScroll` prop is set. */
63
63
  virtualScrollOverscan?: number;
64
+ /** Flag to configure component as optional in Form */
65
+ isOptional?: boolean;
66
+ /** Flag to configure component as mandatory */
67
+ isRequired?: boolean;
64
68
  }
65
69
  export declare const SimpleSelect: React.ForwardRefExoticComponent<SimpleSelectProps & React.RefAttributes<unknown>>;
66
70
  export default SimpleSelect;
@@ -57,6 +57,8 @@ const SimpleSelect = exports.SimpleSelect = /*#__PURE__*/_react.default.forwardR
57
57
  inputRef,
58
58
  enableVirtualScroll,
59
59
  virtualScrollOverscan,
60
+ isOptional,
61
+ required,
60
62
  ...props
61
63
  }, ref) => {
62
64
  const selectListId = (0, _react.useRef)((0, _guid.default)());
@@ -323,6 +325,8 @@ const SimpleSelect = exports.SimpleSelect = /*#__PURE__*/_react.default.forwardR
323
325
  onKeyDown: handleTextboxKeydown,
324
326
  onBlur: handleTextboxBlur,
325
327
  tooltipPosition,
328
+ required,
329
+ isOptional,
326
330
  transparent,
327
331
  inputRef,
328
332
  ...(0, _utils.filterOutStyledSystemSpacingProps)(props)
@@ -485,6 +489,8 @@ if (process.env.NODE_ENV !== "production") {
485
489
  "inputWidth": _propTypes.default.number,
486
490
  "is": _propTypes.default.string,
487
491
  "isLoading": _propTypes.default.bool,
492
+ "isOptional": _propTypes.default.bool,
493
+ "isRequired": _propTypes.default.bool,
488
494
  "itemID": _propTypes.default.string,
489
495
  "itemProp": _propTypes.default.string,
490
496
  "itemRef": _propTypes.default.string,
@@ -284,6 +284,7 @@ if (process.env.NODE_ENV !== "production") {
284
284
  })]),
285
285
  "inputWidth": _propTypes.default.number,
286
286
  "is": _propTypes.default.string,
287
+ "isOptional": _propTypes.default.bool,
287
288
  "itemID": _propTypes.default.string,
288
289
  "itemProp": _propTypes.default.string,
289
290
  "itemRef": _propTypes.default.string,
@@ -16,8 +16,10 @@ export interface TextEditorProps extends MarginProps {
16
16
  toolbarElements?: React.ReactNode;
17
17
  /** The value of the input, this is an EditorState immutable object */
18
18
  value: EditorState;
19
- /** Flag to configure component as mandatory */
19
+ /** Flag to configure component as mandatory. */
20
20
  required?: boolean;
21
+ /** Flag to configure component as optional. */
22
+ isOptional?: boolean;
21
23
  /** Message to be displayed when there is an error */
22
24
  error?: string;
23
25
  /** Message to be displayed when there is a warning */