carbon-react 154.3.1 → 154.3.2
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/components/text-editor/__internal__/plugins/ContentEditor/content-editor.component.d.ts +6 -0
- package/esm/components/text-editor/__internal__/plugins/ContentEditor/content-editor.component.js +11 -3
- package/esm/components/text-editor/text-editor.component.js +5 -1
- package/lib/components/text-editor/__internal__/plugins/ContentEditor/content-editor.component.d.ts +6 -0
- package/lib/components/text-editor/__internal__/plugins/ContentEditor/content-editor.component.js +11 -3
- package/lib/components/text-editor/text-editor.component.js +5 -1
- package/package.json +1 -1
package/esm/components/text-editor/__internal__/plugins/ContentEditor/content-editor.component.d.ts
CHANGED
|
@@ -10,6 +10,12 @@ export interface ContentEditorProps {
|
|
|
10
10
|
rows?: number;
|
|
11
11
|
/** Whether the editor is read-only */
|
|
12
12
|
readOnly?: boolean;
|
|
13
|
+
/** Whether the editor is required */
|
|
14
|
+
required?: boolean;
|
|
15
|
+
/** Editor has an error */
|
|
16
|
+
error?: boolean;
|
|
17
|
+
/** Editor has a warning */
|
|
18
|
+
warning?: boolean;
|
|
13
19
|
}
|
|
14
20
|
declare const ContentEditor: React.ForwardRefExoticComponent<ContentEditorProps & React.RefAttributes<HTMLDivElement>>;
|
|
15
21
|
export default ContentEditor;
|
package/esm/components/text-editor/__internal__/plugins/ContentEditor/content-editor.component.js
CHANGED
|
@@ -11,9 +11,15 @@ const ContentEditor = /*#__PURE__*/forwardRef(({
|
|
|
11
11
|
namespace,
|
|
12
12
|
previews = [],
|
|
13
13
|
rows,
|
|
14
|
-
readOnly
|
|
14
|
+
readOnly,
|
|
15
|
+
required,
|
|
16
|
+
error,
|
|
17
|
+
warning
|
|
15
18
|
}, ref) => {
|
|
16
19
|
const focusAtEnd = useCursorAtEnd();
|
|
20
|
+
const validationMessageId = error || warning ? `${namespace}-validation-message` : "";
|
|
21
|
+
const inputHintId = inputHint ? `${namespace}-input-hint` : "";
|
|
22
|
+
const ariaDescribedBy = `${validationMessageId} ${inputHintId}`.trim();
|
|
17
23
|
return /*#__PURE__*/React.createElement(StyledContentEditable, {
|
|
18
24
|
"data-role": `${namespace}-content-editable`,
|
|
19
25
|
namespace: namespace,
|
|
@@ -21,8 +27,10 @@ const ContentEditor = /*#__PURE__*/forwardRef(({
|
|
|
21
27
|
readOnly: readOnly
|
|
22
28
|
}, /*#__PURE__*/React.createElement(ContentEditable, {
|
|
23
29
|
ref: ref,
|
|
24
|
-
"aria-describedby":
|
|
30
|
+
"aria-describedby": ariaDescribedBy,
|
|
25
31
|
"aria-labelledby": `${namespace}-label`,
|
|
32
|
+
"aria-required": required,
|
|
33
|
+
"aria-invalid": error,
|
|
26
34
|
className: `${namespace}-editable`,
|
|
27
35
|
"data-role": `${namespace}-editable`,
|
|
28
36
|
onFocus: event => {
|
|
@@ -32,7 +40,7 @@ const ContentEditor = /*#__PURE__*/forwardRef(({
|
|
|
32
40
|
focusAtEnd(event);
|
|
33
41
|
}
|
|
34
42
|
}
|
|
35
|
-
/** The following are automatically added by Lexical but violate WCAG 4.1.2 Name, Role, Value and so have been
|
|
43
|
+
/** The following are automatically added by Lexical but violate WCAG 4.1.2 Name, Role, Value and so have been overridden */,
|
|
36
44
|
"aria-autocomplete": undefined,
|
|
37
45
|
"aria-readonly": undefined
|
|
38
46
|
}), /*#__PURE__*/React.createElement(LinkPreviewerPlugin, {
|
|
@@ -164,6 +164,7 @@ export const TextEditor = ({
|
|
|
164
164
|
warning: characterLimitWarning || warning || undefined
|
|
165
165
|
}, (error || characterLimitWarning || warning) && /*#__PURE__*/React.createElement(StyledValidationMessage, {
|
|
166
166
|
error: error,
|
|
167
|
+
id: `${namespace}-validation-message`,
|
|
167
168
|
"data-role": `${namespace}-validation-message`
|
|
168
169
|
}, error || characterLimitWarning || warning), /*#__PURE__*/React.createElement(StyledEditorToolbarWrapper, {
|
|
169
170
|
"data-role": `${namespace}-editor-toolbar-wrapper`,
|
|
@@ -183,7 +184,10 @@ export const TextEditor = ({
|
|
|
183
184
|
namespace: namespace,
|
|
184
185
|
previews: previews,
|
|
185
186
|
rows: rows,
|
|
186
|
-
readOnly: readOnly
|
|
187
|
+
readOnly: readOnly,
|
|
188
|
+
required: required,
|
|
189
|
+
error: !!error,
|
|
190
|
+
warning: !!warning || !!characterLimitWarning
|
|
187
191
|
}),
|
|
188
192
|
placeholder: /*#__PURE__*/React.createElement(Placeholder, {
|
|
189
193
|
namespace: namespace,
|
package/lib/components/text-editor/__internal__/plugins/ContentEditor/content-editor.component.d.ts
CHANGED
|
@@ -10,6 +10,12 @@ export interface ContentEditorProps {
|
|
|
10
10
|
rows?: number;
|
|
11
11
|
/** Whether the editor is read-only */
|
|
12
12
|
readOnly?: boolean;
|
|
13
|
+
/** Whether the editor is required */
|
|
14
|
+
required?: boolean;
|
|
15
|
+
/** Editor has an error */
|
|
16
|
+
error?: boolean;
|
|
17
|
+
/** Editor has a warning */
|
|
18
|
+
warning?: boolean;
|
|
13
19
|
}
|
|
14
20
|
declare const ContentEditor: React.ForwardRefExoticComponent<ContentEditorProps & React.RefAttributes<HTMLDivElement>>;
|
|
15
21
|
export default ContentEditor;
|
package/lib/components/text-editor/__internal__/plugins/ContentEditor/content-editor.component.js
CHANGED
|
@@ -21,9 +21,15 @@ const ContentEditor = /*#__PURE__*/(0, _react.forwardRef)(({
|
|
|
21
21
|
namespace,
|
|
22
22
|
previews = [],
|
|
23
23
|
rows,
|
|
24
|
-
readOnly
|
|
24
|
+
readOnly,
|
|
25
|
+
required,
|
|
26
|
+
error,
|
|
27
|
+
warning
|
|
25
28
|
}, ref) => {
|
|
26
29
|
const focusAtEnd = (0, _.useCursorAtEnd)();
|
|
30
|
+
const validationMessageId = error || warning ? `${namespace}-validation-message` : "";
|
|
31
|
+
const inputHintId = inputHint ? `${namespace}-input-hint` : "";
|
|
32
|
+
const ariaDescribedBy = `${validationMessageId} ${inputHintId}`.trim();
|
|
27
33
|
return /*#__PURE__*/_react.default.createElement(_contentEditor.default, {
|
|
28
34
|
"data-role": `${namespace}-content-editable`,
|
|
29
35
|
namespace: namespace,
|
|
@@ -31,8 +37,10 @@ const ContentEditor = /*#__PURE__*/(0, _react.forwardRef)(({
|
|
|
31
37
|
readOnly: readOnly
|
|
32
38
|
}, /*#__PURE__*/_react.default.createElement(_LexicalContentEditable.ContentEditable, {
|
|
33
39
|
ref: ref,
|
|
34
|
-
"aria-describedby":
|
|
40
|
+
"aria-describedby": ariaDescribedBy,
|
|
35
41
|
"aria-labelledby": `${namespace}-label`,
|
|
42
|
+
"aria-required": required,
|
|
43
|
+
"aria-invalid": error,
|
|
36
44
|
className: `${namespace}-editable`,
|
|
37
45
|
"data-role": `${namespace}-editable`,
|
|
38
46
|
onFocus: event => {
|
|
@@ -42,7 +50,7 @@ const ContentEditor = /*#__PURE__*/(0, _react.forwardRef)(({
|
|
|
42
50
|
focusAtEnd(event);
|
|
43
51
|
}
|
|
44
52
|
}
|
|
45
|
-
/** The following are automatically added by Lexical but violate WCAG 4.1.2 Name, Role, Value and so have been
|
|
53
|
+
/** The following are automatically added by Lexical but violate WCAG 4.1.2 Name, Role, Value and so have been overridden */,
|
|
46
54
|
"aria-autocomplete": undefined,
|
|
47
55
|
"aria-readonly": undefined
|
|
48
56
|
}), /*#__PURE__*/_react.default.createElement(_.LinkPreviewerPlugin, {
|
|
@@ -172,6 +172,7 @@ const TextEditor = ({
|
|
|
172
172
|
warning: characterLimitWarning || warning || undefined
|
|
173
173
|
}, (error || characterLimitWarning || warning) && /*#__PURE__*/_react.default.createElement(_textEditor2.StyledValidationMessage, {
|
|
174
174
|
error: error,
|
|
175
|
+
id: `${namespace}-validation-message`,
|
|
175
176
|
"data-role": `${namespace}-validation-message`
|
|
176
177
|
}, error || characterLimitWarning || warning), /*#__PURE__*/_react.default.createElement(_textEditor2.StyledEditorToolbarWrapper, {
|
|
177
178
|
"data-role": `${namespace}-editor-toolbar-wrapper`,
|
|
@@ -191,7 +192,10 @@ const TextEditor = ({
|
|
|
191
192
|
namespace: namespace,
|
|
192
193
|
previews: previews,
|
|
193
194
|
rows: rows,
|
|
194
|
-
readOnly: readOnly
|
|
195
|
+
readOnly: readOnly,
|
|
196
|
+
required: required,
|
|
197
|
+
error: !!error,
|
|
198
|
+
warning: !!warning || !!characterLimitWarning
|
|
195
199
|
}),
|
|
196
200
|
placeholder: /*#__PURE__*/_react.default.createElement(_plugins.Placeholder, {
|
|
197
201
|
namespace: namespace,
|