@coopdigital/react 0.45.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 +6 -4
- package/dist/components/Button/Button.js +4 -7
- package/dist/components/Card/Card.d.ts +4 -2
- package/dist/components/Card/Card.js +4 -4
- 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 +4 -4
- package/dist/components/Field/Field.d.ts +4 -2
- package/dist/components/Field/Field.js +7 -8
- 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 +7 -8
- package/dist/components/Radio/Radio.d.ts +20 -0
- package/dist/components/Radio/Radio.js +21 -0
- package/dist/components/Radio/index.d.ts +4 -0
- package/dist/components/{SearchBox/SearchBox.d.ts → Searchbox/Searchbox.d.ts} +10 -8
- package/dist/components/{SearchBox/SearchBox.js → Searchbox/Searchbox.js} +16 -11
- package/dist/components/Searchbox/index.d.ts +4 -0
- 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 +5 -3
- 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/dist/{utils/slots.d.ts → hooks/useSlots.d.ts} +1 -1
- package/dist/{utils/slots.js → hooks/useSlots.js} +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +2 -2
- package/package.json +3 -3
- package/src/components/AlertBanner/AlertBanner.tsx +6 -2
- package/src/components/Author/Author.tsx +5 -2
- package/src/components/Button/Button.tsx +10 -15
- package/src/components/Card/Card.tsx +7 -5
- package/src/components/Checkbox/Checkbox.tsx +6 -2
- package/src/components/Expandable/Expandable.tsx +12 -5
- package/src/components/Field/Field.tsx +10 -9
- 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 +10 -9
- package/src/components/Radio/Radio.tsx +50 -0
- package/src/components/Radio/index.ts +5 -0
- package/src/components/{SearchBox/SearchBox.tsx → Searchbox/Searchbox.tsx} +33 -30
- package/src/components/Searchbox/index.ts +5 -0
- 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 +18 -3
- package/src/components/Textarea/Textarea.tsx +8 -6
- package/src/{utils/slots.ts → hooks/useSlots.ts} +1 -1
- package/src/index.ts +2 -2
- package/dist/components/RadioButton/RadioButton.d.ts +0 -18
- package/dist/components/RadioButton/RadioButton.js +0 -22
- package/dist/components/RadioButton/index.d.ts +0 -4
- package/dist/components/SearchBox/index.d.ts +0 -4
- package/src/components/RadioButton/RadioButton.tsx +0 -48
- package/src/components/RadioButton/index.ts +0 -5
- package/src/components/SearchBox/index.ts +0 -5
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { HTMLAttributes, JSX, ReactNode } from "react";
|
|
1
|
+
import type { HTMLAttributes, JSX, ReactNode, Ref } from "react";
|
|
2
2
|
export interface AlertBannerProps extends HTMLAttributes<HTMLDivElement> {
|
|
3
3
|
/** **(Optional)** Main content inside the banner. It can be any valid JSX or string. */
|
|
4
4
|
children?: string | ReactNode;
|
|
@@ -6,8 +6,10 @@ export interface AlertBannerProps extends HTMLAttributes<HTMLDivElement> {
|
|
|
6
6
|
className?: string;
|
|
7
7
|
/** Specify the main title of the banner, rendered as a `h2`. */
|
|
8
8
|
heading: string;
|
|
9
|
+
/** **(Optional)** Specify a custom React ref for this component. */
|
|
10
|
+
ref?: Ref<HTMLDivElement>;
|
|
9
11
|
/** **(Optional)** Specify the AlertBanner variant. */
|
|
10
12
|
variant?: "black" | "default";
|
|
11
13
|
}
|
|
12
|
-
export declare const AlertBanner: ({ children, className, heading, variant, ...props }: AlertBannerProps) => JSX.Element;
|
|
14
|
+
export declare const AlertBanner: ({ children, className, heading, ref, variant, ...props }: AlertBannerProps) => JSX.Element;
|
|
13
15
|
export default AlertBanner;
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import { jsx, jsxs } from 'react/jsx-runtime';
|
|
2
2
|
import clsx from 'clsx';
|
|
3
3
|
|
|
4
|
-
const AlertBanner = ({ children, className, heading, variant = "default", ...props }) => {
|
|
4
|
+
const AlertBanner = ({ children, className, heading, ref, variant = "default", ...props }) => {
|
|
5
5
|
const componentProps = {
|
|
6
6
|
className: clsx("coop-alert-banner", className),
|
|
7
7
|
"data-variant": variant,
|
|
8
8
|
...props,
|
|
9
9
|
};
|
|
10
|
-
return (jsx("aside", { ...componentProps, children: jsxs("div", { className: "coop-alert-banner--inner", children: [jsx("h2", { id: "coop-alert-banner--headline", children: heading }), children] }) }));
|
|
10
|
+
return (jsx("aside", { ...componentProps, ref: ref, children: jsxs("div", { className: "coop-alert-banner--inner", children: [jsx("h2", { id: "coop-alert-banner--headline", children: heading }), children] }) }));
|
|
11
11
|
};
|
|
12
12
|
|
|
13
13
|
export { AlertBanner, AlertBanner as default };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { HTMLAttributes, JSX } from "react";
|
|
1
|
+
import type { HTMLAttributes, JSX, Ref } from "react";
|
|
2
2
|
import { ImageProps } from "../Image";
|
|
3
3
|
export interface AuthorProps extends HTMLAttributes<HTMLDivElement> {
|
|
4
4
|
/** **(Optional)** Specify the Author name. */
|
|
@@ -11,6 +11,8 @@ export interface AuthorProps extends HTMLAttributes<HTMLDivElement> {
|
|
|
11
11
|
datePrefix?: string;
|
|
12
12
|
/** **(Optional)** Specify properties of the Author Image. */
|
|
13
13
|
image?: ImageProps;
|
|
14
|
+
/** **(Optional)** Specify a custom React ref for this component. */
|
|
15
|
+
ref?: Ref<HTMLDivElement>;
|
|
14
16
|
}
|
|
15
|
-
export declare const Author: ({ author, className, date, datePrefix, image, ...props }: AuthorProps) => JSX.Element;
|
|
17
|
+
export declare const Author: ({ author, className, date, datePrefix, image, ref, ...props }: AuthorProps) => JSX.Element;
|
|
16
18
|
export default Author;
|
|
@@ -5,7 +5,7 @@ import { Image } from '../Image/Image.js';
|
|
|
5
5
|
const Author = ({ author = "Co-op team", className, date, datePrefix = "", image = {
|
|
6
6
|
alt: "",
|
|
7
7
|
src: "https://s3.eu-west-1.amazonaws.com/assets.digital.coop.co.uk/oneweb/coop-logo-inverted.svg",
|
|
8
|
-
}, ...props }) => {
|
|
8
|
+
}, ref, ...props }) => {
|
|
9
9
|
const imageProps = {
|
|
10
10
|
width: "56px",
|
|
11
11
|
...image,
|
|
@@ -14,7 +14,7 @@ const Author = ({ author = "Co-op team", className, date, datePrefix = "", image
|
|
|
14
14
|
className: clsx("coop-author", className),
|
|
15
15
|
...props,
|
|
16
16
|
};
|
|
17
|
-
return (jsxs("div", { ...componentProps, children: [image && jsx(Image, { ...imageProps }), jsxs("div", { className: "coop-author--content", children: [jsxs("span", { children: [datePrefix ? datePrefix + " " : "", date] }), jsxs("span", { children: ["by ", author] })] })] }));
|
|
17
|
+
return (jsxs("div", { ...componentProps, ref: ref, children: [image && jsx(Image, { ...imageProps }), jsxs("div", { className: "coop-author--content", children: [jsxs("span", { children: [datePrefix ? datePrefix + " " : "", date] }), jsxs("span", { children: ["by ", author] })] })] }));
|
|
18
18
|
};
|
|
19
19
|
|
|
20
20
|
export { Author, Author as default };
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { ButtonHTMLAttributes, ForwardRefExoticComponent, JSX, Ref } from "react";
|
|
2
2
|
import React from "react";
|
|
3
3
|
export interface ButtonProps extends ButtonHTMLAttributes<HTMLButtonElement> {
|
|
4
4
|
/** **(Optional)** Specify a custom element to override default `a` or `button`. */
|
|
5
|
-
as?: React.FC<
|
|
5
|
+
as?: React.FC<any> | ForwardRefExoticComponent<any> | string;
|
|
6
6
|
/** **(Optional)** Main content inside the component. It can be any valid JSX or string. */
|
|
7
7
|
children?: React.ReactNode;
|
|
8
8
|
/** **(Optional)** Specify additional CSS classes to be applied to the component. */
|
|
@@ -18,11 +18,13 @@ export interface ButtonProps extends ButtonHTMLAttributes<HTMLButtonElement> {
|
|
|
18
18
|
/** **(Optional)** Specify text to show when the Button is in a loading state. */
|
|
19
19
|
loadingText?: string;
|
|
20
20
|
/** **(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. */
|
|
21
|
-
onClick?:
|
|
21
|
+
onClick?: React.MouseEventHandler<HTMLButtonElement | HTMLAnchorElement>;
|
|
22
|
+
/** **(Optional)** Specify a custom React ref for this component. */
|
|
23
|
+
ref?: Ref<HTMLElement>;
|
|
22
24
|
/** **(Optional)** Specify the Button size. */
|
|
23
25
|
size?: "sm" | "md" | "lg";
|
|
24
26
|
/** **(Optional)** Specify the Button variant. */
|
|
25
27
|
variant?: "green" | "blue" | "white" | "grey" | "green-ghost" | "blue-ghost" | "white-ghost" | "grey-ghost" | "text";
|
|
26
28
|
}
|
|
27
|
-
export declare const Button: ({ as, children, className, href, isDisabled, isFullWidth, isLoading, loadingText, onClick, size, variant, ...props }: ButtonProps) => JSX.Element;
|
|
29
|
+
export declare const Button: ({ as, children, className, href, isDisabled, isFullWidth, isLoading, loadingText, onClick, ref, size, variant, ...props }: ButtonProps) => JSX.Element;
|
|
28
30
|
export default Button;
|
|
@@ -5,11 +5,8 @@ import clsx from 'clsx';
|
|
|
5
5
|
import React, { useState, useCallback } from 'react';
|
|
6
6
|
import { LoadingIcon } from '../Icon/LoadingIcon.js';
|
|
7
7
|
|
|
8
|
-
const Button = ({ as, children, className, href, isDisabled = false, isFullWidth = false, isLoading = false, loadingText = "Loading", onClick, size = "md", variant = "green", ...props }) => {
|
|
9
|
-
|
|
10
|
-
if (as) {
|
|
11
|
-
element = as;
|
|
12
|
-
}
|
|
8
|
+
const Button = ({ as, children, className, href, isDisabled = false, isFullWidth = false, isLoading = false, loadingText = "Loading", onClick, ref, size = "md", variant = "green", ...props }) => {
|
|
9
|
+
const element = as !== null && as !== void 0 ? as : (href ? "a" : "button");
|
|
13
10
|
const [isPending, setIsPending] = useState(false);
|
|
14
11
|
const handleClick = useCallback(async (event) => {
|
|
15
12
|
if (isPending || !onClick)
|
|
@@ -31,11 +28,11 @@ const Button = ({ as, children, className, href, isDisabled = false, isFullWidth
|
|
|
31
28
|
"data-variant": variant !== "text" ? variant : undefined,
|
|
32
29
|
"data-width": isFullWidth ? "full" : undefined,
|
|
33
30
|
href,
|
|
34
|
-
onClick: handleClick,
|
|
31
|
+
onClick: onClick ? handleClick : undefined,
|
|
35
32
|
...props,
|
|
36
33
|
};
|
|
37
34
|
const finalChildren = isPending || isLoading ? (jsxs(Fragment, { children: [loadingText, jsx(LoadingIcon, {})] })) : (children);
|
|
38
|
-
return React.createElement(element, { ...componentProps }, finalChildren);
|
|
35
|
+
return React.createElement(element, { ...componentProps, ref }, finalChildren);
|
|
39
36
|
};
|
|
40
37
|
|
|
41
38
|
export { Button, Button as default };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { ForwardRefExoticComponent, HTMLAttributes, JSX } from "react";
|
|
1
|
+
import type { ForwardRefExoticComponent, HTMLAttributes, JSX, Ref } from "react";
|
|
2
2
|
import React from "react";
|
|
3
3
|
import { ImageProps } from "../Image";
|
|
4
4
|
export interface CardProps extends HTMLAttributes<HTMLDivElement> {
|
|
@@ -16,6 +16,8 @@ export interface CardProps extends HTMLAttributes<HTMLDivElement> {
|
|
|
16
16
|
imagePosition?: "left" | "right";
|
|
17
17
|
/** **(Optional)** Specify the orientation of the Card. */
|
|
18
18
|
orientation?: "vertical" | "horizontal";
|
|
19
|
+
/** **(Optional)** Specify a custom React ref for this component. */
|
|
20
|
+
ref?: Ref<HTMLDivElement>;
|
|
19
21
|
}
|
|
20
22
|
interface CardLabelProps extends HTMLAttributes<HTMLSpanElement> {
|
|
21
23
|
/** **(Optional)** Content inside the Label. */
|
|
@@ -47,7 +49,7 @@ interface CardBadgeProps extends HTMLAttributes<HTMLDivElement> {
|
|
|
47
49
|
}
|
|
48
50
|
type CardImageProps = ImageProps;
|
|
49
51
|
export declare const Card: {
|
|
50
|
-
({ chevron, children, className, href, hrefAs, imagePosition, orientation, ...props }: CardProps): JSX.Element;
|
|
52
|
+
({ chevron, children, className, href, hrefAs, imagePosition, orientation, ref, ...props }: CardProps): JSX.Element;
|
|
51
53
|
Label: {
|
|
52
54
|
({ children, className }: CardLabelProps): JSX.Element;
|
|
53
55
|
displayName: string;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { jsxs, jsx, Fragment } from 'react/jsx-runtime';
|
|
2
2
|
import clsx from 'clsx';
|
|
3
3
|
import React from 'react';
|
|
4
|
-
import {
|
|
4
|
+
import { useSlots } from '../../hooks/useSlots.js';
|
|
5
5
|
import { ChevronRightIcon } from '../Icon/ChevronRightIcon.js';
|
|
6
6
|
import { Image } from '../Image/Image.js';
|
|
7
7
|
|
|
@@ -22,9 +22,9 @@ function getCardLinkElement(as, href) {
|
|
|
22
22
|
},
|
|
23
23
|
};
|
|
24
24
|
}
|
|
25
|
-
const Card = ({ chevron = false, children, className, href, hrefAs, imagePosition = "left", orientation = "vertical", ...props }) => {
|
|
25
|
+
const Card = ({ chevron = false, children, className, href, hrefAs, imagePosition = "left", orientation = "vertical", ref, ...props }) => {
|
|
26
26
|
const { element: linkElement, props: linkProps } = getCardLinkElement(hrefAs, href);
|
|
27
|
-
const slots =
|
|
27
|
+
const slots = { ...useSlots(componentSlots, children) };
|
|
28
28
|
const innerProps = { className: "coop-card--inner" };
|
|
29
29
|
const hasLinkWrapper = href && !slots.CardHeading;
|
|
30
30
|
const componentProps = {
|
|
@@ -36,7 +36,7 @@ const Card = ({ chevron = false, children, className, href, hrefAs, imagePositio
|
|
|
36
36
|
if (href && slots.CardHeading) {
|
|
37
37
|
slots.CardHeading = React.createElement(linkElement, linkProps, slots.CardHeading);
|
|
38
38
|
}
|
|
39
|
-
return (jsxs("article", { ...componentProps, children: [slots.CardImage, slots.CardBadge, React.createElement(hasLinkWrapper ? linkElement : "div", hasLinkWrapper ? { href, ...innerProps } : innerProps, jsxs("div", { className: "coop-card--content", children: [slots.CardLabel, slots.CardHeading, slots.CardBody, slots.Children] }), chevron && (jsx("span", { "aria-hidden": "true", className: "coop-card--icon", role: "presentation", children: jsx(ChevronRightIcon, {}) })))] }));
|
|
39
|
+
return (jsxs("article", { ...componentProps, ref: ref, children: [slots.CardImage, slots.CardBadge, React.createElement(hasLinkWrapper ? linkElement : "div", hasLinkWrapper ? { href, ...innerProps } : innerProps, jsxs("div", { className: "coop-card--content", children: [slots.CardLabel, slots.CardHeading, slots.CardBody, slots.Children] }), chevron && (jsx("span", { "aria-hidden": "true", className: "coop-card--icon", role: "presentation", children: jsx(ChevronRightIcon, {}) })))] }));
|
|
40
40
|
};
|
|
41
41
|
const CardHeading = ({ as = "h3", children, className }) => {
|
|
42
42
|
return React.createElement(as, { className: clsx("coop-card--heading", className) }, children);
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { InputHTMLAttributes, JSX } from "react";
|
|
1
|
+
import type { InputHTMLAttributes, JSX, Ref } from "react";
|
|
2
2
|
import { 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. */
|
|
@@ -11,8 +11,10 @@ export interface CheckboxProps extends Omit<InputHTMLAttributes<HTMLInputElement
|
|
|
11
11
|
id?: string;
|
|
12
12
|
/** Specify the Checkbox name. */
|
|
13
13
|
name: string;
|
|
14
|
+
/** **(Optional)** Specify a custom React ref for this component. */
|
|
15
|
+
ref?: Ref<HTMLInputElement>;
|
|
14
16
|
/** **(Optional)** Specify the Checkbox size. */
|
|
15
17
|
size?: StandardSizes;
|
|
16
18
|
}
|
|
17
|
-
export declare const Checkbox: ({ className, disabled, error, id, name, size, ...props }: CheckboxProps) => JSX.Element;
|
|
19
|
+
export declare const Checkbox: ({ className, disabled, error, id, name, ref, size, ...props }: CheckboxProps) => JSX.Element;
|
|
18
20
|
export default Checkbox;
|
|
@@ -2,7 +2,7 @@ import { jsx } from 'react/jsx-runtime';
|
|
|
2
2
|
import clsx from 'clsx';
|
|
3
3
|
import { useId } from '../../hooks/useId.js';
|
|
4
4
|
|
|
5
|
-
const Checkbox = ({ className, disabled, error = false, id, name, size = "md", ...props }) => {
|
|
5
|
+
const Checkbox = ({ className, disabled, error = false, id, name, ref, size = "md", ...props }) => {
|
|
6
6
|
const uid = useId(id);
|
|
7
7
|
const componentProps = {
|
|
8
8
|
className: clsx("coop-checkbox", className),
|
|
@@ -14,7 +14,7 @@ const Checkbox = ({ className, disabled, error = false, id, name, size = "md", .
|
|
|
14
14
|
type: "checkbox",
|
|
15
15
|
...props,
|
|
16
16
|
};
|
|
17
|
-
return jsx("input", { ...componentProps });
|
|
17
|
+
return jsx("input", { ...componentProps, ref: ref });
|
|
18
18
|
};
|
|
19
19
|
|
|
20
20
|
export { Checkbox, Checkbox as default };
|
|
@@ -1,9 +1,11 @@
|
|
|
1
|
-
import type { DetailsHTMLAttributes, HTMLAttributes, JSX } from "react";
|
|
1
|
+
import type { DetailsHTMLAttributes, HTMLAttributes, JSX, Ref } from "react";
|
|
2
2
|
export interface ExpandableProps extends DetailsHTMLAttributes<HTMLDetailsElement> {
|
|
3
3
|
/** Main content inside the component, only visible when it is open. It can be any valid JSX or string. */
|
|
4
4
|
children: React.ReactNode;
|
|
5
5
|
/** **(Optional)** Specify additional CSS classes to be applied to the component. */
|
|
6
6
|
className?: string;
|
|
7
|
+
/** **(Optional)** Specify a custom React ref for this component. */
|
|
8
|
+
ref?: Ref<HTMLDetailsElement>;
|
|
7
9
|
}
|
|
8
10
|
interface ExpandableSummaryProps extends HTMLAttributes<HTMLElement> {
|
|
9
11
|
/** **(Optional)** Content inside the Summary. */
|
|
@@ -12,7 +14,7 @@ interface ExpandableSummaryProps extends HTMLAttributes<HTMLElement> {
|
|
|
12
14
|
className?: string;
|
|
13
15
|
}
|
|
14
16
|
export declare const Expandable: {
|
|
15
|
-
({ children, className, ...props }: ExpandableProps): JSX.Element;
|
|
17
|
+
({ children, className, ref, ...props }: ExpandableProps): JSX.Element;
|
|
16
18
|
Summary: {
|
|
17
19
|
({ children, className, ...props }: ExpandableSummaryProps): import("react/jsx-runtime").JSX.Element;
|
|
18
20
|
displayName: string;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { jsxs, jsx } from 'react/jsx-runtime';
|
|
2
2
|
import { clsx } from 'clsx';
|
|
3
|
+
import { useSlots } from '../../hooks/useSlots.js';
|
|
3
4
|
import { hasUserBg, bgClassToColor } from '../../utils/index.js';
|
|
4
|
-
import { getSlots } from '../../utils/slots.js';
|
|
5
5
|
import 'react';
|
|
6
6
|
import { ChevronDownIcon } from '../Icon/ChevronDownIcon.js';
|
|
7
7
|
|
|
@@ -9,8 +9,8 @@ const componentSlots = {
|
|
|
9
9
|
Children: null,
|
|
10
10
|
ExpandableSummary: null,
|
|
11
11
|
};
|
|
12
|
-
const Expandable = ({ children, className, ...props }) => {
|
|
13
|
-
const slots =
|
|
12
|
+
const Expandable = ({ children, className, ref, ...props }) => {
|
|
13
|
+
const slots = useSlots(componentSlots, children);
|
|
14
14
|
const componentProps = {
|
|
15
15
|
className: clsx("coop-expandable", !hasUserBg(className) && "bg-tint-grey", className),
|
|
16
16
|
...props,
|
|
@@ -18,7 +18,7 @@ const Expandable = ({ children, className, ...props }) => {
|
|
|
18
18
|
componentProps.style = {
|
|
19
19
|
"--bg": `var(--color-${bgClassToColor(componentProps.className)})`,
|
|
20
20
|
};
|
|
21
|
-
return (jsxs("details", { ...componentProps, children: [slots.ExpandableSummary, jsx("div", { className: "coop-expandable--content", children: slots.Children })] }));
|
|
21
|
+
return (jsxs("details", { ...componentProps, ref: ref, children: [slots.ExpandableSummary, jsx("div", { className: "coop-expandable--content", children: slots.Children })] }));
|
|
22
22
|
};
|
|
23
23
|
const ExpandableSummary = ({ children, className, ...props }) => {
|
|
24
24
|
return (jsxs("summary", { ...props, className: className, children: [children, jsx(ChevronDownIcon, { className: "coop-expandable--icon", stroke: "currentColor", strokeWidth: 2, width: "12" })] }));
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { HTMLAttributes, JSX } from "react";
|
|
1
|
+
import type { HTMLAttributes, JSX, Ref } from "react";
|
|
2
2
|
import React from "react";
|
|
3
3
|
import { type ErrorProps } from "../FieldMarkers/Error";
|
|
4
4
|
import { type HintProps } from "../FieldMarkers/Hint";
|
|
@@ -16,6 +16,8 @@ interface FieldProps extends HTMLAttributes<HTMLDivElement> {
|
|
|
16
16
|
error?: boolean;
|
|
17
17
|
/** **(Optional)** Specify whether the Field should show the left-hand error bar if it is in an error state. */
|
|
18
18
|
hideErrorBar?: boolean;
|
|
19
|
+
/** **(Optional)** Specify a custom React ref for this component. */
|
|
20
|
+
ref?: Ref<HTMLDivElement>;
|
|
19
21
|
}
|
|
20
22
|
interface ControlProps extends HTMLAttributes<HTMLDivElement> {
|
|
21
23
|
/** **(Optional)** Elements inside the form control. */
|
|
@@ -27,7 +29,7 @@ export declare const FieldControl: {
|
|
|
27
29
|
({ children, className, ...props }: ControlProps): JSX.Element;
|
|
28
30
|
displayName: string;
|
|
29
31
|
};
|
|
30
|
-
export declare const Field: (({ boxed, children, className, error, hideErrorBar, ...props }: FieldProps) => import("react/jsx-runtime").JSX.Element) & {
|
|
32
|
+
export declare const Field: (({ boxed, children, className, error, hideErrorBar, ref, ...props }: FieldProps) => import("react/jsx-runtime").JSX.Element) & {
|
|
31
33
|
Control: {
|
|
32
34
|
({ children, className, ...props }: ControlProps): JSX.Element;
|
|
33
35
|
displayName: string;
|
|
@@ -2,7 +2,7 @@ import { jsx, jsxs } from 'react/jsx-runtime';
|
|
|
2
2
|
import clsx from 'clsx';
|
|
3
3
|
import React from 'react';
|
|
4
4
|
import { useId } from '../../hooks/useId.js';
|
|
5
|
-
import {
|
|
5
|
+
import { useSlots } from '../../hooks/useSlots.js';
|
|
6
6
|
import { Error } from '../FieldMarkers/Error.js';
|
|
7
7
|
import { Hint } from '../FieldMarkers/Hint.js';
|
|
8
8
|
import { Label } from '../FieldMarkers/Label.js';
|
|
@@ -14,21 +14,20 @@ const componentSlots = {
|
|
|
14
14
|
FieldError: null,
|
|
15
15
|
FieldHint: null,
|
|
16
16
|
FieldLabel: null,
|
|
17
|
-
|
|
17
|
+
Radio: null,
|
|
18
18
|
Textarea: null,
|
|
19
19
|
TextInput: null,
|
|
20
20
|
};
|
|
21
21
|
const standardFields = ["Children", "FieldError", "FieldHint", "FieldLabel"];
|
|
22
|
-
const inlineFields = ["Checkbox", "
|
|
23
|
-
const Root = ({ boxed = false, children, className, error = false, hideErrorBar = false, ...props }) => {
|
|
22
|
+
const inlineFields = ["Checkbox", "Radio"];
|
|
23
|
+
const Root = ({ boxed = false, children, className, error = false, hideErrorBar = false, ref, ...props }) => {
|
|
24
24
|
var _a, _b, _c, _d, _e, _f;
|
|
25
|
-
const slots =
|
|
25
|
+
const slots = { ...useSlots(componentSlots, children) };
|
|
26
26
|
const slotsArray = Object.entries(slots);
|
|
27
|
-
const uid = useId();
|
|
28
27
|
const isInlineControl = slotsArray.some((s) => s[1] !== null && inlineFields.includes(s[0]));
|
|
29
28
|
const hasFieldMarkers = !!((_b = (_a = slots.FieldLabel) !== null && _a !== void 0 ? _a : slots.FieldError) !== null && _b !== void 0 ? _b : slots.FieldHint);
|
|
30
29
|
const [, control] = (_c = slotsArray.find((s) => (!standardFields.includes(s[0]) && s[1] !== null ? s : null))) !== null && _c !== void 0 ? _c : [];
|
|
31
|
-
let controlId =
|
|
30
|
+
let controlId = useId();
|
|
32
31
|
let controlDisabled = false;
|
|
33
32
|
if (control) {
|
|
34
33
|
if (typeof control === "object" && "props" in control) {
|
|
@@ -53,7 +52,7 @@ const Root = ({ boxed = false, children, className, error = false, hideErrorBar
|
|
|
53
52
|
"data-error": error || undefined,
|
|
54
53
|
"data-hide-error": hideErrorBar || undefined,
|
|
55
54
|
};
|
|
56
|
-
return (jsxs("div", { ...componentProps, children: [!isInlineControl && hasFieldMarkers && (jsxs("div", { className: "coop-field-markers", children: [slots.FieldLabel, slots.FieldHint, slots.FieldError] })), slots.Control && (jsxs("div", { className: "coop-field-control", children: [slots.Control, isInlineControl && hasFieldMarkers && (jsxs("div", { className: "coop-field-markers", children: [slots.FieldLabel, slots.FieldHint, slots.FieldError] }))] })), slots.Children] }));
|
|
55
|
+
return (jsxs("div", { ...componentProps, ref: ref, children: [!isInlineControl && hasFieldMarkers && (jsxs("div", { className: "coop-field-markers", children: [slots.FieldLabel, slots.FieldHint, slots.FieldError] })), slots.Control && (jsxs("div", { className: "coop-field-control", children: [slots.Control, isInlineControl && hasFieldMarkers && (jsxs("div", { className: "coop-field-markers", children: [slots.FieldLabel, slots.FieldHint, slots.FieldError] }))] })), slots.Children] }));
|
|
57
56
|
};
|
|
58
57
|
const FieldControl = ({ children, className, ...props }) => {
|
|
59
58
|
return (jsx("div", { className: clsx("coop-field-control ", className), ...props, children: children }));
|
|
@@ -1,9 +1,11 @@
|
|
|
1
|
-
import type { HTMLAttributes, JSX, ReactNode } from "react";
|
|
1
|
+
import type { HTMLAttributes, JSX, ReactNode, Ref } from "react";
|
|
2
2
|
export interface ErrorProps extends HTMLAttributes<HTMLSpanElement> {
|
|
3
3
|
/** **(Optional)** Error text for the form element. Accepts any valid JSX or string. */
|
|
4
4
|
children?: string | ReactNode;
|
|
5
5
|
/** **(Optional)** Specify additional CSS classes to be applied to the component. */
|
|
6
6
|
className?: string;
|
|
7
|
+
/** **(Optional)** Specify a custom React ref for this component. */
|
|
8
|
+
ref?: Ref<HTMLSpanElement>;
|
|
7
9
|
}
|
|
8
|
-
export declare const Error: ({ children, className, ...props }: ErrorProps) => JSX.Element;
|
|
10
|
+
export declare const Error: ({ children, className, ref, ...props }: ErrorProps) => JSX.Element;
|
|
9
11
|
export default Error;
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { jsx } from 'react/jsx-runtime';
|
|
2
2
|
import clsx from 'clsx';
|
|
3
3
|
|
|
4
|
-
const Error = ({ children, className, ...props }) => {
|
|
4
|
+
const Error = ({ children, className, ref, ...props }) => {
|
|
5
5
|
const componentProps = {
|
|
6
6
|
className: clsx("coop-field-error ", className),
|
|
7
7
|
...props,
|
|
8
8
|
};
|
|
9
|
-
return jsx("span", { ...componentProps, children: children });
|
|
9
|
+
return (jsx("span", { ...componentProps, ref: ref, children: children }));
|
|
10
10
|
};
|
|
11
11
|
|
|
12
12
|
export { Error, Error as default };
|
|
@@ -1,9 +1,11 @@
|
|
|
1
|
-
import type { HTMLAttributes, JSX, ReactNode } from "react";
|
|
2
|
-
export interface HintProps extends HTMLAttributes<
|
|
1
|
+
import type { HTMLAttributes, JSX, ReactNode, Ref } from "react";
|
|
2
|
+
export interface HintProps extends HTMLAttributes<HTMLDivElement> {
|
|
3
3
|
/** **(Optional)** Hint text for the form element. Accepts any valid JSX or string. */
|
|
4
4
|
children?: string | ReactNode;
|
|
5
5
|
/** **(Optional)** Specify additional CSS classes to be applied to the component. */
|
|
6
6
|
className?: string;
|
|
7
|
+
/** **(Optional)** Specify a custom React ref for this component. */
|
|
8
|
+
ref?: Ref<HTMLDivElement>;
|
|
7
9
|
}
|
|
8
|
-
export declare const Hint: ({ children, className, ...props }: HintProps) => JSX.Element | null;
|
|
10
|
+
export declare const Hint: ({ children, className, ref, ...props }: HintProps) => JSX.Element | null;
|
|
9
11
|
export default Hint;
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { jsx } from 'react/jsx-runtime';
|
|
2
2
|
import clsx from 'clsx';
|
|
3
3
|
|
|
4
|
-
const Hint = ({ children, className, ...props }) => {
|
|
4
|
+
const Hint = ({ children, className, ref, ...props }) => {
|
|
5
5
|
const componentProps = {
|
|
6
6
|
className: clsx("coop-field-hint ", className),
|
|
7
7
|
...props,
|
|
8
8
|
};
|
|
9
|
-
return
|
|
9
|
+
return (jsx("div", { ...componentProps, ref: ref, children: children }));
|
|
10
10
|
};
|
|
11
11
|
|
|
12
12
|
export { Hint, Hint as default };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { LabelHTMLAttributes } from "react";
|
|
1
|
+
import { LabelHTMLAttributes, Ref } from "react";
|
|
2
2
|
export interface LabelProps extends LabelHTMLAttributes<HTMLLabelElement> {
|
|
3
3
|
/** **(Optional)** Main label for the form element. Accepts any valid JSX or string. */
|
|
4
4
|
children?: string | React.ReactNode;
|
|
@@ -6,6 +6,8 @@ export interface LabelProps extends LabelHTMLAttributes<HTMLLabelElement> {
|
|
|
6
6
|
className?: string;
|
|
7
7
|
/** **(Optional)** Specify whether the label is visible for humans or only for screen readers. */
|
|
8
8
|
isVisible?: boolean;
|
|
9
|
+
/** **(Optional)** Specify a custom React ref for this component. */
|
|
10
|
+
ref?: Ref<HTMLLabelElement>;
|
|
9
11
|
}
|
|
10
|
-
export declare const Label: ({ children, className, isVisible, ...props }: LabelProps) => import("react/jsx-runtime").JSX.Element;
|
|
12
|
+
export declare const Label: ({ children, className, isVisible, ref, ...props }: LabelProps) => import("react/jsx-runtime").JSX.Element;
|
|
11
13
|
export default Label;
|
|
@@ -1,8 +1,12 @@
|
|
|
1
1
|
import { jsx } from 'react/jsx-runtime';
|
|
2
2
|
import clsx from 'clsx';
|
|
3
3
|
|
|
4
|
-
const Label = ({ children, className, isVisible = true, ...props }) => {
|
|
5
|
-
|
|
4
|
+
const Label = ({ children, className, isVisible = true, ref, ...props }) => {
|
|
5
|
+
const componentProps = {
|
|
6
|
+
className: clsx("coop-field-label", !isVisible && "sr-only", className),
|
|
7
|
+
...props,
|
|
8
|
+
};
|
|
9
|
+
return (jsx("label", { ...componentProps, ref: ref, children: jsx("span", { children: children }) }));
|
|
6
10
|
};
|
|
7
11
|
|
|
8
12
|
export { Label, Label as default };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { HTMLAttributes } from "react";
|
|
1
|
+
import { HTMLAttributes, Ref } from "react";
|
|
2
2
|
export interface LegendProps extends HTMLAttributes<HTMLLegendElement> {
|
|
3
3
|
/** **(Optional)** Main legend for the fieldset. Accepts any valid JSX or string. */
|
|
4
4
|
children?: string | React.ReactNode;
|
|
@@ -6,6 +6,8 @@ export interface LegendProps extends HTMLAttributes<HTMLLegendElement> {
|
|
|
6
6
|
className?: string;
|
|
7
7
|
/** **(Optional)** Specify whether the legend should be visible to humans or screen readers. */
|
|
8
8
|
isVisible?: boolean;
|
|
9
|
+
/** **(Optional)** Specify a custom React ref for this component. */
|
|
10
|
+
ref?: Ref<HTMLLegendElement>;
|
|
9
11
|
}
|
|
10
|
-
export declare const Legend: ({ children, className, isVisible, ...props }: LegendProps) => import("react/jsx-runtime").JSX.Element;
|
|
12
|
+
export declare const Legend: ({ children, className, isVisible, ref, ...props }: LegendProps) => import("react/jsx-runtime").JSX.Element;
|
|
11
13
|
export default Legend;
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import { jsxs, Fragment, jsx } from 'react/jsx-runtime';
|
|
2
2
|
import clsx from 'clsx';
|
|
3
3
|
|
|
4
|
-
const Legend = ({ children, className, isVisible = true, ...props }) => {
|
|
4
|
+
const Legend = ({ children, className, isVisible = true, ref, ...props }) => {
|
|
5
5
|
const componentProps = {
|
|
6
6
|
"aria-hidden": true,
|
|
7
7
|
className: clsx("coop-field-label", !isVisible && "sr-only", className),
|
|
8
8
|
...props,
|
|
9
9
|
};
|
|
10
|
-
return (jsxs(Fragment, { children: [jsx("legend", { className: "sr-only", children: children }), isVisible && jsx("div", { ...componentProps, children: children })] }));
|
|
10
|
+
return (jsxs(Fragment, { children: [jsx("legend", { className: "sr-only", children: children }), isVisible && (jsx("div", { ...componentProps, ref: ref, children: children }))] }));
|
|
11
11
|
};
|
|
12
12
|
|
|
13
13
|
export { Legend, Legend as default };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { type FieldsetHTMLAttributes, type JSX } from "react";
|
|
1
|
+
import { type FieldsetHTMLAttributes, type JSX, Ref } from "react";
|
|
2
2
|
import { StandardSizes } from "../../../src/types";
|
|
3
3
|
import { type ErrorProps } from "../FieldMarkers/Error";
|
|
4
4
|
import { type HintProps } from "../FieldMarkers/Hint";
|
|
@@ -16,6 +16,8 @@ export interface FieldsetProps extends FieldsetHTMLAttributes<HTMLFieldSetElemen
|
|
|
16
16
|
error?: boolean;
|
|
17
17
|
/** **(Optional)** Specify whether the Fieldset should show the left-hand error bar if it is in an error state. */
|
|
18
18
|
hideErrorBar?: boolean;
|
|
19
|
+
/** **(Optional)** Specify a custom React ref for this component. */
|
|
20
|
+
ref?: Ref<HTMLFieldSetElement>;
|
|
19
21
|
/** **(Optional)** Specify the size of the Fieldset and all its descendents. */
|
|
20
22
|
size?: StandardSizes;
|
|
21
23
|
}
|
|
@@ -33,7 +35,7 @@ export declare const FieldsetFields: {
|
|
|
33
35
|
({ boxed, children, className, orientation, ...props }: FieldsetFieldsProps): JSX.Element;
|
|
34
36
|
displayName: string;
|
|
35
37
|
};
|
|
36
|
-
export declare const Fieldset: (({ children, className, disabled, error, hideErrorBar, size, ...props }: FieldsetProps) => JSX.Element) & {
|
|
38
|
+
export declare const Fieldset: (({ children, className, disabled, error, hideErrorBar, ref, size, ...props }: FieldsetProps) => JSX.Element) & {
|
|
37
39
|
Error: {
|
|
38
40
|
(props: ErrorProps): import("react/jsx-runtime").JSX.Element;
|
|
39
41
|
displayName: string;
|
|
@@ -4,19 +4,17 @@ import { Error } from '../FieldMarkers/Error.js';
|
|
|
4
4
|
import { Hint } from '../FieldMarkers/Hint.js';
|
|
5
5
|
import { Legend } from '../FieldMarkers/Legend.js';
|
|
6
6
|
|
|
7
|
-
const Root = ({ children, className, disabled, error = false, hideErrorBar = false, size = "md", ...props }) => {
|
|
7
|
+
const Root = ({ children, className, disabled, error = false, hideErrorBar = false, ref, size = "md", ...props }) => {
|
|
8
8
|
const componentProps = {
|
|
9
9
|
"aria-disabled": disabled,
|
|
10
10
|
className: clsx("coop-fieldset", className),
|
|
11
11
|
"data-error": error || undefined,
|
|
12
|
-
//"data-variant": variant !== "default" ? variant : undefined,
|
|
13
12
|
"data-hide-error": hideErrorBar || undefined,
|
|
14
|
-
// "data-orientation": orientation !== "vertical" ? orientation : undefined,
|
|
15
13
|
"data-size": size.length && size !== "md" ? size : undefined,
|
|
16
14
|
disabled,
|
|
17
15
|
...props,
|
|
18
16
|
};
|
|
19
|
-
return jsx("fieldset", { ...componentProps, children: children });
|
|
17
|
+
return (jsx("fieldset", { ...componentProps, ref: ref, children: children }));
|
|
20
18
|
};
|
|
21
19
|
const FieldsetFields = ({ boxed = false, children, className, orientation = "vertical", ...props }) => {
|
|
22
20
|
const componentProps = {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { JSX, ReactNode, SVGProps } from "react";
|
|
1
|
+
import type { JSX, ReactNode, Ref, SVGProps } from "react";
|
|
2
2
|
import { Black, BrandBlue, Darks, Lights, OfferRed, Tints, White } from "../../types/colors";
|
|
3
3
|
export interface FlourishProps extends SVGProps<SVGSVGElement> {
|
|
4
4
|
/** Specify the text to be highlighted by the Flourish. */
|
|
@@ -7,6 +7,8 @@ export interface FlourishProps extends SVGProps<SVGSVGElement> {
|
|
|
7
7
|
className?: string;
|
|
8
8
|
/** **(Optional)** Specify the Flourish color. */
|
|
9
9
|
fill?: Darks | Lights | Tints | OfferRed | BrandBlue | White | Black;
|
|
10
|
+
/** **(Optional)** Specify a custom React ref for this component. */
|
|
11
|
+
ref?: Ref<SVGSVGElement>;
|
|
10
12
|
}
|
|
11
|
-
export declare const Flourish: ({ children, className, fill, ...props }: FlourishProps) => JSX.Element;
|
|
13
|
+
export declare const Flourish: ({ children, className, fill, ref, ...props }: FlourishProps) => JSX.Element;
|
|
12
14
|
export default Flourish;
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import { jsxs, jsx } from 'react/jsx-runtime';
|
|
2
2
|
import clsx from 'clsx';
|
|
3
3
|
|
|
4
|
-
const Flourish = ({ children, className, fill = "brand-blue", ...props }) => {
|
|
4
|
+
const Flourish = ({ children, className, fill = "brand-blue", ref, ...props }) => {
|
|
5
5
|
const componentProps = {
|
|
6
6
|
className: clsx("coop-flourish ", className),
|
|
7
7
|
fill: `var(--color-${fill})`,
|
|
8
8
|
...props,
|
|
9
9
|
};
|
|
10
|
-
return (jsxs("span", { style: { position: "relative" }, children: [children, jsx("svg", { ...componentProps, viewBox: "0 0 276 10", children: jsx("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" }) })] }));
|
|
10
|
+
return (jsxs("span", { style: { position: "relative" }, children: [children, jsx("svg", { ...componentProps, ref: ref, viewBox: "0 0 276 10", children: jsx("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" }) })] }));
|
|
11
11
|
};
|
|
12
12
|
|
|
13
13
|
export { Flourish, Flourish as default };
|
|
@@ -2,5 +2,5 @@ import { type SVGProps } from "react";
|
|
|
2
2
|
interface IconProps extends SVGProps<SVGSVGElement> {
|
|
3
3
|
alt?: string;
|
|
4
4
|
}
|
|
5
|
-
export declare const AddIcon: ({ alt, className, fill, ...props }: IconProps) => import("react/jsx-runtime").JSX.Element;
|
|
5
|
+
export declare const AddIcon: ({ alt, className, fill, id, ref, ...props }: IconProps) => import("react/jsx-runtime").JSX.Element;
|
|
6
6
|
export {};
|
|
@@ -1,19 +1,20 @@
|
|
|
1
1
|
import { jsxs, jsx } from 'react/jsx-runtime';
|
|
2
2
|
import clsx from 'clsx';
|
|
3
|
-
import { useId } from '
|
|
3
|
+
import { useId } from '../../hooks/useId.js';
|
|
4
4
|
|
|
5
|
-
const AddIcon = ({ alt, className, fill, ...props }) => {
|
|
6
|
-
const
|
|
5
|
+
const AddIcon = ({ alt, className, fill, id, ref, ...props }) => {
|
|
6
|
+
const uid = useId(id);
|
|
7
7
|
const componentProps = {
|
|
8
|
-
"aria-labelledby": alt ?
|
|
8
|
+
"aria-labelledby": alt ? uid + "-title" : undefined,
|
|
9
9
|
className: clsx("coop-icon", className),
|
|
10
10
|
"data-icon": "add",
|
|
11
11
|
fill: fill !== null && fill !== void 0 ? fill : "none",
|
|
12
|
+
id: uid,
|
|
12
13
|
role: alt ? "img" : undefined,
|
|
13
14
|
viewBox: "0 0 32 32",
|
|
14
15
|
...props,
|
|
15
16
|
};
|
|
16
|
-
return (jsxs("svg", { ...componentProps, children: [alt ? jsx("title", { id:
|
|
17
|
+
return (jsxs("svg", { ...componentProps, ref: ref, children: [alt ? jsx("title", { id: uid + "-title", children: alt }) : null, jsx("path", { 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", fill: fill !== null && fill !== void 0 ? fill : "currentColor" }), jsx("path", { d: "M16.72 24.7a1 1 0 0 1-.72.3 1 1 0 0 1-1-1V8a1 1 0 0 1 2 0v16a1 1 0 0 1-.28.7", fill: fill !== null && fill !== void 0 ? fill : "currentColor" })] }));
|
|
17
18
|
};
|
|
18
19
|
|
|
19
20
|
export { AddIcon };
|
|
@@ -2,5 +2,5 @@ import { type SVGProps } from "react";
|
|
|
2
2
|
interface IconProps extends SVGProps<SVGSVGElement> {
|
|
3
3
|
alt?: string;
|
|
4
4
|
}
|
|
5
|
-
export declare const ArrowDownIcon: ({ alt, className, fill, ...props }: IconProps) => import("react/jsx-runtime").JSX.Element;
|
|
5
|
+
export declare const ArrowDownIcon: ({ alt, className, fill, id, ref, ...props }: IconProps) => import("react/jsx-runtime").JSX.Element;
|
|
6
6
|
export {};
|