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
@@ -25,6 +25,7 @@ var _useCharacterCount = _interopRequireDefault(require("../../hooks/__internal_
25
25
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
26
26
  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); }
27
27
  function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && Object.prototype.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
28
+ 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); }
28
29
  const NUMBERS = ["0", "1", "2", "3", "4", "5", "6", "7", "8", "9"];
29
30
  const INLINE_STYLES = [_types.BOLD, _types.ITALIC];
30
31
  const EditorContext = exports.EditorContext = /*#__PURE__*/_react.default.createContext({});
@@ -42,6 +43,7 @@ const TextEditor = exports.TextEditor = /*#__PURE__*/_react.default.forwardRef((
42
43
  previews,
43
44
  onLinkAdded,
44
45
  inputHint,
46
+ isOptional,
45
47
  ...rest
46
48
  }, ref) => {
47
49
  const {
@@ -52,6 +54,7 @@ const TextEditor = exports.TextEditor = /*#__PURE__*/_react.default.forwardRef((
52
54
  const [activeInlines, setActiveInlines] = (0, _react.useState)({});
53
55
  const [focusToolbar, setFocusToolbar] = (0, _react.useState)(false);
54
56
  const editorRef = (0, _react.useRef)(null);
57
+ const wrapper = (0, _react.useRef)(null);
55
58
  const editor = ref || editorRef;
56
59
  const contentLength = (0, _utils.getContent)(value).getPlainText("").length;
57
60
  const moveCursor = (0, _react.useRef)(contentLength > 0);
@@ -251,16 +254,26 @@ const TextEditor = exports.TextEditor = /*#__PURE__*/_react.default.forwardRef((
251
254
  editor.current?.focus();
252
255
  }
253
256
  };
257
+ (0, _react.useEffect)(() => {
258
+ if (required) {
259
+ const editableElement = wrapper.current?.querySelector("div[contenteditable='true']");
260
+ editableElement?.setAttribute("required", "");
261
+ editableElement?.setAttribute("aria-required", "true");
262
+ }
263
+ }, [required]);
254
264
  return /*#__PURE__*/_react.default.createElement(EditorContext.Provider, {
255
265
  value: {
256
266
  onLinkAdded,
257
267
  editMode: true
258
268
  }
259
- }, /*#__PURE__*/_react.default.createElement(_textEditor.StyledEditorWrapper, rest, /*#__PURE__*/_react.default.createElement(_labelWrapper.default, {
269
+ }, /*#__PURE__*/_react.default.createElement(_textEditor.StyledEditorWrapper, _extends({
270
+ ref: wrapper
271
+ }, rest), /*#__PURE__*/_react.default.createElement(_labelWrapper.default, {
260
272
  onClick: () => handleEditorFocus(true)
261
273
  }, /*#__PURE__*/_react.default.createElement(_label.default, {
262
274
  labelId: labelId,
263
- isRequired: required
275
+ isRequired: required,
276
+ optional: isOptional
264
277
  }, labelText)), inputHint && /*#__PURE__*/_react.default.createElement(_textbox.StyledHintText, {
265
278
  id: inputHintId.current
266
279
  }, inputHint), /*#__PURE__*/_react.default.createElement(_box.default, {
@@ -322,6 +335,7 @@ if (process.env.NODE_ENV !== "production") {
322
335
  "error": _propTypes.default.string,
323
336
  "info": _propTypes.default.string,
324
337
  "inputHint": _propTypes.default.string,
338
+ "isOptional": _propTypes.default.bool,
325
339
  "labelText": _propTypes.default.string.isRequired,
326
340
  "m": _propTypes.default.oneOfType([_propTypes.default.arrayOf(_propTypes.default.oneOfType([_propTypes.default.oneOf([null]), _propTypes.default.number, _propTypes.default.shape({
327
341
  "__@toStringTag": _propTypes.default.string.isRequired,
@@ -79,8 +79,8 @@ export interface TextareaProps extends ValidationProps, MarginProps, Omit<Common
79
79
  placeholder?: string;
80
80
  /** Adds readOnly property */
81
81
  readOnly?: boolean;
82
- /** Flag to configure component as mandatory */
83
- required?: boolean;
82
+ /** Flag to configure component as optional */
83
+ isOptional?: boolean;
84
84
  /** The number of visible text lines for the control */
85
85
  rows?: number;
86
86
  /** One of type of size to apply to the textarea */
@@ -69,6 +69,8 @@ const Textarea = exports.OriginalTextarea = exports.Textarea = /*#__PURE__*/_rea
69
69
  inputRef,
70
70
  borderRadius,
71
71
  hideBorders = false,
72
+ required,
73
+ isOptional,
72
74
  ...rest
73
75
  }, ref) => {
74
76
  const {
@@ -194,7 +196,8 @@ const Textarea = exports.OriginalTextarea = exports.Textarea = /*#__PURE__*/_rea
194
196
  as: "textarea",
195
197
  inputRef: inputRef,
196
198
  validationIconId: validationRedesignOptIn ? undefined : validationId,
197
- inputBorderRadius: borderRadius
199
+ inputBorderRadius: borderRadius,
200
+ required: required
198
201
  }, rest)), children, /*#__PURE__*/_react.default.createElement(_inputIconToggle.default, {
199
202
  disabled: disabled,
200
203
  readOnly: readOnly,
@@ -231,7 +234,8 @@ const Textarea = exports.OriginalTextarea = exports.Textarea = /*#__PURE__*/_rea
231
234
  labelWidth: computeLabelPropValues(labelWidth),
232
235
  labelHelp: computeLabelPropValues(labelHelp),
233
236
  labelSpacing: labelSpacing,
234
- isRequired: rest.required,
237
+ isRequired: required,
238
+ isOptional: isOptional,
235
239
  useValidationIcon: computeLabelPropValues(validationOnLabel),
236
240
  adaptiveLabelBreakpoint: adaptiveLabelBreakpoint,
237
241
  validationRedesignOptIn: validationRedesignOptIn
@@ -358,6 +362,7 @@ if (process.env.NODE_ENV !== "production") {
358
362
  "inputRef": _propTypes.default.func,
359
363
  "inputWidth": _propTypes.default.number,
360
364
  "is": _propTypes.default.string,
365
+ "isOptional": _propTypes.default.bool,
361
366
  "itemID": _propTypes.default.string,
362
367
  "itemProp": _propTypes.default.string,
363
368
  "itemRef": _propTypes.default.string,
@@ -91,12 +91,12 @@ export interface CommonTextboxProps extends ValidationProps, MarginProps, Omit<C
91
91
  tooltipPosition?: "top" | "bottom" | "left" | "right";
92
92
  /** Aria label for rendered help component */
93
93
  helpAriaLabel?: string;
94
+ /** Flag to configure component as optional. */
95
+ isOptional?: boolean;
94
96
  }
95
97
  export interface TextboxProps extends CommonTextboxProps {
96
98
  /** Content to be rendered next to the input */
97
99
  children?: React.ReactNode;
98
- /** [Legacy] Flag to configure component as optional in Form */
99
- isOptional?: boolean;
100
100
  /** Container for DatePicker or SelectList components */
101
101
  positionedChildren?: React.ReactNode;
102
102
  /** Character limit of the textarea */
@@ -28,7 +28,7 @@ declare const StyledDeselectWrapper: import("styled-components").StyledComponent
28
28
  hasActionAdornment: boolean;
29
29
  }, never>;
30
30
  declare const StyledTileSelectFieldset: import("styled-components").StyledComponent<{
31
- ({ children, inline, legend, ...rest }: import("../fieldset").FieldsetProps): import("react").JSX.Element;
31
+ ({ children, inline, legend, required, isOptional, ...rest }: import("../fieldset").FieldsetProps): import("react").JSX.Element;
32
32
  displayName: string;
33
33
  }, any, {
34
34
  multiSelect: boolean;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "carbon-react",
3
- "version": "128.1.2",
3
+ "version": "128.2.0",
4
4
  "description": "A library of reusable React components for easily building user interfaces.",
5
5
  "files": [
6
6
  "lib",