@coopdigital/react 0.37.0 → 0.38.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.
@@ -3,6 +3,8 @@ import { FormFieldError, StandardSizes } from "../../../src/types";
3
3
  export interface CheckboxProps extends Omit<InputHTMLAttributes<HTMLInputElement>, "size" | "type"> {
4
4
  /** **(Optional)** Specify additional CSS classes to be applied to the component. */
5
5
  className?: string;
6
+ /** **(Optional)** Specify whether the Checkbox should be disabled. Refer to Experience Library guidance on disabled form controls and accessibility. */
7
+ disabled?: boolean;
6
8
  /** **(Optional)** Specify the Checkbox error state.
7
9
  *
8
10
  * This is an instance of `FormFieldError`. You can provide either an object with a `message` key, or a boolean value if you need to render the message independently.
@@ -26,5 +28,5 @@ export interface CheckboxProps extends Omit<InputHTMLAttributes<HTMLInputElement
26
28
  /** **(Optional)** Specify the Checkbox size. */
27
29
  size?: StandardSizes;
28
30
  }
29
- export declare const Checkbox: ({ className, error, hint, id, label, labelVisible, name, size, ...props }: CheckboxProps) => JSX.Element;
31
+ export declare const Checkbox: ({ className, disabled, error, hint, id, label, labelVisible, name, size, ...props }: CheckboxProps) => JSX.Element;
30
32
  export default Checkbox;
@@ -5,19 +5,21 @@ import { FieldError } from '../FieldError/FieldError.js';
5
5
  import { FieldHint } from '../FieldHint/FieldHint.js';
6
6
  import { FieldLabel } from '../FieldLabel/FieldLabel.js';
7
7
 
8
- const Checkbox = ({ className, error = false, hint, id, label, labelVisible = true, name, size = "md", ...props }) => {
8
+ const Checkbox = ({ className, disabled, error = false, hint, id, label, labelVisible = true, name, size = "md", ...props }) => {
9
9
  const internalId = useId();
10
10
  id = id !== null && id !== void 0 ? id : internalId;
11
11
  const componentProps = {
12
12
  className: clsx("coop-checkbox", className),
13
13
  "data-error": error ? "" : undefined,
14
14
  "data-size": size.length && size !== "md" ? size : undefined,
15
+ disabled,
15
16
  id,
16
17
  name,
17
18
  type: "checkbox",
18
19
  ...props,
19
20
  };
20
- return (jsxs("div", { className: "coop-form-item", children: [jsxs("div", { className: "coop-checkbox-wrapper", children: [jsx("input", { ...componentProps }), label && (jsx(FieldLabel, { htmlFor: id, isVisible: labelVisible, children: label })), hint && jsx(FieldHint, { children: hint })] }), typeof error === "object" && (error === null || error === void 0 ? void 0 : error.message) && jsx(FieldError, { children: error.message })] }));
21
+ const formItemProps = { "aria-disabled": disabled ? true : undefined };
22
+ return (jsxs("div", { className: "coop-form-item", ...formItemProps, children: [jsxs("div", { className: "coop-checkbox-wrapper", children: [jsx("input", { ...componentProps }), label && (jsx(FieldLabel, { htmlFor: id, isVisible: labelVisible, children: label })), hint && jsx(FieldHint, { children: hint })] }), typeof error === "object" && (error === null || error === void 0 ? void 0 : error.message) && jsx(FieldError, { children: error.message })] }));
21
23
  };
22
24
 
23
25
  export { Checkbox, Checkbox as default };
@@ -5,6 +5,8 @@ export interface CheckboxGroupProps extends FieldsetHTMLAttributes<HTMLFieldSetE
5
5
  children?: React.ReactNode;
6
6
  /** **(Optional)** Specify additional CSS classes to be applied to the component. */
7
7
  className?: string;
8
+ /** **(Optional)** Specify whether the CheckboxGroup, and all of its descendents, should be disabled. Refer to Experience Library guidance on disabled form controls and accessibility. */
9
+ disabled?: boolean;
8
10
  /** **(Optional)** Specify the CheckboxGroup error state.
9
11
  *
10
12
  * This is an instance of `FormFieldError`. You can provide either an object with a `message` key, or a boolean value if you need to render the message independently.
@@ -4,6 +4,8 @@ import { TagProps } from "../Tag";
4
4
  export interface RadioButtonProps extends Omit<InputHTMLAttributes<HTMLInputElement>, "size" | "type"> {
5
5
  /** **(Optional)** Specify additional CSS classes to be applied to the component. */
6
6
  className?: string;
7
+ /** **(Optional)** Specify whether the RadioButton should be disabled. Refer to Experience Library guidance on disabled form controls and accessibility. */
8
+ disabled?: boolean;
7
9
  /** **(Optional)** Specify the RadioButton error state.
8
10
  *
9
11
  * This is an instance of `FormFieldError`. You can provide either an object with a `message` key, or a boolean value if you need to render the message independently.
@@ -33,5 +35,5 @@ export interface RadioButtonProps extends Omit<InputHTMLAttributes<HTMLInputElem
33
35
  /** **(Optional)** Specify the RadioButton variant. */
34
36
  variant?: "default" | "boxed";
35
37
  }
36
- export declare const RadioButton: ({ className, error, hint, id, label, labelVisible, name, size, tag, tagBackground, variant, ...props }: RadioButtonProps) => JSX.Element;
38
+ export declare const RadioButton: ({ className, disabled, error, hint, id, label, labelVisible, name, size, tag, tagBackground, variant, ...props }: RadioButtonProps) => JSX.Element;
37
39
  export default RadioButton;
@@ -6,7 +6,7 @@ import { FieldHint } from '../FieldHint/FieldHint.js';
6
6
  import { FieldLabel } from '../FieldLabel/FieldLabel.js';
7
7
  import { Tag } from '../Tag/Tag.js';
8
8
 
9
- const RadioButton = ({ className, error = false, hint, id, label, labelVisible = true, name, size = "md", tag, tagBackground, variant = "default", ...props }) => {
9
+ const RadioButton = ({ className, disabled, error = false, hint, id, label, labelVisible = true, name, size = "md", tag, tagBackground, variant = "default", ...props }) => {
10
10
  const internalId = useId();
11
11
  id = id !== null && id !== void 0 ? id : internalId;
12
12
  const componentProps = {
@@ -14,12 +14,14 @@ const RadioButton = ({ className, error = false, hint, id, label, labelVisible =
14
14
  "data-error": error ? "" : undefined,
15
15
  "data-size": size.length && size !== "md" ? size : undefined,
16
16
  "data-variant": variant !== "default" ? variant : undefined,
17
+ disabled,
17
18
  id,
18
19
  name,
19
20
  type: "radio",
20
21
  ...props,
21
22
  };
22
- return (jsxs("div", { className: "coop-form-item", children: [jsxs("div", { className: "coop-radio-button-wrapper", children: [jsx("input", { ...componentProps }), label && (jsxs(FieldLabel, { htmlFor: id, isVisible: labelVisible, children: [jsx("span", { children: label }), " ", tag && (jsx(Tag, { background: tagBackground, size: "sm", children: tag }))] })), hint && jsx(FieldHint, { children: hint })] }), typeof error === "object" && (error === null || error === void 0 ? void 0 : error.message) && jsx(FieldError, { children: error.message })] }));
23
+ const formItemProps = { "aria-disabled": disabled ? true : undefined };
24
+ return (jsxs("div", { className: "coop-form-item", ...formItemProps, children: [jsxs("div", { className: "coop-radio-button-wrapper", children: [jsx("input", { ...componentProps }), label && (jsxs(FieldLabel, { htmlFor: id, isVisible: labelVisible, children: [jsx("span", { children: label }), " ", tag && (jsx(Tag, { background: tagBackground, size: "sm", children: tag }))] })), hint && jsx(FieldHint, { children: hint })] }), typeof error === "object" && (error === null || error === void 0 ? void 0 : error.message) && jsx(FieldError, { children: error.message })] }));
23
25
  };
24
26
 
25
27
  export { RadioButton, RadioButton as default };
@@ -5,6 +5,8 @@ export interface RadioButtonGroupProps extends FieldsetHTMLAttributes<HTMLFieldS
5
5
  children?: React.ReactNode;
6
6
  /** **(Optional)** Specify additional CSS classes to be applied to the component. */
7
7
  className?: string;
8
+ /** **(Optional)** Specify whether the RadioButtonGroup, and all of its descendents, should be disabled. Refer to Experience Library guidance on disabled form controls and accessibility. */
9
+ disabled?: boolean;
8
10
  /** **(Optional)** Specify the RadioButtonGroup error state.
9
11
  *
10
12
  * This is an instance of `FormFieldError`. You can provide either an object with a `message` key, or a boolean value if you need to render the message independently.
@@ -3,6 +3,8 @@ import { FormFieldError, StandardSizes } from "../../../src/types";
3
3
  export interface TextInputProps extends Omit<InputHTMLAttributes<HTMLInputElement>, "size" | "type"> {
4
4
  /** **(Optional)** Specify additional CSS classes to be applied to the component. */
5
5
  className?: string;
6
+ /** **(Optional)** Specify whether the TextInput should be disabled. Refer to Experience Library guidance on disabled form controls and accessibility. */
7
+ disabled?: boolean;
6
8
  /** **(Optional)** Specify the TextInput error state.
7
9
  *
8
10
  * This is an instance of `FormFieldError`. You can provide either an object with a `message` key, or a boolean value if you need to render the message independently.
@@ -34,5 +36,5 @@ export interface TextInputProps extends Omit<InputHTMLAttributes<HTMLInputElemen
34
36
  /** **(Optional)** Specify the TextInput type. */
35
37
  type?: "text" | "email" | "number" | "password" | "search" | "tel" | "url";
36
38
  }
37
- export declare const TextInput: ({ "aria-placeholder": ariaPlaceholder, className, error, hint, id, label, labelVisible, name, placeholder, prefix, size, suffix, type, ...props }: TextInputProps) => JSX.Element;
39
+ export declare const TextInput: ({ "aria-placeholder": ariaPlaceholder, className, disabled, error, hint, id, label, labelVisible, name, placeholder, prefix, size, suffix, type, ...props }: TextInputProps) => JSX.Element;
38
40
  export default TextInput;
@@ -5,7 +5,7 @@ import { FieldError } from '../FieldError/FieldError.js';
5
5
  import { FieldHint } from '../FieldHint/FieldHint.js';
6
6
  import { FieldLabel } from '../FieldLabel/FieldLabel.js';
7
7
 
8
- const TextInput = ({ "aria-placeholder": ariaPlaceholder, className, error = false, hint, id, label, labelVisible = true, name, placeholder, prefix, size = "md", suffix, type = "text", ...props }) => {
8
+ const TextInput = ({ "aria-placeholder": ariaPlaceholder, className, disabled, error = false, hint, id, label, labelVisible = true, name, placeholder, prefix, size = "md", suffix, type = "text", ...props }) => {
9
9
  var _a;
10
10
  const internalId = useId();
11
11
  id = id !== null && id !== void 0 ? id : internalId;
@@ -14,13 +14,15 @@ const TextInput = ({ "aria-placeholder": ariaPlaceholder, className, error = fal
14
14
  className: clsx("coop-text-input", className),
15
15
  "data-error": error ? "" : undefined,
16
16
  "data-size": size.length && size !== "md" ? size : undefined,
17
+ disabled,
17
18
  id,
18
19
  name,
19
20
  placeholder,
20
21
  type,
21
22
  ...props,
22
23
  };
23
- return (jsxs("div", { className: "coop-form-item", children: [label && (jsx(FieldLabel, { htmlFor: id, isVisible: labelVisible, children: label })), hint && jsx(FieldHint, { children: hint }), typeof error === "object" && (error === null || error === void 0 ? void 0 : error.message) && jsx(FieldError, { children: error.message }), jsxs("div", { className: "coop-text-input-wrapper", children: [prefix && jsx("span", { className: "coop-text-input--prefix", children: prefix }), jsx("input", { ...componentProps }), suffix && jsx("span", { className: "coop-text-input--suffix", children: suffix })] })] }));
24
+ const formItemProps = { "aria-disabled": disabled ? true : undefined };
25
+ return (jsxs("div", { className: "coop-form-item", ...formItemProps, children: [label && (jsx(FieldLabel, { htmlFor: id, isVisible: labelVisible, children: label })), hint && jsx(FieldHint, { children: hint }), typeof error === "object" && (error === null || error === void 0 ? void 0 : error.message) && jsx(FieldError, { children: error.message }), jsxs("div", { className: "coop-text-input-wrapper", children: [prefix && jsx("span", { className: "coop-text-input--prefix", children: prefix }), jsx("input", { ...componentProps }), suffix && jsx("span", { className: "coop-text-input--suffix", children: suffix })] })] }));
24
26
  };
25
27
 
26
28
  export { TextInput, TextInput as default };
@@ -14,6 +14,8 @@ export interface TextareaProps extends TextareaHTMLAttributes<HTMLTextAreaElemen
14
14
  * Remember it is still your responsibility to handle validation on submission, this is simply a hint for the user.
15
15
  */
16
16
  cutoff?: boolean;
17
+ /** **(Optional)** Specify whether the Textarea should be disabled. Refer to Experience Library guidance on disabled form controls and accessibility. */
18
+ disabled?: boolean;
17
19
  /** **(Optional)** Specify the Textarea error state.
18
20
  *
19
21
  * This is an instance of `FormFieldError`. You can provide either an object with a `message` key, or a boolean value if you need to render the message independently.
@@ -43,5 +45,5 @@ export interface TextareaProps extends TextareaHTMLAttributes<HTMLTextAreaElemen
43
45
  /** **(Optional)** Specify the Textarea size. */
44
46
  size?: StandardSizes;
45
47
  }
46
- export declare const Textarea: ({ "aria-placeholder": ariaPlaceholder, className, cols, counter, cutoff, error, hint, id, label, labelVisible, maxLength, name, onChange: userOnChange, placeholder, rows, size, ...props }: TextareaProps) => JSX.Element;
48
+ export declare const Textarea: ({ "aria-placeholder": ariaPlaceholder, className, cols, counter, cutoff, disabled, error, hint, id, label, labelVisible, maxLength, name, onChange: userOnChange, placeholder, rows, size, ...props }: TextareaProps) => JSX.Element;
47
49
  export default Textarea;
@@ -10,7 +10,7 @@ const DEBOUNCE_DELAY = 750;
10
10
  const charCountMessage = (remaining) => {
11
11
  return `You have ${Math.abs(remaining).toLocaleString()} ${Math.abs(remaining) === 1 ? "character" : "characters"} ${remaining < 0 ? "too many" : "remaining"}`;
12
12
  };
13
- const Textarea = ({ "aria-placeholder": ariaPlaceholder, className, cols = 30, counter = false, cutoff = false, error = false, hint, id, label, labelVisible = true, maxLength, name, onChange: userOnChange = undefined, placeholder, rows = 4, size = "md", ...props }) => {
13
+ const Textarea = ({ "aria-placeholder": ariaPlaceholder, className, cols = 30, counter = false, cutoff = false, disabled = false, error = false, hint, id, label, labelVisible = true, maxLength, name, onChange: userOnChange = undefined, placeholder, rows = 4, size = "md", ...props }) => {
14
14
  var _a;
15
15
  const internalId = useId();
16
16
  id = id !== null && id !== void 0 ? id : internalId;
@@ -20,6 +20,7 @@ const Textarea = ({ "aria-placeholder": ariaPlaceholder, className, cols = 30, c
20
20
  cols,
21
21
  "data-error": error ? "" : undefined,
22
22
  "data-size": size.length && size !== "md" ? size : undefined,
23
+ disabled,
23
24
  id,
24
25
  maxLength: cutoff ? maxLength : undefined,
25
26
  name,
@@ -32,10 +33,11 @@ const Textarea = ({ "aria-placeholder": ariaPlaceholder, className, cols = 30, c
32
33
  const handleChange = (e) => {
33
34
  maxLength && e.target && setRemaining(maxLength - e.target.value.length);
34
35
  };
35
- return (jsxs("div", { className: "coop-form-item", children: [label && (jsx(FieldLabel, { htmlFor: id, isVisible: labelVisible, children: label })), hint && jsx(FieldHint, { children: hint }), typeof error === "object" && (error === null || error === void 0 ? void 0 : error.message) && jsx(FieldError, { children: error.message }), jsx("textarea", { ...componentProps, onChange: (e) => {
36
+ const formItemProps = { "aria-disabled": disabled ? true : undefined };
37
+ return (jsxs("div", { className: "coop-form-item", ...formItemProps, children: [label && (jsx(FieldLabel, { htmlFor: id, isVisible: labelVisible, children: label })), hint && jsx(FieldHint, { children: hint }), typeof error === "object" && (error === null || error === void 0 ? void 0 : error.message) && jsx(FieldError, { children: error.message }), jsx("textarea", { ...componentProps, onChange: (e) => {
36
38
  userOnChange === null || userOnChange === void 0 ? void 0 : userOnChange(e);
37
39
  handleChange(e);
38
- } }), counter && maxLength && remaining != null && debouncedRemaining != null && (jsxs(Fragment, { children: [jsx("small", { "aria-hidden": "true", className: "coop-textarea-counter", ...(remaining < 0 && { "data-error": "" }), children: charCountMessage(remaining) }), jsx("span", { "aria-live": "polite", className: "sr-only", children: charCountMessage(debouncedRemaining) })] }))] }));
40
+ } }), !disabled && counter && maxLength && remaining != null && debouncedRemaining != null && (jsxs(Fragment, { children: [jsx("small", { "aria-hidden": "true", className: "coop-textarea-counter", ...(remaining < 0 && { "data-error": "" }), children: charCountMessage(remaining) }), jsx("span", { "aria-live": "polite", className: "sr-only", children: charCountMessage(debouncedRemaining) })] }))] }));
39
41
  };
40
42
 
41
43
  export { Textarea, Textarea as default };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@coopdigital/react",
3
3
  "type": "module",
4
- "version": "0.37.0",
4
+ "version": "0.38.0",
5
5
  "private": false,
6
6
  "publishConfig": {
7
7
  "access": "public"
@@ -80,7 +80,7 @@
80
80
  "storybook": "$storybook"
81
81
  },
82
82
  "dependencies": {
83
- "@coopdigital/styles": "^0.32.0"
83
+ "@coopdigital/styles": "^0.33.0"
84
84
  },
85
- "gitHead": "07c3e26f63d0b276cd48f392ec61241f7db7fe84"
85
+ "gitHead": "a944468d589dbae7fda45baab60dc9eac0c83032"
86
86
  }
@@ -12,6 +12,8 @@ export interface CheckboxProps
12
12
  extends Omit<InputHTMLAttributes<HTMLInputElement>, "size" | "type"> {
13
13
  /** **(Optional)** Specify additional CSS classes to be applied to the component. */
14
14
  className?: string
15
+ /** **(Optional)** Specify whether the Checkbox should be disabled. Refer to Experience Library guidance on disabled form controls and accessibility. */
16
+ disabled?: boolean
15
17
  /** **(Optional)** Specify the Checkbox error state.
16
18
  *
17
19
  * This is an instance of `FormFieldError`. You can provide either an object with a `message` key, or a boolean value if you need to render the message independently.
@@ -38,6 +40,7 @@ export interface CheckboxProps
38
40
 
39
41
  export const Checkbox = ({
40
42
  className,
43
+ disabled,
41
44
  error = false,
42
45
  hint,
43
46
  id,
@@ -55,14 +58,15 @@ export const Checkbox = ({
55
58
  className: clsx("coop-checkbox", className),
56
59
  "data-error": error ? "" : undefined,
57
60
  "data-size": size.length && size !== "md" ? size : undefined,
61
+ disabled,
58
62
  id,
59
63
  name,
60
64
  type: "checkbox",
61
65
  ...props,
62
66
  }
63
-
67
+ const formItemProps = { "aria-disabled": disabled ? true : undefined }
64
68
  return (
65
- <div className="coop-form-item">
69
+ <div className="coop-form-item" {...formItemProps}>
66
70
  <div className="coop-checkbox-wrapper">
67
71
  <input {...componentProps} />
68
72
 
@@ -11,6 +11,8 @@ export interface CheckboxGroupProps extends FieldsetHTMLAttributes<HTMLFieldSetE
11
11
  children?: React.ReactNode
12
12
  /** **(Optional)** Specify additional CSS classes to be applied to the component. */
13
13
  className?: string
14
+ /** **(Optional)** Specify whether the CheckboxGroup, and all of its descendents, should be disabled. Refer to Experience Library guidance on disabled form controls and accessibility. */
15
+ disabled?: boolean
14
16
  /** **(Optional)** Specify the CheckboxGroup error state.
15
17
  *
16
18
  * This is an instance of `FormFieldError`. You can provide either an object with a `message` key, or a boolean value if you need to render the message independently.
@@ -11,6 +11,8 @@ export interface RadioButtonProps
11
11
  extends Omit<InputHTMLAttributes<HTMLInputElement>, "size" | "type"> {
12
12
  /** **(Optional)** Specify additional CSS classes to be applied to the component. */
13
13
  className?: string
14
+ /** **(Optional)** Specify whether the RadioButton should be disabled. Refer to Experience Library guidance on disabled form controls and accessibility. */
15
+ disabled?: boolean
14
16
  /** **(Optional)** Specify the RadioButton error state.
15
17
  *
16
18
  * This is an instance of `FormFieldError`. You can provide either an object with a `message` key, or a boolean value if you need to render the message independently.
@@ -43,6 +45,7 @@ export interface RadioButtonProps
43
45
 
44
46
  export const RadioButton = ({
45
47
  className,
48
+ disabled,
46
49
  error = false,
47
50
  hint,
48
51
  id,
@@ -64,14 +67,15 @@ export const RadioButton = ({
64
67
  "data-error": error ? "" : undefined,
65
68
  "data-size": size.length && size !== "md" ? size : undefined,
66
69
  "data-variant": variant !== "default" ? variant : undefined,
70
+ disabled,
67
71
  id,
68
72
  name,
69
73
  type: "radio",
70
74
  ...props,
71
75
  }
72
-
76
+ const formItemProps = { "aria-disabled": disabled ? true : undefined }
73
77
  return (
74
- <div className="coop-form-item">
78
+ <div className="coop-form-item" {...formItemProps}>
75
79
  <div className="coop-radio-button-wrapper">
76
80
  <input {...componentProps} />
77
81
 
@@ -11,6 +11,8 @@ export interface RadioButtonGroupProps extends FieldsetHTMLAttributes<HTMLFieldS
11
11
  children?: React.ReactNode
12
12
  /** **(Optional)** Specify additional CSS classes to be applied to the component. */
13
13
  className?: string
14
+ /** **(Optional)** Specify whether the RadioButtonGroup, and all of its descendents, should be disabled. Refer to Experience Library guidance on disabled form controls and accessibility. */
15
+ disabled?: boolean
14
16
  /** **(Optional)** Specify the RadioButtonGroup error state.
15
17
  *
16
18
  * This is an instance of `FormFieldError`. You can provide either an object with a `message` key, or a boolean value if you need to render the message independently.
@@ -12,6 +12,8 @@ export interface TextInputProps
12
12
  extends Omit<InputHTMLAttributes<HTMLInputElement>, "size" | "type"> {
13
13
  /** **(Optional)** Specify additional CSS classes to be applied to the component. */
14
14
  className?: string
15
+ /** **(Optional)** Specify whether the TextInput should be disabled. Refer to Experience Library guidance on disabled form controls and accessibility. */
16
+ disabled?: boolean
15
17
  /** **(Optional)** Specify the TextInput error state.
16
18
  *
17
19
  * This is an instance of `FormFieldError`. You can provide either an object with a `message` key, or a boolean value if you need to render the message independently.
@@ -47,6 +49,7 @@ export interface TextInputProps
47
49
  export const TextInput = ({
48
50
  "aria-placeholder": ariaPlaceholder,
49
51
  className,
52
+ disabled,
50
53
  error = false,
51
54
  hint,
52
55
  id,
@@ -69,15 +72,16 @@ export const TextInput = ({
69
72
  className: clsx("coop-text-input", className),
70
73
  "data-error": error ? "" : undefined,
71
74
  "data-size": size.length && size !== "md" ? size : undefined,
75
+ disabled,
72
76
  id,
73
77
  name,
74
78
  placeholder,
75
79
  type,
76
80
  ...props,
77
81
  }
78
-
82
+ const formItemProps = { "aria-disabled": disabled ? true : undefined }
79
83
  return (
80
- <div className="coop-form-item">
84
+ <div className="coop-form-item" {...formItemProps}>
81
85
  {label && (
82
86
  <FieldLabel htmlFor={id} isVisible={labelVisible}>
83
87
  {label}
@@ -29,6 +29,8 @@ export interface TextareaProps extends TextareaHTMLAttributes<HTMLTextAreaElemen
29
29
  * Remember it is still your responsibility to handle validation on submission, this is simply a hint for the user.
30
30
  */
31
31
  cutoff?: boolean
32
+ /** **(Optional)** Specify whether the Textarea should be disabled. Refer to Experience Library guidance on disabled form controls and accessibility. */
33
+ disabled?: boolean
32
34
  /** **(Optional)** Specify the Textarea error state.
33
35
  *
34
36
  * This is an instance of `FormFieldError`. You can provide either an object with a `message` key, or a boolean value if you need to render the message independently.
@@ -65,6 +67,7 @@ export const Textarea = ({
65
67
  cols = 30,
66
68
  counter = false,
67
69
  cutoff = false,
70
+ disabled = false,
68
71
  error = false,
69
72
  hint,
70
73
  id,
@@ -88,6 +91,7 @@ export const Textarea = ({
88
91
  cols,
89
92
  "data-error": error ? "" : undefined,
90
93
  "data-size": size.length && size !== "md" ? size : undefined,
94
+ disabled,
91
95
  id,
92
96
  maxLength: cutoff ? maxLength : undefined,
93
97
  name,
@@ -102,9 +106,9 @@ export const Textarea = ({
102
106
  const handleChange = (e: ChangeEvent<HTMLTextAreaElement>) => {
103
107
  maxLength && e.target && setRemaining(maxLength - e.target.value.length)
104
108
  }
105
-
109
+ const formItemProps = { "aria-disabled": disabled ? true : undefined }
106
110
  return (
107
- <div className="coop-form-item">
111
+ <div className="coop-form-item" {...formItemProps}>
108
112
  {label && (
109
113
  <FieldLabel htmlFor={id} isVisible={labelVisible}>
110
114
  {label}
@@ -123,7 +127,7 @@ export const Textarea = ({
123
127
  }}
124
128
  ></textarea>
125
129
 
126
- {counter && maxLength && remaining != null && debouncedRemaining != null && (
130
+ {!disabled && counter && maxLength && remaining != null && debouncedRemaining != null && (
127
131
  <>
128
132
  <small
129
133
  aria-hidden="true"