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.
- package/esm/__internal__/checkable-input/checkable-input.component.d.ts +2 -0
- package/esm/__internal__/checkable-input/checkable-input.component.js +4 -2
- package/esm/__internal__/fieldset/fieldset.style.js +7 -6
- package/esm/__internal__/form-field/form-field.component.d.ts +1 -1
- package/esm/__internal__/form-field/form-field.component.js +1 -0
- package/esm/__internal__/label/label.style.js +6 -5
- package/esm/components/checkbox/checkbox-group/checkbox-group.component.d.ts +2 -0
- package/esm/components/checkbox/checkbox-group/checkbox-group.component.js +5 -2
- package/esm/components/checkbox/checkbox.component.js +3 -0
- package/esm/components/date-range/date-range.component.d.ts +5 -1
- package/esm/components/date-range/date-range.component.js +5 -1
- package/esm/components/decimal/decimal.component.d.ts +0 -2
- package/esm/components/decimal/decimal.component.js +1 -2
- package/esm/components/fieldset/fieldset.component.d.ts +8 -3
- package/esm/components/fieldset/fieldset.component.js +16 -2
- package/esm/components/fieldset/fieldset.style.d.ts +4 -0
- package/esm/components/fieldset/fieldset.style.js +29 -2
- package/esm/components/file-input/file-input.component.d.ts +4 -0
- package/esm/components/file-input/file-input.component.js +3 -0
- package/esm/components/form/index.d.ts +1 -0
- package/esm/components/form/index.js +2 -1
- package/esm/components/form/required-fields-indicator/index.d.ts +1 -0
- package/esm/components/form/required-fields-indicator/index.js +1 -0
- package/esm/components/form/required-fields-indicator/required-fields-indicator.component.d.ts +7 -0
- package/esm/components/form/required-fields-indicator/required-fields-indicator.component.js +20 -0
- package/esm/components/inline-inputs/inline-inputs.component.d.ts +3 -1
- package/esm/components/inline-inputs/inline-inputs.component.js +13 -3
- package/esm/components/numeral-date/numeral-date.component.d.ts +3 -1
- package/esm/components/numeral-date/numeral-date.component.js +4 -3
- package/esm/components/radio-button/radio-button-group/radio-button-group.component.d.ts +2 -0
- package/esm/components/radio-button/radio-button-group/radio-button-group.component.js +5 -3
- package/esm/components/radio-button/radio-button.component.d.ts +1 -2
- package/esm/components/radio-button/radio-button.component.js +1 -3
- package/esm/components/select/filterable-select/filterable-select.component.d.ts +4 -0
- package/esm/components/select/filterable-select/filterable-select.component.js +5 -0
- package/esm/components/select/multi-select/multi-select.component.d.ts +2 -0
- package/esm/components/select/multi-select/multi-select.component.js +5 -0
- package/esm/components/select/select-textbox/select-textbox.component.d.ts +2 -0
- package/esm/components/select/select-textbox/select-textbox.component.js +3 -0
- package/esm/components/select/simple-select/simple-select.component.d.ts +4 -0
- package/esm/components/select/simple-select/simple-select.component.js +6 -0
- package/esm/components/switch/switch.component.js +1 -0
- package/esm/components/text-editor/text-editor.component.d.ts +3 -1
- package/esm/components/text-editor/text-editor.component.js +16 -2
- package/esm/components/textarea/textarea.component.d.ts +2 -2
- package/esm/components/textarea/textarea.component.js +7 -2
- package/esm/components/textbox/textbox.component.d.ts +2 -2
- package/esm/components/tile-select/tile-select.style.d.ts +1 -1
- package/lib/__internal__/checkable-input/checkable-input.component.d.ts +2 -0
- package/lib/__internal__/checkable-input/checkable-input.component.js +4 -2
- package/lib/__internal__/fieldset/fieldset.style.js +7 -6
- package/lib/__internal__/form-field/form-field.component.d.ts +1 -1
- package/lib/__internal__/form-field/form-field.component.js +1 -0
- package/lib/__internal__/label/label.style.js +6 -5
- package/lib/components/checkbox/checkbox-group/checkbox-group.component.d.ts +2 -0
- package/lib/components/checkbox/checkbox-group/checkbox-group.component.js +5 -2
- package/lib/components/checkbox/checkbox.component.js +3 -0
- package/lib/components/date-range/date-range.component.d.ts +5 -1
- package/lib/components/date-range/date-range.component.js +5 -1
- package/lib/components/decimal/decimal.component.d.ts +0 -2
- package/lib/components/decimal/decimal.component.js +1 -2
- package/lib/components/fieldset/fieldset.component.d.ts +8 -3
- package/lib/components/fieldset/fieldset.component.js +18 -2
- package/lib/components/fieldset/fieldset.style.d.ts +4 -0
- package/lib/components/fieldset/fieldset.style.js +31 -2
- package/lib/components/file-input/file-input.component.d.ts +4 -0
- package/lib/components/file-input/file-input.component.js +3 -0
- package/lib/components/form/index.d.ts +1 -0
- package/lib/components/form/index.js +7 -0
- package/lib/components/form/required-fields-indicator/index.d.ts +1 -0
- package/lib/components/form/required-fields-indicator/index.js +13 -0
- package/lib/components/form/required-fields-indicator/package.json +6 -0
- package/lib/components/form/required-fields-indicator/required-fields-indicator.component.d.ts +7 -0
- package/lib/components/form/required-fields-indicator/required-fields-indicator.component.js +28 -0
- package/lib/components/inline-inputs/inline-inputs.component.d.ts +3 -1
- package/lib/components/inline-inputs/inline-inputs.component.js +14 -4
- package/lib/components/numeral-date/numeral-date.component.d.ts +3 -1
- package/lib/components/numeral-date/numeral-date.component.js +4 -3
- package/lib/components/radio-button/radio-button-group/radio-button-group.component.d.ts +2 -0
- package/lib/components/radio-button/radio-button-group/radio-button-group.component.js +5 -3
- package/lib/components/radio-button/radio-button.component.d.ts +1 -2
- package/lib/components/radio-button/radio-button.component.js +1 -3
- package/lib/components/select/filterable-select/filterable-select.component.d.ts +4 -0
- package/lib/components/select/filterable-select/filterable-select.component.js +5 -0
- package/lib/components/select/multi-select/multi-select.component.d.ts +2 -0
- package/lib/components/select/multi-select/multi-select.component.js +5 -0
- package/lib/components/select/select-textbox/select-textbox.component.d.ts +2 -0
- package/lib/components/select/select-textbox/select-textbox.component.js +3 -0
- package/lib/components/select/simple-select/simple-select.component.d.ts +4 -0
- package/lib/components/select/simple-select/simple-select.component.js +6 -0
- package/lib/components/switch/switch.component.js +1 -0
- package/lib/components/text-editor/text-editor.component.d.ts +3 -1
- package/lib/components/text-editor/text-editor.component.js +16 -2
- package/lib/components/textarea/textarea.component.d.ts +2 -2
- package/lib/components/textarea/textarea.component.js +7 -2
- package/lib/components/textbox/textbox.component.d.ts +2 -2
- package/lib/components/tile-select/tile-select.style.d.ts +1 -1
- 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,
|
|
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
|
|
83
|
-
|
|
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:
|
|
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;
|