@coopdigital/react 0.46.0 → 0.47.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/dist/components/AlertBanner/AlertBanner.d.ts +4 -2
- package/dist/components/AlertBanner/AlertBanner.js +2 -2
- package/dist/components/Author/Author.d.ts +4 -2
- package/dist/components/Author/Author.js +2 -2
- package/dist/components/Button/Button.d.ts +1 -1
- package/dist/components/Button/Button.js +1 -2
- package/dist/components/Card/Card.d.ts +4 -2
- package/dist/components/Card/Card.js +2 -2
- package/dist/components/Checkbox/Checkbox.d.ts +4 -2
- package/dist/components/Checkbox/Checkbox.js +2 -2
- package/dist/components/Expandable/Expandable.d.ts +4 -2
- package/dist/components/Expandable/Expandable.js +2 -2
- package/dist/components/Field/Field.d.ts +4 -2
- package/dist/components/Field/Field.js +3 -4
- package/dist/components/FieldMarkers/Error.d.ts +4 -2
- package/dist/components/FieldMarkers/Error.js +2 -2
- package/dist/components/FieldMarkers/Hint.d.ts +5 -3
- package/dist/components/FieldMarkers/Hint.js +2 -2
- package/dist/components/FieldMarkers/Label.d.ts +4 -2
- package/dist/components/FieldMarkers/Label.js +6 -2
- package/dist/components/FieldMarkers/Legend.d.ts +4 -2
- package/dist/components/FieldMarkers/Legend.js +2 -2
- package/dist/components/Fieldset/Fieldset.d.ts +4 -2
- package/dist/components/Fieldset/Fieldset.js +2 -4
- package/dist/components/Flourish/Flourish.d.ts +4 -2
- package/dist/components/Flourish/Flourish.js +2 -2
- package/dist/components/Icon/AddIcon.d.ts +1 -1
- package/dist/components/Icon/AddIcon.js +6 -5
- package/dist/components/Icon/ArrowDownIcon.d.ts +1 -1
- package/dist/components/Icon/ArrowDownIcon.js +6 -5
- package/dist/components/Icon/ArrowLeftIcon.d.ts +1 -1
- package/dist/components/Icon/ArrowLeftIcon.js +6 -5
- package/dist/components/Icon/ArrowRightIcon.d.ts +1 -1
- package/dist/components/Icon/ArrowRightIcon.js +6 -5
- package/dist/components/Icon/ArrowUpIcon.d.ts +1 -1
- package/dist/components/Icon/ArrowUpIcon.js +6 -5
- package/dist/components/Icon/AvatarAltIcon.d.ts +1 -1
- package/dist/components/Icon/AvatarAltIcon.js +6 -5
- package/dist/components/Icon/AvatarIcon.d.ts +1 -1
- package/dist/components/Icon/AvatarIcon.js +6 -5
- package/dist/components/Icon/BasketIcon.d.ts +1 -1
- package/dist/components/Icon/BasketIcon.js +6 -5
- package/dist/components/Icon/CalendarIcon.d.ts +1 -1
- package/dist/components/Icon/CalendarIcon.js +6 -5
- package/dist/components/Icon/ChevronDownIcon.d.ts +1 -1
- package/dist/components/Icon/ChevronDownIcon.js +6 -5
- package/dist/components/Icon/ChevronLeftIcon.d.ts +1 -1
- package/dist/components/Icon/ChevronLeftIcon.js +6 -5
- package/dist/components/Icon/ChevronRightIcon.d.ts +1 -1
- package/dist/components/Icon/ChevronRightIcon.js +6 -5
- package/dist/components/Icon/ChevronUpIcon.d.ts +1 -1
- package/dist/components/Icon/ChevronUpIcon.js +6 -5
- package/dist/components/Icon/ClockIcon.d.ts +1 -1
- package/dist/components/Icon/ClockIcon.js +6 -5
- package/dist/components/Icon/CloseAltIcon.d.ts +1 -1
- package/dist/components/Icon/CloseAltIcon.js +6 -5
- package/dist/components/Icon/CloseIcon.d.ts +1 -1
- package/dist/components/Icon/CloseIcon.js +6 -5
- package/dist/components/Icon/CoopCardIcon.d.ts +1 -1
- package/dist/components/Icon/CoopCardIcon.js +6 -5
- package/dist/components/Icon/CoopIcon.d.ts +1 -1
- package/dist/components/Icon/CoopIcon.js +6 -5
- package/dist/components/Icon/CoopLocationIcon.d.ts +1 -1
- package/dist/components/Icon/CoopLocationIcon.js +6 -5
- package/dist/components/Icon/DownloadIcon.d.ts +1 -1
- package/dist/components/Icon/DownloadIcon.js +6 -5
- package/dist/components/Icon/HomeIcon.d.ts +1 -1
- package/dist/components/Icon/HomeIcon.js +6 -5
- package/dist/components/Icon/InformationIcon.d.ts +1 -1
- package/dist/components/Icon/InformationIcon.js +6 -5
- package/dist/components/Icon/LoadingIcon.d.ts +1 -1
- package/dist/components/Icon/LoadingIcon.js +6 -5
- package/dist/components/Icon/LocationIcon.d.ts +1 -1
- package/dist/components/Icon/LocationIcon.js +6 -5
- package/dist/components/Icon/MailIcon.d.ts +1 -1
- package/dist/components/Icon/MailIcon.js +6 -5
- package/dist/components/Icon/MenuIcon.d.ts +1 -1
- package/dist/components/Icon/MenuIcon.js +6 -5
- package/dist/components/Icon/MessageIcon.d.ts +1 -1
- package/dist/components/Icon/MessageIcon.js +6 -5
- package/dist/components/Icon/MinusIcon.d.ts +1 -1
- package/dist/components/Icon/MinusIcon.js +6 -5
- package/dist/components/Icon/OpenNewIcon.d.ts +1 -1
- package/dist/components/Icon/OpenNewIcon.js +6 -5
- package/dist/components/Icon/PencilIcon.d.ts +1 -1
- package/dist/components/Icon/PencilIcon.js +6 -5
- package/dist/components/Icon/PhoneIcon.d.ts +1 -1
- package/dist/components/Icon/PhoneIcon.js +6 -5
- package/dist/components/Icon/QuestionIcon.d.ts +1 -1
- package/dist/components/Icon/QuestionIcon.js +6 -5
- package/dist/components/Icon/ScooterIcon.d.ts +1 -1
- package/dist/components/Icon/ScooterIcon.js +6 -5
- package/dist/components/Icon/SearchIcon.d.ts +1 -1
- package/dist/components/Icon/SearchIcon.js +6 -5
- package/dist/components/Icon/SettingsIcon.d.ts +1 -1
- package/dist/components/Icon/SettingsIcon.js +6 -5
- package/dist/components/Icon/TickAltIcon.d.ts +1 -1
- package/dist/components/Icon/TickAltIcon.js +6 -5
- package/dist/components/Icon/TickIcon.d.ts +1 -1
- package/dist/components/Icon/TickIcon.js +6 -5
- package/dist/components/Icon/VanIcon.d.ts +1 -1
- package/dist/components/Icon/VanIcon.js +6 -5
- package/dist/components/Icon/WarningIcon.d.ts +1 -1
- package/dist/components/Icon/WarningIcon.js +6 -5
- package/dist/components/Icon/WriteIcon.d.ts +1 -1
- package/dist/components/Icon/WriteIcon.js +6 -5
- package/dist/components/Image/Image.d.ts +4 -2
- package/dist/components/Image/Image.js +2 -2
- package/dist/components/Pill/Pill.d.ts +4 -2
- package/dist/components/Pill/Pill.js +5 -6
- package/dist/components/Radio/Radio.d.ts +5 -3
- package/dist/components/Radio/Radio.js +5 -6
- package/dist/components/Searchbox/Searchbox.d.ts +4 -2
- package/dist/components/Searchbox/Searchbox.js +14 -9
- package/dist/components/Signpost/Signpost.d.ts +6 -4
- package/dist/components/Signpost/Signpost.js +3 -6
- package/dist/components/SkipNav/SkipNav.d.ts +4 -2
- package/dist/components/SkipNav/SkipNav.js +2 -2
- package/dist/components/Squircle/Squircle.d.ts +4 -2
- package/dist/components/Squircle/Squircle.js +2 -2
- package/dist/components/Tag/Tag.d.ts +5 -3
- package/dist/components/Tag/Tag.js +3 -6
- package/dist/components/TextInput/TextInput.d.ts +4 -2
- package/dist/components/TextInput/TextInput.js +2 -2
- package/dist/components/Textarea/Textarea.d.ts +4 -2
- package/dist/components/Textarea/Textarea.js +4 -5
- package/package.json +2 -2
- package/src/components/AlertBanner/AlertBanner.tsx +6 -2
- package/src/components/Author/Author.tsx +5 -2
- package/src/components/Button/Button.tsx +2 -3
- package/src/components/Card/Card.tsx +5 -2
- package/src/components/Checkbox/Checkbox.tsx +6 -2
- package/src/components/Expandable/Expandable.tsx +10 -3
- package/src/components/Field/Field.tsx +6 -5
- package/src/components/FieldMarkers/Error.tsx +9 -3
- package/src/components/FieldMarkers/Hint.tsx +10 -4
- package/src/components/FieldMarkers/Label.tsx +9 -3
- package/src/components/FieldMarkers/Legend.tsx +9 -3
- package/src/components/Fieldset/Fieldset.tsx +9 -4
- package/src/components/Flourish/Flourish.tsx +5 -2
- package/src/components/Icon/AddIcon.tsx +9 -6
- package/src/components/Icon/ArrowDownIcon.tsx +9 -6
- package/src/components/Icon/ArrowLeftIcon.tsx +9 -6
- package/src/components/Icon/ArrowRightIcon.tsx +9 -6
- package/src/components/Icon/ArrowUpIcon.tsx +9 -6
- package/src/components/Icon/AvatarAltIcon.tsx +9 -6
- package/src/components/Icon/AvatarIcon.tsx +9 -6
- package/src/components/Icon/BasketIcon.tsx +9 -6
- package/src/components/Icon/CalendarIcon.tsx +9 -6
- package/src/components/Icon/ChevronDownIcon.tsx +9 -6
- package/src/components/Icon/ChevronLeftIcon.tsx +9 -6
- package/src/components/Icon/ChevronRightIcon.tsx +9 -6
- package/src/components/Icon/ChevronUpIcon.tsx +9 -6
- package/src/components/Icon/ClockIcon.tsx +9 -6
- package/src/components/Icon/CloseAltIcon.tsx +9 -6
- package/src/components/Icon/CloseIcon.tsx +9 -6
- package/src/components/Icon/CoopCardIcon.tsx +9 -6
- package/src/components/Icon/CoopIcon.tsx +9 -6
- package/src/components/Icon/CoopLocationIcon.tsx +9 -6
- package/src/components/Icon/DownloadIcon.tsx +9 -6
- package/src/components/Icon/HomeIcon.tsx +9 -6
- package/src/components/Icon/InformationIcon.tsx +9 -6
- package/src/components/Icon/LoadingIcon.tsx +9 -6
- package/src/components/Icon/LocationIcon.tsx +9 -6
- package/src/components/Icon/MailIcon.tsx +9 -6
- package/src/components/Icon/MenuIcon.tsx +9 -6
- package/src/components/Icon/MessageIcon.tsx +9 -6
- package/src/components/Icon/MinusIcon.tsx +9 -6
- package/src/components/Icon/OpenNewIcon.tsx +9 -6
- package/src/components/Icon/PencilIcon.tsx +9 -6
- package/src/components/Icon/PhoneIcon.tsx +9 -6
- package/src/components/Icon/QuestionIcon.tsx +9 -6
- package/src/components/Icon/ScooterIcon.tsx +9 -6
- package/src/components/Icon/SearchIcon.tsx +9 -6
- package/src/components/Icon/SettingsIcon.tsx +9 -6
- package/src/components/Icon/TickAltIcon.tsx +9 -6
- package/src/components/Icon/TickIcon.tsx +9 -6
- package/src/components/Icon/VanIcon.tsx +9 -6
- package/src/components/Icon/WarningIcon.tsx +9 -6
- package/src/components/Icon/WriteIcon.tsx +9 -6
- package/src/components/Image/Image.tsx +5 -2
- package/src/components/Pill/Pill.tsx +8 -7
- package/src/components/Radio/Radio.tsx +10 -7
- package/src/components/Searchbox/Searchbox.tsx +22 -19
- package/src/components/Signpost/Signpost.tsx +8 -8
- package/src/components/SkipNav/SkipNav.tsx +5 -2
- package/src/components/Squircle/Squircle.tsx +5 -2
- package/src/components/Tag/Tag.tsx +9 -8
- package/src/components/TextInput/TextInput.tsx +5 -2
- package/src/components/Textarea/Textarea.tsx +8 -6
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { JSX, TextareaHTMLAttributes } from "react";
|
|
1
|
+
import type { JSX, Ref, TextareaHTMLAttributes } from "react";
|
|
2
2
|
import { StandardSizes } from "../../types";
|
|
3
3
|
export interface TextareaProps extends TextareaHTMLAttributes<HTMLTextAreaElement> {
|
|
4
4
|
/** **(Optional)** Specify additional CSS classes to be applied to the component. */
|
|
@@ -26,10 +26,12 @@ export interface TextareaProps extends TextareaHTMLAttributes<HTMLTextAreaElemen
|
|
|
26
26
|
name: string;
|
|
27
27
|
/** **(Optional)** Specify the Textarea placeholder text. Do not use in place of a form label. */
|
|
28
28
|
placeholder?: string;
|
|
29
|
+
/** **(Optional)** Specify a custom React ref for this component. */
|
|
30
|
+
ref?: Ref<HTMLTextAreaElement>;
|
|
29
31
|
/** Specify the number of rows (lines of text) in the Textarea. Defaults to `4`. */
|
|
30
32
|
rows?: number;
|
|
31
33
|
/** **(Optional)** Specify the Textarea size. */
|
|
32
34
|
size?: StandardSizes;
|
|
33
35
|
}
|
|
34
|
-
export declare const Textarea: ({ "aria-placeholder": ariaPlaceholder, className, cols, counter, cutoff, disabled, error, id, maxLength, name, onChange: userOnChange, placeholder, rows, size, ...props }: TextareaProps) => JSX.Element;
|
|
36
|
+
export declare const Textarea: ({ "aria-placeholder": ariaPlaceholder, className, cols, counter, cutoff, disabled, error, id, maxLength, name, onChange: userOnChange, placeholder, ref, rows, size, ...props }: TextareaProps) => JSX.Element;
|
|
35
37
|
export default Textarea;
|
|
@@ -8,10 +8,9 @@ const DEBOUNCE_DELAY = 750;
|
|
|
8
8
|
const charCountMessage = (remaining) => {
|
|
9
9
|
return `You have ${Math.abs(remaining).toLocaleString()} ${Math.abs(remaining) === 1 ? "character" : "characters"} ${remaining < 0 ? "too many" : "remaining"}`;
|
|
10
10
|
};
|
|
11
|
-
const Textarea = ({ "aria-placeholder": ariaPlaceholder, className, cols = 30, counter = false, cutoff = false, disabled = false, error = false, id, maxLength, name, onChange: userOnChange = undefined, placeholder, rows = 4, size = "md", ...props }) => {
|
|
11
|
+
const Textarea = ({ "aria-placeholder": ariaPlaceholder, className, cols = 30, counter = false, cutoff = false, disabled = false, error = false, id, maxLength, name, onChange: userOnChange = undefined, placeholder, ref, rows = 4, size = "md", ...props }) => {
|
|
12
12
|
var _a;
|
|
13
|
-
const
|
|
14
|
-
id = id !== null && id !== void 0 ? id : internalId;
|
|
13
|
+
const uid = useId(id);
|
|
15
14
|
const componentProps = {
|
|
16
15
|
"aria-placeholder": (_a = placeholder !== null && placeholder !== void 0 ? placeholder : ariaPlaceholder) !== null && _a !== void 0 ? _a : undefined,
|
|
17
16
|
className: clsx("coop-textarea", className),
|
|
@@ -19,7 +18,7 @@ const Textarea = ({ "aria-placeholder": ariaPlaceholder, className, cols = 30, c
|
|
|
19
18
|
"data-error": error !== null && error !== void 0 ? error : undefined,
|
|
20
19
|
"data-size": size.length && size !== "md" ? size : undefined,
|
|
21
20
|
disabled,
|
|
22
|
-
id,
|
|
21
|
+
id: uid,
|
|
23
22
|
maxLength: cutoff ? maxLength : undefined,
|
|
24
23
|
name,
|
|
25
24
|
placeholder,
|
|
@@ -36,7 +35,7 @@ const Textarea = ({ "aria-placeholder": ariaPlaceholder, className, cols = 30, c
|
|
|
36
35
|
return (jsxs("div", { className: "coop-textarea-wrapper", children: [jsx("textarea", { ...componentProps, onChange: (e) => {
|
|
37
36
|
userOnChange === null || userOnChange === void 0 ? void 0 : userOnChange(e);
|
|
38
37
|
handleChange(e);
|
|
39
|
-
} }), showCounter && (jsxs(Fragment, { children: [jsx("small", { "aria-hidden": "true", className: "coop-textarea-counter", ...(remaining < 0 && { "data-error": true }), children: charCountMessage(remaining) }), jsx("span", { "aria-live": "polite", className: "sr-only", children: charCountMessage(debouncedRemaining) })] }))] }));
|
|
38
|
+
}, ref: ref }), showCounter && (jsxs(Fragment, { children: [jsx("small", { "aria-hidden": "true", className: "coop-textarea-counter", ...(remaining < 0 && { "data-error": true }), children: charCountMessage(remaining) }), jsx("span", { "aria-live": "polite", className: "sr-only", children: charCountMessage(debouncedRemaining) })] }))] }));
|
|
40
39
|
};
|
|
41
40
|
|
|
42
41
|
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.
|
|
4
|
+
"version": "0.47.0",
|
|
5
5
|
"private": false,
|
|
6
6
|
"publishConfig": {
|
|
7
7
|
"access": "public"
|
|
@@ -81,5 +81,5 @@
|
|
|
81
81
|
"@coopdigital/styles": "^0.40.0",
|
|
82
82
|
"clsx": "^2.1.1"
|
|
83
83
|
},
|
|
84
|
-
"gitHead": "
|
|
84
|
+
"gitHead": "f28e578e8a74f005d372677975f19a707ea643ca"
|
|
85
85
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { HTMLAttributes, JSX, ReactNode } from "react"
|
|
1
|
+
import type { HTMLAttributes, JSX, ReactNode, Ref } from "react"
|
|
2
2
|
|
|
3
3
|
import clsx from "clsx"
|
|
4
4
|
|
|
@@ -9,6 +9,8 @@ export interface AlertBannerProps extends HTMLAttributes<HTMLDivElement> {
|
|
|
9
9
|
className?: string
|
|
10
10
|
/** Specify the main title of the banner, rendered as a `h2`. */
|
|
11
11
|
heading: string
|
|
12
|
+
/** **(Optional)** Specify a custom React ref for this component. */
|
|
13
|
+
ref?: Ref<HTMLDivElement>
|
|
12
14
|
/** **(Optional)** Specify the AlertBanner variant. */
|
|
13
15
|
variant?: "black" | "default"
|
|
14
16
|
}
|
|
@@ -17,6 +19,7 @@ export const AlertBanner = ({
|
|
|
17
19
|
children,
|
|
18
20
|
className,
|
|
19
21
|
heading,
|
|
22
|
+
ref,
|
|
20
23
|
variant = "default",
|
|
21
24
|
...props
|
|
22
25
|
}: AlertBannerProps): JSX.Element => {
|
|
@@ -25,8 +28,9 @@ export const AlertBanner = ({
|
|
|
25
28
|
"data-variant": variant,
|
|
26
29
|
...props,
|
|
27
30
|
}
|
|
31
|
+
|
|
28
32
|
return (
|
|
29
|
-
<aside {...componentProps}>
|
|
33
|
+
<aside {...componentProps} ref={ref}>
|
|
30
34
|
<div className="coop-alert-banner--inner">
|
|
31
35
|
<h2 id="coop-alert-banner--headline">{heading}</h2>
|
|
32
36
|
{children}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { HTMLAttributes, JSX } from "react"
|
|
1
|
+
import type { HTMLAttributes, JSX, Ref } from "react"
|
|
2
2
|
|
|
3
3
|
import clsx from "clsx"
|
|
4
4
|
|
|
@@ -15,6 +15,8 @@ export interface AuthorProps extends HTMLAttributes<HTMLDivElement> {
|
|
|
15
15
|
datePrefix?: string
|
|
16
16
|
/** **(Optional)** Specify properties of the Author Image. */
|
|
17
17
|
image?: ImageProps
|
|
18
|
+
/** **(Optional)** Specify a custom React ref for this component. */
|
|
19
|
+
ref?: Ref<HTMLDivElement>
|
|
18
20
|
}
|
|
19
21
|
|
|
20
22
|
export const Author = ({
|
|
@@ -26,6 +28,7 @@ export const Author = ({
|
|
|
26
28
|
alt: "",
|
|
27
29
|
src: "https://s3.eu-west-1.amazonaws.com/assets.digital.coop.co.uk/oneweb/coop-logo-inverted.svg",
|
|
28
30
|
},
|
|
31
|
+
ref,
|
|
29
32
|
...props
|
|
30
33
|
}: AuthorProps): JSX.Element => {
|
|
31
34
|
const imageProps: ImageProps = {
|
|
@@ -38,7 +41,7 @@ export const Author = ({
|
|
|
38
41
|
...props,
|
|
39
42
|
}
|
|
40
43
|
return (
|
|
41
|
-
<div {...componentProps}>
|
|
44
|
+
<div {...componentProps} ref={ref}>
|
|
42
45
|
{image && <Image {...imageProps} />}
|
|
43
46
|
<div className="coop-author--content">
|
|
44
47
|
<span>
|
|
@@ -28,7 +28,7 @@ export interface ButtonProps extends ButtonHTMLAttributes<HTMLButtonElement> {
|
|
|
28
28
|
/** **(Optional)** Callback to run when the button is pressed. If this is an async function, it will be awaited and the button will be in a pending state until the promise is resolved. */
|
|
29
29
|
onClick?: React.MouseEventHandler<HTMLButtonElement | HTMLAnchorElement>
|
|
30
30
|
/** **(Optional)** Specify a custom React ref for this component. */
|
|
31
|
-
ref?: Ref<
|
|
31
|
+
ref?: Ref<HTMLElement>
|
|
32
32
|
/** **(Optional)** Specify the Button size. */
|
|
33
33
|
size?: "sm" | "md" | "lg"
|
|
34
34
|
/** **(Optional)** Specify the Button variant. */
|
|
@@ -92,7 +92,6 @@ export const Button = ({
|
|
|
92
92
|
"data-width": isFullWidth ? "full" : undefined,
|
|
93
93
|
href,
|
|
94
94
|
onClick: onClick ? handleClick : undefined,
|
|
95
|
-
ref,
|
|
96
95
|
...props,
|
|
97
96
|
}
|
|
98
97
|
|
|
@@ -106,6 +105,6 @@ export const Button = ({
|
|
|
106
105
|
children
|
|
107
106
|
)
|
|
108
107
|
|
|
109
|
-
return React.createElement(element, { ...componentProps }, finalChildren)
|
|
108
|
+
return React.createElement(element, { ...componentProps, ref }, finalChildren)
|
|
110
109
|
}
|
|
111
110
|
export default Button
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { ForwardRefExoticComponent, HTMLAttributes, JSX } from "react"
|
|
1
|
+
import type { ForwardRefExoticComponent, HTMLAttributes, JSX, Ref } from "react"
|
|
2
2
|
|
|
3
3
|
import clsx from "clsx"
|
|
4
4
|
import React from "react"
|
|
@@ -24,6 +24,8 @@ export interface CardProps extends HTMLAttributes<HTMLDivElement> {
|
|
|
24
24
|
imagePosition?: "left" | "right"
|
|
25
25
|
/** **(Optional)** Specify the orientation of the Card. */
|
|
26
26
|
orientation?: "vertical" | "horizontal"
|
|
27
|
+
/** **(Optional)** Specify a custom React ref for this component. */
|
|
28
|
+
ref?: Ref<HTMLDivElement>
|
|
27
29
|
}
|
|
28
30
|
|
|
29
31
|
interface CardLabelProps extends HTMLAttributes<HTMLSpanElement> {
|
|
@@ -87,6 +89,7 @@ export const Card = ({
|
|
|
87
89
|
hrefAs,
|
|
88
90
|
imagePosition = "left",
|
|
89
91
|
orientation = "vertical",
|
|
92
|
+
ref,
|
|
90
93
|
...props
|
|
91
94
|
}: CardProps): JSX.Element => {
|
|
92
95
|
const { element: linkElement, props: linkProps } = getCardLinkElement(hrefAs, href)
|
|
@@ -107,7 +110,7 @@ export const Card = ({
|
|
|
107
110
|
}
|
|
108
111
|
|
|
109
112
|
return (
|
|
110
|
-
<article {...componentProps}>
|
|
113
|
+
<article {...componentProps} ref={ref}>
|
|
111
114
|
{slots.CardImage}
|
|
112
115
|
{slots.CardBadge}
|
|
113
116
|
{React.createElement(
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { InputHTMLAttributes, JSX } from "react"
|
|
1
|
+
import type { InputHTMLAttributes, JSX, Ref } from "react"
|
|
2
2
|
|
|
3
3
|
import clsx from "clsx"
|
|
4
4
|
|
|
@@ -17,6 +17,8 @@ export interface CheckboxProps
|
|
|
17
17
|
id?: string
|
|
18
18
|
/** Specify the Checkbox name. */
|
|
19
19
|
name: string
|
|
20
|
+
/** **(Optional)** Specify a custom React ref for this component. */
|
|
21
|
+
ref?: Ref<HTMLInputElement>
|
|
20
22
|
/** **(Optional)** Specify the Checkbox size. */
|
|
21
23
|
size?: StandardSizes
|
|
22
24
|
}
|
|
@@ -27,6 +29,7 @@ export const Checkbox = ({
|
|
|
27
29
|
error = false,
|
|
28
30
|
id,
|
|
29
31
|
name,
|
|
32
|
+
ref,
|
|
30
33
|
size = "md",
|
|
31
34
|
...props
|
|
32
35
|
}: CheckboxProps): JSX.Element => {
|
|
@@ -41,7 +44,8 @@ export const Checkbox = ({
|
|
|
41
44
|
type: "checkbox",
|
|
42
45
|
...props,
|
|
43
46
|
}
|
|
44
|
-
|
|
47
|
+
|
|
48
|
+
return <input {...componentProps} ref={ref} />
|
|
45
49
|
}
|
|
46
50
|
|
|
47
51
|
export default Checkbox
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { DetailsHTMLAttributes, HTMLAttributes, JSX } from "react"
|
|
1
|
+
import type { DetailsHTMLAttributes, HTMLAttributes, JSX, Ref } from "react"
|
|
2
2
|
|
|
3
3
|
import { clsx } from "clsx"
|
|
4
4
|
|
|
@@ -11,6 +11,8 @@ export interface ExpandableProps extends DetailsHTMLAttributes<HTMLDetailsElemen
|
|
|
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 a custom React ref for this component. */
|
|
15
|
+
ref?: Ref<HTMLDetailsElement>
|
|
14
16
|
}
|
|
15
17
|
|
|
16
18
|
interface ExpandableSummaryProps extends HTMLAttributes<HTMLElement> {
|
|
@@ -25,7 +27,12 @@ const componentSlots = {
|
|
|
25
27
|
ExpandableSummary: null,
|
|
26
28
|
}
|
|
27
29
|
|
|
28
|
-
export const Expandable = ({
|
|
30
|
+
export const Expandable = ({
|
|
31
|
+
children,
|
|
32
|
+
className,
|
|
33
|
+
ref,
|
|
34
|
+
...props
|
|
35
|
+
}: ExpandableProps): JSX.Element => {
|
|
29
36
|
const slots = useSlots(componentSlots, children)
|
|
30
37
|
|
|
31
38
|
const componentProps = {
|
|
@@ -38,7 +45,7 @@ export const Expandable = ({ children, className, ...props }: ExpandableProps):
|
|
|
38
45
|
}
|
|
39
46
|
|
|
40
47
|
return (
|
|
41
|
-
<details {...componentProps}>
|
|
48
|
+
<details {...componentProps} ref={ref}>
|
|
42
49
|
{slots.ExpandableSummary}
|
|
43
50
|
<div className="coop-expandable--content">{slots.Children}</div>
|
|
44
51
|
</details>
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { HTMLAttributes, HTMLProps, JSX } from "react"
|
|
1
|
+
import type { HTMLAttributes, HTMLProps, JSX, Ref } from "react"
|
|
2
2
|
|
|
3
3
|
import clsx from "clsx"
|
|
4
4
|
import React from "react"
|
|
@@ -37,6 +37,8 @@ interface FieldProps extends HTMLAttributes<HTMLDivElement> {
|
|
|
37
37
|
error?: boolean
|
|
38
38
|
/** **(Optional)** Specify whether the Field should show the left-hand error bar if it is in an error state. */
|
|
39
39
|
hideErrorBar?: boolean
|
|
40
|
+
/** **(Optional)** Specify a custom React ref for this component. */
|
|
41
|
+
ref?: Ref<HTMLDivElement>
|
|
40
42
|
}
|
|
41
43
|
|
|
42
44
|
const Root = ({
|
|
@@ -45,19 +47,18 @@ const Root = ({
|
|
|
45
47
|
className,
|
|
46
48
|
error = false,
|
|
47
49
|
hideErrorBar = false,
|
|
50
|
+
ref,
|
|
48
51
|
...props
|
|
49
52
|
}: FieldProps) => {
|
|
50
53
|
const slots = { ...useSlots(componentSlots, children) }
|
|
51
54
|
const slotsArray = Object.entries(slots)
|
|
52
55
|
|
|
53
|
-
const uid = useId()
|
|
54
|
-
|
|
55
56
|
const isInlineControl = slotsArray.some((s) => s[1] !== null && inlineFields.includes(s[0]))
|
|
56
57
|
const hasFieldMarkers = !!(slots.FieldLabel ?? slots.FieldError ?? slots.FieldHint)
|
|
57
58
|
const [, control] =
|
|
58
59
|
slotsArray.find((s) => (!standardFields.includes(s[0]) && s[1] !== null ? s : null)) ?? []
|
|
59
60
|
|
|
60
|
-
let controlId =
|
|
61
|
+
let controlId = useId()
|
|
61
62
|
let controlDisabled = false
|
|
62
63
|
|
|
63
64
|
if (control) {
|
|
@@ -88,7 +89,7 @@ const Root = ({
|
|
|
88
89
|
}
|
|
89
90
|
|
|
90
91
|
return (
|
|
91
|
-
<div {...componentProps}>
|
|
92
|
+
<div {...componentProps} ref={ref}>
|
|
92
93
|
{!isInlineControl && hasFieldMarkers && (
|
|
93
94
|
<div className="coop-field-markers">
|
|
94
95
|
{slots.FieldLabel}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { HTMLAttributes, JSX, ReactNode } from "react"
|
|
1
|
+
import type { HTMLAttributes, JSX, ReactNode, Ref } from "react"
|
|
2
2
|
|
|
3
3
|
import clsx from "clsx"
|
|
4
4
|
|
|
@@ -7,14 +7,20 @@ export interface ErrorProps extends HTMLAttributes<HTMLSpanElement> {
|
|
|
7
7
|
children?: string | ReactNode
|
|
8
8
|
/** **(Optional)** Specify additional CSS classes to be applied to the component. */
|
|
9
9
|
className?: string
|
|
10
|
+
/** **(Optional)** Specify a custom React ref for this component. */
|
|
11
|
+
ref?: Ref<HTMLSpanElement>
|
|
10
12
|
}
|
|
11
13
|
|
|
12
|
-
export const Error = ({ children, className, ...props }: ErrorProps): JSX.Element => {
|
|
14
|
+
export const Error = ({ children, className, ref, ...props }: ErrorProps): JSX.Element => {
|
|
13
15
|
const componentProps = {
|
|
14
16
|
className: clsx("coop-field-error ", className),
|
|
15
17
|
...props,
|
|
16
18
|
}
|
|
17
|
-
return
|
|
19
|
+
return (
|
|
20
|
+
<span {...componentProps} ref={ref}>
|
|
21
|
+
{children}
|
|
22
|
+
</span>
|
|
23
|
+
)
|
|
18
24
|
}
|
|
19
25
|
|
|
20
26
|
export default Error
|
|
@@ -1,21 +1,27 @@
|
|
|
1
|
-
import type { HTMLAttributes, JSX, ReactNode } from "react"
|
|
1
|
+
import type { HTMLAttributes, JSX, ReactNode, Ref } from "react"
|
|
2
2
|
|
|
3
3
|
import clsx from "clsx"
|
|
4
4
|
|
|
5
|
-
export interface HintProps extends HTMLAttributes<
|
|
5
|
+
export interface HintProps extends HTMLAttributes<HTMLDivElement> {
|
|
6
6
|
/** **(Optional)** Hint text for the form element. Accepts any valid JSX or string. */
|
|
7
7
|
children?: string | ReactNode
|
|
8
8
|
/** **(Optional)** Specify additional CSS classes to be applied to the component. */
|
|
9
9
|
className?: string
|
|
10
|
+
/** **(Optional)** Specify a custom React ref for this component. */
|
|
11
|
+
ref?: Ref<HTMLDivElement>
|
|
10
12
|
}
|
|
11
13
|
|
|
12
|
-
export const Hint = ({ children, className, ...props }: HintProps): JSX.Element | null => {
|
|
14
|
+
export const Hint = ({ children, className, ref, ...props }: HintProps): JSX.Element | null => {
|
|
13
15
|
const componentProps = {
|
|
14
16
|
className: clsx("coop-field-hint ", className),
|
|
15
17
|
...props,
|
|
16
18
|
}
|
|
17
19
|
|
|
18
|
-
return
|
|
20
|
+
return (
|
|
21
|
+
<div {...componentProps} ref={ref}>
|
|
22
|
+
{children}
|
|
23
|
+
</div>
|
|
24
|
+
)
|
|
19
25
|
}
|
|
20
26
|
|
|
21
27
|
export default Hint
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import clsx from "clsx"
|
|
2
|
-
import { LabelHTMLAttributes } from "react"
|
|
2
|
+
import { LabelHTMLAttributes, Ref } from "react"
|
|
3
3
|
|
|
4
4
|
export interface LabelProps extends LabelHTMLAttributes<HTMLLabelElement> {
|
|
5
5
|
/** **(Optional)** Main label for the form element. Accepts any valid JSX or string. */
|
|
@@ -8,11 +8,17 @@ export interface LabelProps extends LabelHTMLAttributes<HTMLLabelElement> {
|
|
|
8
8
|
className?: string
|
|
9
9
|
/** **(Optional)** Specify whether the label is visible for humans or only for screen readers. */
|
|
10
10
|
isVisible?: boolean
|
|
11
|
+
/** **(Optional)** Specify a custom React ref for this component. */
|
|
12
|
+
ref?: Ref<HTMLLabelElement>
|
|
11
13
|
}
|
|
12
14
|
|
|
13
|
-
export const Label = ({ children, className, isVisible = true, ...props }: LabelProps) => {
|
|
15
|
+
export const Label = ({ children, className, isVisible = true, ref, ...props }: LabelProps) => {
|
|
16
|
+
const componentProps = {
|
|
17
|
+
className: clsx("coop-field-label", !isVisible && "sr-only", className),
|
|
18
|
+
...props,
|
|
19
|
+
}
|
|
14
20
|
return (
|
|
15
|
-
<label {...
|
|
21
|
+
<label {...componentProps} ref={ref}>
|
|
16
22
|
<span>{children}</span>
|
|
17
23
|
</label>
|
|
18
24
|
)
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import clsx from "clsx"
|
|
2
|
-
import { HTMLAttributes } from "react"
|
|
2
|
+
import { HTMLAttributes, Ref } from "react"
|
|
3
3
|
|
|
4
4
|
export interface LegendProps extends HTMLAttributes<HTMLLegendElement> {
|
|
5
5
|
/** **(Optional)** Main legend for the fieldset. Accepts any valid JSX or string. */
|
|
@@ -8,9 +8,11 @@ export interface LegendProps extends HTMLAttributes<HTMLLegendElement> {
|
|
|
8
8
|
className?: string
|
|
9
9
|
/** **(Optional)** Specify whether the legend should be visible to humans or screen readers. */
|
|
10
10
|
isVisible?: boolean
|
|
11
|
+
/** **(Optional)** Specify a custom React ref for this component. */
|
|
12
|
+
ref?: Ref<HTMLLegendElement>
|
|
11
13
|
}
|
|
12
14
|
|
|
13
|
-
export const Legend = ({ children, className, isVisible = true, ...props }: LegendProps) => {
|
|
15
|
+
export const Legend = ({ children, className, isVisible = true, ref, ...props }: LegendProps) => {
|
|
14
16
|
const componentProps = {
|
|
15
17
|
"aria-hidden": true,
|
|
16
18
|
className: clsx("coop-field-label", !isVisible && "sr-only", className),
|
|
@@ -20,7 +22,11 @@ export const Legend = ({ children, className, isVisible = true, ...props }: Lege
|
|
|
20
22
|
return (
|
|
21
23
|
<>
|
|
22
24
|
<legend className="sr-only">{children}</legend>
|
|
23
|
-
{isVisible &&
|
|
25
|
+
{isVisible && (
|
|
26
|
+
<div {...componentProps} ref={ref}>
|
|
27
|
+
{children}
|
|
28
|
+
</div>
|
|
29
|
+
)}
|
|
24
30
|
</>
|
|
25
31
|
)
|
|
26
32
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import clsx from "clsx"
|
|
2
|
-
import { type FieldsetHTMLAttributes, type JSX } from "react"
|
|
2
|
+
import { type FieldsetHTMLAttributes, type JSX, Ref } from "react"
|
|
3
3
|
|
|
4
4
|
import { StandardSizes } from "../../../src/types"
|
|
5
5
|
import { Error as BaseError, type ErrorProps } from "../FieldMarkers/Error"
|
|
@@ -19,6 +19,8 @@ export interface FieldsetProps extends FieldsetHTMLAttributes<HTMLFieldSetElemen
|
|
|
19
19
|
error?: boolean
|
|
20
20
|
/** **(Optional)** Specify whether the Fieldset should show the left-hand error bar if it is in an error state. */
|
|
21
21
|
hideErrorBar?: boolean
|
|
22
|
+
/** **(Optional)** Specify a custom React ref for this component. */
|
|
23
|
+
ref?: Ref<HTMLFieldSetElement>
|
|
22
24
|
/** **(Optional)** Specify the size of the Fieldset and all its descendents. */
|
|
23
25
|
size?: StandardSizes
|
|
24
26
|
}
|
|
@@ -28,6 +30,7 @@ const Root = ({
|
|
|
28
30
|
disabled,
|
|
29
31
|
error = false,
|
|
30
32
|
hideErrorBar = false,
|
|
33
|
+
ref,
|
|
31
34
|
size = "md",
|
|
32
35
|
...props
|
|
33
36
|
}: FieldsetProps): JSX.Element => {
|
|
@@ -35,15 +38,17 @@ const Root = ({
|
|
|
35
38
|
"aria-disabled": disabled,
|
|
36
39
|
className: clsx("coop-fieldset", className),
|
|
37
40
|
"data-error": error || undefined,
|
|
38
|
-
//"data-variant": variant !== "default" ? variant : undefined,
|
|
39
41
|
"data-hide-error": hideErrorBar || undefined,
|
|
40
|
-
// "data-orientation": orientation !== "vertical" ? orientation : undefined,
|
|
41
42
|
"data-size": size.length && size !== "md" ? size : undefined,
|
|
42
43
|
disabled,
|
|
43
44
|
...props,
|
|
44
45
|
}
|
|
45
46
|
|
|
46
|
-
return
|
|
47
|
+
return (
|
|
48
|
+
<fieldset {...componentProps} ref={ref}>
|
|
49
|
+
{children}
|
|
50
|
+
</fieldset>
|
|
51
|
+
)
|
|
47
52
|
}
|
|
48
53
|
|
|
49
54
|
interface FieldsetFieldsProps {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { JSX, ReactNode, SVGProps } from "react"
|
|
1
|
+
import type { JSX, ReactNode, Ref, SVGProps } from "react"
|
|
2
2
|
|
|
3
3
|
import clsx from "clsx"
|
|
4
4
|
|
|
@@ -11,12 +11,15 @@ export interface FlourishProps extends SVGProps<SVGSVGElement> {
|
|
|
11
11
|
className?: string
|
|
12
12
|
/** **(Optional)** Specify the Flourish color. */
|
|
13
13
|
fill?: Darks | Lights | Tints | OfferRed | BrandBlue | White | Black
|
|
14
|
+
/** **(Optional)** Specify a custom React ref for this component. */
|
|
15
|
+
ref?: Ref<SVGSVGElement>
|
|
14
16
|
}
|
|
15
17
|
|
|
16
18
|
export const Flourish = ({
|
|
17
19
|
children,
|
|
18
20
|
className,
|
|
19
21
|
fill = "brand-blue",
|
|
22
|
+
ref,
|
|
20
23
|
...props
|
|
21
24
|
}: FlourishProps): JSX.Element => {
|
|
22
25
|
const componentProps = {
|
|
@@ -28,7 +31,7 @@ export const Flourish = ({
|
|
|
28
31
|
return (
|
|
29
32
|
<span style={{ position: "relative" }}>
|
|
30
33
|
{children}
|
|
31
|
-
<svg {...componentProps} viewBox="0 0 276 10">
|
|
34
|
+
<svg {...componentProps} ref={ref} viewBox="0 0 276 10">
|
|
32
35
|
<path d="M275.9 8.6c.1-1.6.2-1.8-.4-2.9.3-1-.3-1.2-1.8-1.1v-.3c.6-.4.2-.2 1.4-.1-.9-2.3-5.6-1.8-8.5-2.3C259 .5 246.3.7 237.4.5L185 .4l-33-.2-26.1-.2-67.4 1.2-44.3.5C10.7 2.1 1.5.4 0 3.3l1 .2L0 4v.5C8.2 7.9 26.6 7.2 35.6 7c5 0 13.5 1.6 16.5-.6C53.4 8 59.5 8 62 7.7l45 .1 42.8.3 30.7.3 44.2.6 27.8-.5 23 .8c.1-.8-.3-.5.5-.7ZM219 2.8v-.2l.8-.2h.4l.3.4H219Zm30-.1h1.2c-.8.4-.5.3-1.2 0Zm6.2.6.2-.4h.3l-.5.4Z" />
|
|
33
36
|
</svg>
|
|
34
37
|
</span>
|
|
@@ -1,24 +1,27 @@
|
|
|
1
1
|
import clsx from "clsx"
|
|
2
|
-
import { type SVGProps
|
|
2
|
+
import { type SVGProps } from "react"
|
|
3
|
+
|
|
4
|
+
import { useId } from "../../hooks/useId"
|
|
3
5
|
|
|
4
6
|
interface IconProps extends SVGProps<SVGSVGElement> {
|
|
5
7
|
alt?: string
|
|
6
8
|
}
|
|
7
9
|
|
|
8
|
-
export const AddIcon = ({ alt, className, fill, ...props }: IconProps) => {
|
|
9
|
-
const
|
|
10
|
+
export const AddIcon = ({ alt, className, fill, id, ref, ...props }: IconProps) => {
|
|
11
|
+
const uid = useId(id)
|
|
10
12
|
const componentProps = {
|
|
11
|
-
"aria-labelledby": alt ?
|
|
13
|
+
"aria-labelledby": alt ? uid + "-title" : undefined,
|
|
12
14
|
className: clsx("coop-icon", className),
|
|
13
15
|
"data-icon": "add",
|
|
14
16
|
fill: fill ?? "none",
|
|
17
|
+
id: uid,
|
|
15
18
|
role: alt ? "img" : undefined,
|
|
16
19
|
viewBox: "0 0 32 32",
|
|
17
20
|
...props,
|
|
18
21
|
}
|
|
19
22
|
return (
|
|
20
|
-
<svg {...componentProps}>
|
|
21
|
-
{alt ? <title id={
|
|
23
|
+
<svg {...componentProps} ref={ref}>
|
|
24
|
+
{alt ? <title id={uid + "-title"}>{alt}</title> : null}
|
|
22
25
|
<path
|
|
23
26
|
d="M24.7 16.72a1 1 0 0 1-.7.28H8a1 1 0 1 1 0-2h16a1 1 0 0 1 1 1 1 1 0 0 1-.3.72"
|
|
24
27
|
fill={fill ?? "currentColor"}
|
|
@@ -1,24 +1,27 @@
|
|
|
1
1
|
import clsx from "clsx"
|
|
2
|
-
import { type SVGProps
|
|
2
|
+
import { type SVGProps } from "react"
|
|
3
|
+
|
|
4
|
+
import { useId } from "../../hooks/useId"
|
|
3
5
|
|
|
4
6
|
interface IconProps extends SVGProps<SVGSVGElement> {
|
|
5
7
|
alt?: string
|
|
6
8
|
}
|
|
7
9
|
|
|
8
|
-
export const ArrowDownIcon = ({ alt, className, fill, ...props }: IconProps) => {
|
|
9
|
-
const
|
|
10
|
+
export const ArrowDownIcon = ({ alt, className, fill, id, ref, ...props }: IconProps) => {
|
|
11
|
+
const uid = useId(id)
|
|
10
12
|
const componentProps = {
|
|
11
|
-
"aria-labelledby": alt ?
|
|
13
|
+
"aria-labelledby": alt ? uid + "-title" : undefined,
|
|
12
14
|
className: clsx("coop-icon", className),
|
|
13
15
|
"data-icon": "arrow-down",
|
|
14
16
|
fill: fill ?? "none",
|
|
17
|
+
id: uid,
|
|
15
18
|
role: alt ? "img" : undefined,
|
|
16
19
|
viewBox: "0 0 32 32",
|
|
17
20
|
...props,
|
|
18
21
|
}
|
|
19
22
|
return (
|
|
20
|
-
<svg {...componentProps}>
|
|
21
|
-
{alt ? <title id={
|
|
23
|
+
<svg {...componentProps} ref={ref}>
|
|
24
|
+
{alt ? <title id={uid + "-title"}>{alt}</title> : null}
|
|
22
25
|
<path d="M15 28.66V3a1 1 0 0 1 2 0v25.66a1 1 0 0 1-2 0" fill={fill ?? "currentColor"} />
|
|
23
26
|
<path
|
|
24
27
|
d="M3 17a1 1 0 0 1 .29-.71 1 1 0 0 1 1.42 0L16 27.58l11.29-11.29a1 1 0 0 1 1.42 0 1 1 0 0 1 0 1.41l-12 12a1 1 0 0 1-1.41 0l-12-12A1 1 0 0 1 3 17"
|
|
@@ -1,24 +1,27 @@
|
|
|
1
1
|
import clsx from "clsx"
|
|
2
|
-
import { type SVGProps
|
|
2
|
+
import { type SVGProps } from "react"
|
|
3
|
+
|
|
4
|
+
import { useId } from "../../hooks/useId"
|
|
3
5
|
|
|
4
6
|
interface IconProps extends SVGProps<SVGSVGElement> {
|
|
5
7
|
alt?: string
|
|
6
8
|
}
|
|
7
9
|
|
|
8
|
-
export const ArrowLeftIcon = ({ alt, className, fill, ...props }: IconProps) => {
|
|
9
|
-
const
|
|
10
|
+
export const ArrowLeftIcon = ({ alt, className, fill, id, ref, ...props }: IconProps) => {
|
|
11
|
+
const uid = useId(id)
|
|
10
12
|
const componentProps = {
|
|
11
|
-
"aria-labelledby": alt ?
|
|
13
|
+
"aria-labelledby": alt ? uid + "-title" : undefined,
|
|
12
14
|
className: clsx("coop-icon", className),
|
|
13
15
|
"data-icon": "arrow-left",
|
|
14
16
|
fill: fill ?? "none",
|
|
17
|
+
id: uid,
|
|
15
18
|
role: alt ? "img" : undefined,
|
|
16
19
|
viewBox: "0 0 32 32",
|
|
17
20
|
...props,
|
|
18
21
|
}
|
|
19
22
|
return (
|
|
20
|
-
<svg {...componentProps}>
|
|
21
|
-
{alt ? <title id={
|
|
23
|
+
<svg {...componentProps} ref={ref}>
|
|
24
|
+
{alt ? <title id={uid + "-title"}>{alt}</title> : null}
|
|
22
25
|
<path d="M3.34 17H29a1 1 0 0 0 0-2H3.34a1 1 0 0 0 0 2" fill={fill ?? "currentColor"} />
|
|
23
26
|
<path
|
|
24
27
|
d="M15 29a1 1 0 0 0 .71-.29 1 1 0 0 0 0-1.42L5.12 16.71a1 1 0 0 1 0-1.42L15.71 4.71a1 1 0 0 0 0-1.42 1 1 0 0 0-1.41 0l-12 12a1 1 0 0 0 0 1.42l12 12a1 1 0 0 0 .7.29"
|
|
@@ -1,24 +1,27 @@
|
|
|
1
1
|
import clsx from "clsx"
|
|
2
|
-
import { type SVGProps
|
|
2
|
+
import { type SVGProps } from "react"
|
|
3
|
+
|
|
4
|
+
import { useId } from "../../hooks/useId"
|
|
3
5
|
|
|
4
6
|
interface IconProps extends SVGProps<SVGSVGElement> {
|
|
5
7
|
alt?: string
|
|
6
8
|
}
|
|
7
9
|
|
|
8
|
-
export const ArrowRightIcon = ({ alt, className, fill, ...props }: IconProps) => {
|
|
9
|
-
const
|
|
10
|
+
export const ArrowRightIcon = ({ alt, className, fill, id, ref, ...props }: IconProps) => {
|
|
11
|
+
const uid = useId(id)
|
|
10
12
|
const componentProps = {
|
|
11
|
-
"aria-labelledby": alt ?
|
|
13
|
+
"aria-labelledby": alt ? uid + "-title" : undefined,
|
|
12
14
|
className: clsx("coop-icon", className),
|
|
13
15
|
"data-icon": "arrow-right",
|
|
14
16
|
fill: fill ?? "none",
|
|
17
|
+
id: uid,
|
|
15
18
|
role: alt ? "img" : undefined,
|
|
16
19
|
viewBox: "0 0 32 32",
|
|
17
20
|
...props,
|
|
18
21
|
}
|
|
19
22
|
return (
|
|
20
|
-
<svg {...componentProps}>
|
|
21
|
-
{alt ? <title id={
|
|
23
|
+
<svg {...componentProps} ref={ref}>
|
|
24
|
+
{alt ? <title id={uid + "-title"}>{alt}</title> : null}
|
|
22
25
|
<path d="M28.7 15H3a1 1 0 0 0 0 2h25.7a1 1 0 0 0 0-2" fill={fill ?? "currentColor"} />
|
|
23
26
|
<path
|
|
24
27
|
d="M17 3a1 1 0 0 0-.7.3 1 1 0 0 0 0 1.4l10.6 10.6a1 1 0 0 1 0 1.4L16.3 27.3a1 1 0 0 0 0 1.4 1 1 0 0 0 1.4 0l12-12a1 1 0 0 0 0-1.4l-12-12A1 1 0 0 0 17 3"
|