carbon-react 154.3.0 → 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/decimal/decimal.component.js +3 -0
- 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/decimal/decimal.component.js +3 -0
- 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 +2 -2
|
@@ -146,6 +146,9 @@ export const Decimal = /*#__PURE__*/React.forwardRef(({
|
|
|
146
146
|
const message = "Input elements should not switch from uncontrolled to controlled (or vice versa). " + "Decide between using a controlled or uncontrolled input element for the lifetime of the component";
|
|
147
147
|
!(prevControlledRef.current !== isControlled) ? process.env.NODE_ENV !== "production" ? invariant(false, message) : invariant(false) : void 0;
|
|
148
148
|
prevControlledRef.current = isControlled;
|
|
149
|
+
return () => {
|
|
150
|
+
prevControlledRef.current = null;
|
|
151
|
+
};
|
|
149
152
|
}, [isControlled]);
|
|
150
153
|
const prevValue = usePrevious(value);
|
|
151
154
|
useEffect(() => {
|
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,
|
|
@@ -155,6 +155,9 @@ const Decimal = exports.Decimal = /*#__PURE__*/_react.default.forwardRef(({
|
|
|
155
155
|
const message = "Input elements should not switch from uncontrolled to controlled (or vice versa). " + "Decide between using a controlled or uncontrolled input element for the lifetime of the component";
|
|
156
156
|
!(prevControlledRef.current !== isControlled) ? process.env.NODE_ENV !== "production" ? (0, _invariant.default)(false, message) : (0, _invariant.default)(false) : void 0;
|
|
157
157
|
prevControlledRef.current = isControlled;
|
|
158
|
+
return () => {
|
|
159
|
+
prevControlledRef.current = null;
|
|
160
|
+
};
|
|
158
161
|
}, [isControlled]);
|
|
159
162
|
const prevValue = (0, _usePrevious.default)(value);
|
|
160
163
|
(0, _react.useEffect)(() => {
|
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,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "carbon-react",
|
|
3
|
-
"version": "154.3.
|
|
3
|
+
"version": "154.3.2",
|
|
4
4
|
"description": "A library of reusable React components for easily building user interfaces.",
|
|
5
5
|
"files": [
|
|
6
6
|
"lib",
|
|
@@ -91,7 +91,7 @@
|
|
|
91
91
|
"@storybook/types": "~8.6.7",
|
|
92
92
|
"@testing-library/dom": "^10.4.0",
|
|
93
93
|
"@testing-library/jest-dom": "^6.6.3",
|
|
94
|
-
"@testing-library/react": "^16.
|
|
94
|
+
"@testing-library/react": "^16.3.0",
|
|
95
95
|
"@testing-library/user-event": "^14.5.2",
|
|
96
96
|
"@types/crypto-js": "^4.2.1",
|
|
97
97
|
"@types/glob": "^8.1.0",
|