@coopdigital/react 0.35.0 → 0.37.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/Card/Card.d.ts +3 -3
- package/dist/components/Card/Card.js +2 -2
- package/dist/components/Checkbox/Checkbox.d.ts +1 -3
- package/dist/components/Checkbox/Checkbox.js +1 -4
- package/dist/components/Checkbox/CheckboxGroup.d.ts +3 -1
- package/dist/components/Checkbox/CheckboxGroup.js +3 -2
- package/dist/components/Checkbox/index.d.ts +2 -1
- package/dist/components/RadioButton/RadioButton.d.ts +37 -0
- package/dist/components/RadioButton/RadioButton.js +25 -0
- package/dist/components/RadioButton/RadioButtonGroup.d.ts +30 -0
- package/dist/components/RadioButton/RadioButtonGroup.js +21 -0
- package/dist/components/RadioButton/index.d.ts +5 -0
- package/dist/components/Tag/Tag.d.ts +3 -1
- package/dist/components/Tag/Tag.js +2 -1
- package/dist/components/Tag/index.js +5 -0
- package/dist/index.d.ts +1 -1
- package/dist/index.js +2 -0
- package/package.json +9 -9
- package/src/components/Card/Card.tsx +4 -4
- package/src/components/Checkbox/Checkbox.tsx +0 -6
- package/src/components/Checkbox/CheckboxGroup.tsx +5 -1
- package/src/components/Checkbox/index.ts +2 -1
- package/src/components/RadioButton/RadioButton.tsx +95 -0
- package/src/components/RadioButton/RadioButtonGroup.tsx +71 -0
- package/src/components/RadioButton/index.ts +6 -0
- package/src/components/Tag/Tag.tsx +5 -0
- package/src/index.ts +1 -1
|
@@ -31,8 +31,8 @@ export interface CardProps extends HTMLAttributes<HTMLDivElement> {
|
|
|
31
31
|
label?: string;
|
|
32
32
|
/** **(Optional)** Specify the background color of the Card label. */
|
|
33
33
|
labelBackground?: Lights;
|
|
34
|
-
/** **(Optional)** Specify the
|
|
35
|
-
|
|
34
|
+
/** **(Optional)** Specify the orientation of the Card. */
|
|
35
|
+
orientation?: "vertical" | "horizontal";
|
|
36
36
|
}
|
|
37
|
-
export declare const Card: ({ as, background, badge, badgePosition, chevron, children, className, heading, headingLevel, href, image, imagePosition, label, labelBackground,
|
|
37
|
+
export declare const Card: ({ as, background, badge, badgePosition, chevron, children, className, heading, headingLevel, href, image, imagePosition, label, labelBackground, orientation, ...props }: CardProps) => JSX.Element;
|
|
38
38
|
export default Card;
|
|
@@ -18,7 +18,7 @@ function getCardLinkElement(as, href) {
|
|
|
18
18
|
},
|
|
19
19
|
};
|
|
20
20
|
}
|
|
21
|
-
const Card = ({ as, background = "white", badge, badgePosition = "inset", chevron = false, children, className, heading, headingLevel = "h3", href, image, imagePosition = "left", label = "", labelBackground,
|
|
21
|
+
const Card = ({ as, background = "white", badge, badgePosition = "inset", chevron = false, children, className, heading, headingLevel = "h3", href, image, imagePosition = "left", label = "", labelBackground, orientation = "vertical", ...props }) => {
|
|
22
22
|
const linkElement = getCardLinkElement(as, href);
|
|
23
23
|
const imageProps = {
|
|
24
24
|
crop: "wide",
|
|
@@ -28,7 +28,7 @@ const Card = ({ as, background = "white", badge, badgePosition = "inset", chevro
|
|
|
28
28
|
className: clsx("coop-card", background && bgPropToClass(background, className), className),
|
|
29
29
|
"data-badge-pos": badgePosition,
|
|
30
30
|
"data-image-pos": imagePosition,
|
|
31
|
-
"data-
|
|
31
|
+
"data-orientation": orientation !== "vertical" ? orientation : undefined,
|
|
32
32
|
...props,
|
|
33
33
|
};
|
|
34
34
|
return (jsxs("article", { ...componentProps, children: [image && jsx(Image, { ...imageProps }), badge && jsx("div", { className: "coop-card--badge", children: badge }), jsxs("div", { className: "coop-card--inner", children: [jsxs("div", { className: "coop-card--content", children: [label && (jsx("span", { className: clsx("coop-card--label", labelBackground && bgPropToClass(labelBackground, className)), children: label })), React.createElement(linkElement.element, linkElement.props, React.createElement(headingLevel, { className: "coop-card--heading" }, heading)), children] }), chevron && (jsx("span", { "aria-hidden": "true", className: "coop-card--icon", role: "presentation", children: jsx(ChevronRightIcon, {}) }))] })] }));
|
|
@@ -23,10 +23,8 @@ export interface CheckboxProps extends Omit<InputHTMLAttributes<HTMLInputElement
|
|
|
23
23
|
labelVisible?: boolean;
|
|
24
24
|
/** Specify the Checkbox name. */
|
|
25
25
|
name: string;
|
|
26
|
-
/** **(Optional)** Specify the Checkbox placeholder text. Do not use in place of a form label. */
|
|
27
|
-
placeholder?: string;
|
|
28
26
|
/** **(Optional)** Specify the Checkbox size. */
|
|
29
27
|
size?: StandardSizes;
|
|
30
28
|
}
|
|
31
|
-
export declare const Checkbox: ({
|
|
29
|
+
export declare const Checkbox: ({ className, error, hint, id, label, labelVisible, name, size, ...props }: CheckboxProps) => JSX.Element;
|
|
32
30
|
export default Checkbox;
|
|
@@ -5,18 +5,15 @@ 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 = ({
|
|
9
|
-
var _a;
|
|
8
|
+
const Checkbox = ({ className, error = false, hint, id, label, labelVisible = true, name, size = "md", ...props }) => {
|
|
10
9
|
const internalId = useId();
|
|
11
10
|
id = id !== null && id !== void 0 ? id : internalId;
|
|
12
11
|
const componentProps = {
|
|
13
|
-
"aria-placeholder": (_a = placeholder !== null && placeholder !== void 0 ? placeholder : ariaPlaceholder) !== null && _a !== void 0 ? _a : undefined,
|
|
14
12
|
className: clsx("coop-checkbox", className),
|
|
15
13
|
"data-error": error ? "" : undefined,
|
|
16
14
|
"data-size": size.length && size !== "md" ? size : undefined,
|
|
17
15
|
id,
|
|
18
16
|
name,
|
|
19
|
-
placeholder,
|
|
20
17
|
type: "checkbox",
|
|
21
18
|
...props,
|
|
22
19
|
};
|
|
@@ -19,8 +19,10 @@ export interface CheckboxGroupProps extends FieldsetHTMLAttributes<HTMLFieldSetE
|
|
|
19
19
|
label?: string;
|
|
20
20
|
/** **(Optional)** Specify whether the label should be visible to humans or screen readers. */
|
|
21
21
|
labelVisible?: boolean;
|
|
22
|
+
/** **(Optional)** Specify the CheckboxGroup orientation. */
|
|
23
|
+
orientation?: "horizontal" | "vertical";
|
|
22
24
|
/** **(Optional)** Specify the CheckboxGroup size. */
|
|
23
25
|
size?: StandardSizes;
|
|
24
26
|
}
|
|
25
|
-
export declare const CheckboxGroup: ({ children, className, error, hint, label, labelVisible, size, ...props }: CheckboxGroupProps) => JSX.Element;
|
|
27
|
+
export declare const CheckboxGroup: ({ children, className, error, hint, label, labelVisible, orientation, size, ...props }: CheckboxGroupProps) => JSX.Element;
|
|
26
28
|
export default CheckboxGroup;
|
|
@@ -3,17 +3,18 @@ import { clsx } from '../../node_modules/clsx/dist/clsx.js';
|
|
|
3
3
|
import { FieldError } from '../FieldError/FieldError.js';
|
|
4
4
|
import { FieldHint } from '../FieldHint/FieldHint.js';
|
|
5
5
|
|
|
6
|
-
const CheckboxGroup = ({ children, className, error = false, hint, label, labelVisible = true, size = "md", ...props }) => {
|
|
6
|
+
const CheckboxGroup = ({ children, className, error = false, hint, label, labelVisible = true, orientation = "vertical", size = "md", ...props }) => {
|
|
7
7
|
const componentProps = {
|
|
8
8
|
className: clsx("coop-fieldset", "coop-checkbox-group", className),
|
|
9
9
|
"data-error": error ? "" : undefined,
|
|
10
|
+
"data-orientation": orientation !== "vertical" ? orientation : undefined,
|
|
10
11
|
"data-size": size.length && size !== "md" ? size : undefined,
|
|
11
12
|
...props,
|
|
12
13
|
};
|
|
13
14
|
const legendProps = {
|
|
14
15
|
className: clsx("coop-field-label", !labelVisible && "sr-only"),
|
|
15
16
|
};
|
|
16
|
-
return (jsxs("fieldset", { ...componentProps, children: [label && jsx("legend", { ...legendProps, children: label }), hint && jsx(FieldHint, { children: hint }), typeof error === "object" && (error === null || error === void 0 ? void 0 : error.message) && jsx(FieldError, { children: error.message }), children] }));
|
|
17
|
+
return (jsxs("fieldset", { ...componentProps, children: [label && jsx("legend", { ...legendProps, 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("div", { className: "coop-checkbox-group-options", children: children })] }));
|
|
17
18
|
};
|
|
18
19
|
|
|
19
20
|
export { CheckboxGroup, CheckboxGroup as default };
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { type InputHTMLAttributes, type JSX } from "react";
|
|
2
|
+
import { FormFieldError, StandardSizes } from "src/types";
|
|
3
|
+
import { TagProps } from "../Tag";
|
|
4
|
+
export interface RadioButtonProps extends Omit<InputHTMLAttributes<HTMLInputElement>, "size" | "type"> {
|
|
5
|
+
/** **(Optional)** Specify additional CSS classes to be applied to the component. */
|
|
6
|
+
className?: string;
|
|
7
|
+
/** **(Optional)** Specify the RadioButton error state.
|
|
8
|
+
*
|
|
9
|
+
* 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.
|
|
10
|
+
*/
|
|
11
|
+
error?: FormFieldError;
|
|
12
|
+
/** **(Optional)** Specify the RadioButton hint.
|
|
13
|
+
*
|
|
14
|
+
* This text is rendered under the label to provide further guidance for users.
|
|
15
|
+
*/
|
|
16
|
+
hint?: string;
|
|
17
|
+
/** **(Optional)** Specify the RadioButton id. Will be auto-generated if not set. */
|
|
18
|
+
id?: string;
|
|
19
|
+
/** **(Optional)** Specify the RadioButton label.
|
|
20
|
+
*
|
|
21
|
+
* This property is optional in case you need to render your own label, but all form elements *must* provide a label. */
|
|
22
|
+
label: string;
|
|
23
|
+
/** **(Optional)** Specify whether the label should be visible to humans or screen readers. */
|
|
24
|
+
labelVisible?: boolean;
|
|
25
|
+
/** Specify the RadioButton name. */
|
|
26
|
+
name: string;
|
|
27
|
+
/** **(Optional)** Specify the RadioButton size. */
|
|
28
|
+
size?: StandardSizes;
|
|
29
|
+
/** **(Optional)** Specify the RadioButton tag text. */
|
|
30
|
+
tag?: string;
|
|
31
|
+
/** **(Optional)** Specify the RadioButton tag background color. */
|
|
32
|
+
tagBackground?: TagProps["background"];
|
|
33
|
+
/** **(Optional)** Specify the RadioButton variant. */
|
|
34
|
+
variant?: "default" | "boxed";
|
|
35
|
+
}
|
|
36
|
+
export declare const RadioButton: ({ className, error, hint, id, label, labelVisible, name, size, tag, tagBackground, variant, ...props }: RadioButtonProps) => JSX.Element;
|
|
37
|
+
export default RadioButton;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { jsxs, jsx } from 'react/jsx-runtime';
|
|
2
|
+
import { clsx } from '../../node_modules/clsx/dist/clsx.js';
|
|
3
|
+
import { useId } from 'react';
|
|
4
|
+
import { FieldError } from '../FieldError/FieldError.js';
|
|
5
|
+
import { FieldHint } from '../FieldHint/FieldHint.js';
|
|
6
|
+
import { FieldLabel } from '../FieldLabel/FieldLabel.js';
|
|
7
|
+
import { Tag } from '../Tag/Tag.js';
|
|
8
|
+
|
|
9
|
+
const RadioButton = ({ className, error = false, hint, id, label, labelVisible = true, name, size = "md", tag, tagBackground, variant = "default", ...props }) => {
|
|
10
|
+
const internalId = useId();
|
|
11
|
+
id = id !== null && id !== void 0 ? id : internalId;
|
|
12
|
+
const componentProps = {
|
|
13
|
+
className: clsx("coop-radio-button", className),
|
|
14
|
+
"data-error": error ? "" : undefined,
|
|
15
|
+
"data-size": size.length && size !== "md" ? size : undefined,
|
|
16
|
+
"data-variant": variant !== "default" ? variant : undefined,
|
|
17
|
+
id,
|
|
18
|
+
name,
|
|
19
|
+
type: "radio",
|
|
20
|
+
...props,
|
|
21
|
+
};
|
|
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
|
+
};
|
|
24
|
+
|
|
25
|
+
export { RadioButton, RadioButton as default };
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import type { FieldsetHTMLAttributes, JSX } from "react";
|
|
2
|
+
import { FormFieldError, StandardSizes } from "../../types";
|
|
3
|
+
export interface RadioButtonGroupProps extends FieldsetHTMLAttributes<HTMLFieldSetElement> {
|
|
4
|
+
/** **(Optional)** Main content inside the component. It can be any valid JSX or string. */
|
|
5
|
+
children?: React.ReactNode;
|
|
6
|
+
/** **(Optional)** Specify additional CSS classes to be applied to the component. */
|
|
7
|
+
className?: string;
|
|
8
|
+
/** **(Optional)** Specify the RadioButtonGroup error state.
|
|
9
|
+
*
|
|
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.
|
|
11
|
+
*/
|
|
12
|
+
error?: FormFieldError;
|
|
13
|
+
/** **(Optional)** Specify the RadioButtonGroup hint.
|
|
14
|
+
*
|
|
15
|
+
* This text is rendered under the label to provide further guidance for users.
|
|
16
|
+
*/
|
|
17
|
+
hint?: string;
|
|
18
|
+
/** **(Optional)** Specify the label for the RadioButtonGroup. This will be rendered as a fieldset legend. */
|
|
19
|
+
label?: string;
|
|
20
|
+
/** **(Optional)** Specify whether the label should be visible to humans or screen readers. */
|
|
21
|
+
labelVisible?: boolean;
|
|
22
|
+
/** **(Optional)** Specify the RadioButtonGroup orientation. */
|
|
23
|
+
orientation?: "horizontal" | "vertical";
|
|
24
|
+
/** **(Optional)** Specify the RadioButtonGroup size. */
|
|
25
|
+
size?: StandardSizes;
|
|
26
|
+
/** **(Optional)** Specify the RadioButtonGroup variant. */
|
|
27
|
+
variant?: "default" | "boxed";
|
|
28
|
+
}
|
|
29
|
+
export declare const RadioButtonGroup: ({ children, className, error, hint, label, labelVisible, orientation, size, variant, ...props }: RadioButtonGroupProps) => JSX.Element;
|
|
30
|
+
export default RadioButtonGroup;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { jsxs, jsx } from 'react/jsx-runtime';
|
|
2
|
+
import { clsx } from '../../node_modules/clsx/dist/clsx.js';
|
|
3
|
+
import { FieldError } from '../FieldError/FieldError.js';
|
|
4
|
+
import { FieldHint } from '../FieldHint/FieldHint.js';
|
|
5
|
+
|
|
6
|
+
const RadioButtonGroup = ({ children, className, error = false, hint, label, labelVisible = true, orientation = "vertical", size = "md", variant = "default", ...props }) => {
|
|
7
|
+
const componentProps = {
|
|
8
|
+
className: clsx("coop-fieldset", "coop-radio-button-group", className),
|
|
9
|
+
"data-error": error ? "" : undefined,
|
|
10
|
+
"data-orientation": orientation !== "vertical" ? orientation : undefined,
|
|
11
|
+
"data-size": size.length && size !== "md" ? size : undefined,
|
|
12
|
+
"data-variant": variant !== "default" ? variant : undefined,
|
|
13
|
+
...props,
|
|
14
|
+
};
|
|
15
|
+
const legendProps = {
|
|
16
|
+
className: clsx("coop-field-label", !labelVisible && "sr-only"),
|
|
17
|
+
};
|
|
18
|
+
return (jsxs("fieldset", { ...componentProps, children: [label && jsx("legend", { ...legendProps, 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("div", { className: "coop-radio-button-group-options", children: children })] }));
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
export { RadioButtonGroup, RadioButtonGroup as default };
|
|
@@ -12,6 +12,8 @@ export interface TagProps extends HTMLAttributes<HTMLAnchorElement> {
|
|
|
12
12
|
className?: string;
|
|
13
13
|
/** **(Optional)** Specify the URL that the Tag component will link to when clicked. */
|
|
14
14
|
href?: string;
|
|
15
|
+
/** **(Optional)** Specify the Tag size. */
|
|
16
|
+
size?: "sm" | "md";
|
|
15
17
|
}
|
|
16
|
-
export declare const Tag: ({ as, background, children, className, href, ...props }: TagProps) => JSX.Element;
|
|
18
|
+
export declare const Tag: ({ as, background, children, className, href, size, ...props }: TagProps) => JSX.Element;
|
|
17
19
|
export default Tag;
|
|
@@ -2,10 +2,11 @@ import { clsx } from '../../node_modules/clsx/dist/clsx.js';
|
|
|
2
2
|
import React from 'react';
|
|
3
3
|
import { bgPropToClass } from '../../utils/index.js';
|
|
4
4
|
|
|
5
|
-
const Tag = ({ as, background = "tint-grey", children, className, href, ...props }) => {
|
|
5
|
+
const Tag = ({ as, background = "tint-grey", children, className, href, size = "md", ...props }) => {
|
|
6
6
|
let element = href ? "a" : "span";
|
|
7
7
|
const componentProps = {
|
|
8
8
|
className: clsx("coop-tag", bgPropToClass(background, className), className),
|
|
9
|
+
"data-size": size.length && size !== "md" ? size : undefined,
|
|
9
10
|
href,
|
|
10
11
|
...props,
|
|
11
12
|
};
|
package/dist/index.d.ts
CHANGED
|
@@ -3,7 +3,6 @@ export * from "./components/Author";
|
|
|
3
3
|
export * from "./components/Button";
|
|
4
4
|
export * from "./components/Card";
|
|
5
5
|
export * from "./components/Checkbox";
|
|
6
|
-
export * from "./components/Checkbox/CheckboxGroup";
|
|
7
6
|
export * from "./components/Expandable";
|
|
8
7
|
export * from "./components/Field";
|
|
9
8
|
export * from "./components/FieldError";
|
|
@@ -12,6 +11,7 @@ export * from "./components/FieldLabel";
|
|
|
12
11
|
export * from "./components/Flourish";
|
|
13
12
|
export * from "./components/Image";
|
|
14
13
|
export * from "./components/Pill";
|
|
14
|
+
export * from "./components/RadioButton";
|
|
15
15
|
export * from "./components/RootSVG";
|
|
16
16
|
export * from "./components/SearchBox";
|
|
17
17
|
export * from "./components/Signpost";
|
package/dist/index.js
CHANGED
|
@@ -12,6 +12,8 @@ export { FieldLabel } from './components/FieldLabel/FieldLabel.js';
|
|
|
12
12
|
export { Flourish } from './components/Flourish/Flourish.js';
|
|
13
13
|
export { Image } from './components/Image/Image.js';
|
|
14
14
|
export { Pill } from './components/Pill/Pill.js';
|
|
15
|
+
export { RadioButton } from './components/RadioButton/RadioButton.js';
|
|
16
|
+
export { RadioButtonGroup } from './components/RadioButton/RadioButtonGroup.js';
|
|
15
17
|
export { RootSVG } from './components/RootSVG/RootSVG.js';
|
|
16
18
|
export { SearchBox } from './components/SearchBox/SearchBox.js';
|
|
17
19
|
export { Signpost } from './components/Signpost/Signpost.js';
|
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.37.0",
|
|
5
5
|
"private": false,
|
|
6
6
|
"publishConfig": {
|
|
7
7
|
"access": "public"
|
|
@@ -56,11 +56,11 @@
|
|
|
56
56
|
"description": "",
|
|
57
57
|
"devDependencies": {
|
|
58
58
|
"@axe-core/playwright": "^4.10.2",
|
|
59
|
-
"@playwright/test": "^1.55.
|
|
60
|
-
"@storybook/addon-a11y": "^9.1.
|
|
61
|
-
"@storybook/addon-docs": "^9.1.
|
|
62
|
-
"@storybook/addon-onboarding": "^9.1.
|
|
63
|
-
"@storybook/react-vite": "^9.1.
|
|
59
|
+
"@playwright/test": "^1.55.1",
|
|
60
|
+
"@storybook/addon-a11y": "^9.1.8",
|
|
61
|
+
"@storybook/addon-docs": "^9.1.8",
|
|
62
|
+
"@storybook/addon-onboarding": "^9.1.8",
|
|
63
|
+
"@storybook/react-vite": "^9.1.8",
|
|
64
64
|
"@testing-library/jest-dom": "^6.8.0",
|
|
65
65
|
"@testing-library/react": "^16.3.0",
|
|
66
66
|
"@types/react": "^19.1.13",
|
|
@@ -69,7 +69,7 @@
|
|
|
69
69
|
"react": "^19.1.1",
|
|
70
70
|
"react-dom": "^19.1.1",
|
|
71
71
|
"serve": "^14.2.5",
|
|
72
|
-
"storybook": "^9.1.
|
|
72
|
+
"storybook": "^9.1.8"
|
|
73
73
|
},
|
|
74
74
|
"peerDependencies": {
|
|
75
75
|
"clsx": "^2.1.1",
|
|
@@ -80,7 +80,7 @@
|
|
|
80
80
|
"storybook": "$storybook"
|
|
81
81
|
},
|
|
82
82
|
"dependencies": {
|
|
83
|
-
"@coopdigital/styles": "^0.
|
|
83
|
+
"@coopdigital/styles": "^0.32.0"
|
|
84
84
|
},
|
|
85
|
-
"gitHead": "
|
|
85
|
+
"gitHead": "07c3e26f63d0b276cd48f392ec61241f7db7fe84"
|
|
86
86
|
}
|
|
@@ -39,8 +39,8 @@ export interface CardProps extends HTMLAttributes<HTMLDivElement> {
|
|
|
39
39
|
label?: string
|
|
40
40
|
/** **(Optional)** Specify the background color of the Card label. */
|
|
41
41
|
labelBackground?: Lights
|
|
42
|
-
/** **(Optional)** Specify the
|
|
43
|
-
|
|
42
|
+
/** **(Optional)** Specify the orientation of the Card. */
|
|
43
|
+
orientation?: "vertical" | "horizontal"
|
|
44
44
|
}
|
|
45
45
|
|
|
46
46
|
function getCardLinkElement(as: CardProps["as"], href?: string) {
|
|
@@ -74,7 +74,7 @@ export const Card = ({
|
|
|
74
74
|
imagePosition = "left",
|
|
75
75
|
label = "",
|
|
76
76
|
labelBackground,
|
|
77
|
-
|
|
77
|
+
orientation = "vertical",
|
|
78
78
|
...props
|
|
79
79
|
}: CardProps): JSX.Element => {
|
|
80
80
|
const linkElement = getCardLinkElement(as, href)
|
|
@@ -88,7 +88,7 @@ export const Card = ({
|
|
|
88
88
|
className: clsx("coop-card", background && bgPropToClass(background, className), className),
|
|
89
89
|
"data-badge-pos": badgePosition,
|
|
90
90
|
"data-image-pos": imagePosition,
|
|
91
|
-
"data-
|
|
91
|
+
"data-orientation": orientation !== "vertical" ? orientation : undefined,
|
|
92
92
|
...props,
|
|
93
93
|
}
|
|
94
94
|
|
|
@@ -32,14 +32,11 @@ export interface CheckboxProps
|
|
|
32
32
|
labelVisible?: boolean
|
|
33
33
|
/** Specify the Checkbox name. */
|
|
34
34
|
name: string
|
|
35
|
-
/** **(Optional)** Specify the Checkbox placeholder text. Do not use in place of a form label. */
|
|
36
|
-
placeholder?: string
|
|
37
35
|
/** **(Optional)** Specify the Checkbox size. */
|
|
38
36
|
size?: StandardSizes
|
|
39
37
|
}
|
|
40
38
|
|
|
41
39
|
export const Checkbox = ({
|
|
42
|
-
"aria-placeholder": ariaPlaceholder,
|
|
43
40
|
className,
|
|
44
41
|
error = false,
|
|
45
42
|
hint,
|
|
@@ -47,7 +44,6 @@ export const Checkbox = ({
|
|
|
47
44
|
label,
|
|
48
45
|
labelVisible = true,
|
|
49
46
|
name,
|
|
50
|
-
placeholder,
|
|
51
47
|
size = "md",
|
|
52
48
|
...props
|
|
53
49
|
}: CheckboxProps): JSX.Element => {
|
|
@@ -56,13 +52,11 @@ export const Checkbox = ({
|
|
|
56
52
|
id = id ?? internalId
|
|
57
53
|
|
|
58
54
|
const componentProps = {
|
|
59
|
-
"aria-placeholder": placeholder ?? ariaPlaceholder ?? undefined,
|
|
60
55
|
className: clsx("coop-checkbox", className),
|
|
61
56
|
"data-error": error ? "" : undefined,
|
|
62
57
|
"data-size": size.length && size !== "md" ? size : undefined,
|
|
63
58
|
id,
|
|
64
59
|
name,
|
|
65
|
-
placeholder,
|
|
66
60
|
type: "checkbox",
|
|
67
61
|
...props,
|
|
68
62
|
}
|
|
@@ -25,6 +25,8 @@ export interface CheckboxGroupProps extends FieldsetHTMLAttributes<HTMLFieldSetE
|
|
|
25
25
|
label?: string
|
|
26
26
|
/** **(Optional)** Specify whether the label should be visible to humans or screen readers. */
|
|
27
27
|
labelVisible?: boolean
|
|
28
|
+
/** **(Optional)** Specify the CheckboxGroup orientation. */
|
|
29
|
+
orientation?: "horizontal" | "vertical"
|
|
28
30
|
/** **(Optional)** Specify the CheckboxGroup size. */
|
|
29
31
|
size?: StandardSizes
|
|
30
32
|
}
|
|
@@ -36,12 +38,14 @@ export const CheckboxGroup = ({
|
|
|
36
38
|
hint,
|
|
37
39
|
label,
|
|
38
40
|
labelVisible = true,
|
|
41
|
+
orientation = "vertical",
|
|
39
42
|
size = "md",
|
|
40
43
|
...props
|
|
41
44
|
}: CheckboxGroupProps): JSX.Element => {
|
|
42
45
|
const componentProps = {
|
|
43
46
|
className: clsx("coop-fieldset", "coop-checkbox-group", className),
|
|
44
47
|
"data-error": error ? "" : undefined,
|
|
48
|
+
"data-orientation": orientation !== "vertical" ? orientation : undefined,
|
|
45
49
|
"data-size": size.length && size !== "md" ? size : undefined,
|
|
46
50
|
...props,
|
|
47
51
|
}
|
|
@@ -55,7 +59,7 @@ export const CheckboxGroup = ({
|
|
|
55
59
|
{label && <legend {...legendProps}>{label}</legend>}
|
|
56
60
|
{hint && <FieldHint>{hint}</FieldHint>}
|
|
57
61
|
{typeof error === "object" && error?.message && <FieldError>{error.message}</FieldError>}
|
|
58
|
-
{children}
|
|
62
|
+
<div className="coop-checkbox-group-options">{children}</div>
|
|
59
63
|
</fieldset>
|
|
60
64
|
)
|
|
61
65
|
}
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
import clsx from "clsx"
|
|
2
|
+
import { type InputHTMLAttributes, type JSX, useId } from "react"
|
|
3
|
+
import { FormFieldError, StandardSizes } from "src/types"
|
|
4
|
+
|
|
5
|
+
import { FieldError } from "../FieldError"
|
|
6
|
+
import { FieldHint } from "../FieldHint"
|
|
7
|
+
import { FieldLabel } from "../FieldLabel"
|
|
8
|
+
import Tag, { TagProps } from "../Tag"
|
|
9
|
+
|
|
10
|
+
export interface RadioButtonProps
|
|
11
|
+
extends Omit<InputHTMLAttributes<HTMLInputElement>, "size" | "type"> {
|
|
12
|
+
/** **(Optional)** Specify additional CSS classes to be applied to the component. */
|
|
13
|
+
className?: string
|
|
14
|
+
/** **(Optional)** Specify the RadioButton error state.
|
|
15
|
+
*
|
|
16
|
+
* 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.
|
|
17
|
+
*/
|
|
18
|
+
error?: FormFieldError
|
|
19
|
+
/** **(Optional)** Specify the RadioButton hint.
|
|
20
|
+
*
|
|
21
|
+
* This text is rendered under the label to provide further guidance for users.
|
|
22
|
+
*/
|
|
23
|
+
hint?: string
|
|
24
|
+
/** **(Optional)** Specify the RadioButton id. Will be auto-generated if not set. */
|
|
25
|
+
id?: string
|
|
26
|
+
/** **(Optional)** Specify the RadioButton label.
|
|
27
|
+
*
|
|
28
|
+
* This property is optional in case you need to render your own label, but all form elements *must* provide a label. */
|
|
29
|
+
label: string
|
|
30
|
+
/** **(Optional)** Specify whether the label should be visible to humans or screen readers. */
|
|
31
|
+
labelVisible?: boolean
|
|
32
|
+
/** Specify the RadioButton name. */
|
|
33
|
+
name: string
|
|
34
|
+
/** **(Optional)** Specify the RadioButton size. */
|
|
35
|
+
size?: StandardSizes
|
|
36
|
+
/** **(Optional)** Specify the RadioButton tag text. */
|
|
37
|
+
tag?: string
|
|
38
|
+
/** **(Optional)** Specify the RadioButton tag background color. */
|
|
39
|
+
tagBackground?: TagProps["background"]
|
|
40
|
+
/** **(Optional)** Specify the RadioButton variant. */
|
|
41
|
+
variant?: "default" | "boxed"
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
export const RadioButton = ({
|
|
45
|
+
className,
|
|
46
|
+
error = false,
|
|
47
|
+
hint,
|
|
48
|
+
id,
|
|
49
|
+
label,
|
|
50
|
+
labelVisible = true,
|
|
51
|
+
name,
|
|
52
|
+
size = "md",
|
|
53
|
+
tag,
|
|
54
|
+
tagBackground,
|
|
55
|
+
variant = "default",
|
|
56
|
+
...props
|
|
57
|
+
}: RadioButtonProps): JSX.Element => {
|
|
58
|
+
const internalId = useId()
|
|
59
|
+
|
|
60
|
+
id = id ?? internalId
|
|
61
|
+
|
|
62
|
+
const componentProps = {
|
|
63
|
+
className: clsx("coop-radio-button", className),
|
|
64
|
+
"data-error": error ? "" : undefined,
|
|
65
|
+
"data-size": size.length && size !== "md" ? size : undefined,
|
|
66
|
+
"data-variant": variant !== "default" ? variant : undefined,
|
|
67
|
+
id,
|
|
68
|
+
name,
|
|
69
|
+
type: "radio",
|
|
70
|
+
...props,
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
return (
|
|
74
|
+
<div className="coop-form-item">
|
|
75
|
+
<div className="coop-radio-button-wrapper">
|
|
76
|
+
<input {...componentProps} />
|
|
77
|
+
|
|
78
|
+
{label && (
|
|
79
|
+
<FieldLabel htmlFor={id} isVisible={labelVisible}>
|
|
80
|
+
<span>{label}</span>{" "}
|
|
81
|
+
{tag && (
|
|
82
|
+
<Tag background={tagBackground} size="sm">
|
|
83
|
+
{tag}
|
|
84
|
+
</Tag>
|
|
85
|
+
)}
|
|
86
|
+
</FieldLabel>
|
|
87
|
+
)}
|
|
88
|
+
{hint && <FieldHint>{hint}</FieldHint>}
|
|
89
|
+
</div>
|
|
90
|
+
{typeof error === "object" && error?.message && <FieldError>{error.message}</FieldError>}
|
|
91
|
+
</div>
|
|
92
|
+
)
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
export default RadioButton
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import type { FieldsetHTMLAttributes, JSX } from "react"
|
|
2
|
+
|
|
3
|
+
import clsx from "clsx"
|
|
4
|
+
|
|
5
|
+
import { FormFieldError, StandardSizes } from "../../types"
|
|
6
|
+
import { FieldError } from "../FieldError"
|
|
7
|
+
import { FieldHint } from "../FieldHint"
|
|
8
|
+
|
|
9
|
+
export interface RadioButtonGroupProps extends FieldsetHTMLAttributes<HTMLFieldSetElement> {
|
|
10
|
+
/** **(Optional)** Main content inside the component. It can be any valid JSX or string. */
|
|
11
|
+
children?: React.ReactNode
|
|
12
|
+
/** **(Optional)** Specify additional CSS classes to be applied to the component. */
|
|
13
|
+
className?: string
|
|
14
|
+
/** **(Optional)** Specify the RadioButtonGroup error state.
|
|
15
|
+
*
|
|
16
|
+
* 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.
|
|
17
|
+
*/
|
|
18
|
+
error?: FormFieldError
|
|
19
|
+
/** **(Optional)** Specify the RadioButtonGroup hint.
|
|
20
|
+
*
|
|
21
|
+
* This text is rendered under the label to provide further guidance for users.
|
|
22
|
+
*/
|
|
23
|
+
hint?: string
|
|
24
|
+
/** **(Optional)** Specify the label for the RadioButtonGroup. This will be rendered as a fieldset legend. */
|
|
25
|
+
label?: string
|
|
26
|
+
/** **(Optional)** Specify whether the label should be visible to humans or screen readers. */
|
|
27
|
+
labelVisible?: boolean
|
|
28
|
+
/** **(Optional)** Specify the RadioButtonGroup orientation. */
|
|
29
|
+
orientation?: "horizontal" | "vertical"
|
|
30
|
+
/** **(Optional)** Specify the RadioButtonGroup size. */
|
|
31
|
+
size?: StandardSizes
|
|
32
|
+
/** **(Optional)** Specify the RadioButtonGroup variant. */
|
|
33
|
+
variant?: "default" | "boxed"
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
export const RadioButtonGroup = ({
|
|
37
|
+
children,
|
|
38
|
+
className,
|
|
39
|
+
error = false,
|
|
40
|
+
hint,
|
|
41
|
+
label,
|
|
42
|
+
labelVisible = true,
|
|
43
|
+
orientation = "vertical",
|
|
44
|
+
size = "md",
|
|
45
|
+
variant = "default",
|
|
46
|
+
...props
|
|
47
|
+
}: RadioButtonGroupProps): JSX.Element => {
|
|
48
|
+
const componentProps = {
|
|
49
|
+
className: clsx("coop-fieldset", "coop-radio-button-group", className),
|
|
50
|
+
"data-error": error ? "" : undefined,
|
|
51
|
+
"data-orientation": orientation !== "vertical" ? orientation : undefined,
|
|
52
|
+
"data-size": size.length && size !== "md" ? size : undefined,
|
|
53
|
+
"data-variant": variant !== "default" ? variant : undefined,
|
|
54
|
+
...props,
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
const legendProps = {
|
|
58
|
+
className: clsx("coop-field-label", !labelVisible && "sr-only"),
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
return (
|
|
62
|
+
<fieldset {...componentProps}>
|
|
63
|
+
{label && <legend {...legendProps}>{label}</legend>}
|
|
64
|
+
{hint && <FieldHint>{hint}</FieldHint>}
|
|
65
|
+
{typeof error === "object" && error?.message && <FieldError>{error.message}</FieldError>}
|
|
66
|
+
<div className="coop-radio-button-group-options">{children}</div>
|
|
67
|
+
</fieldset>
|
|
68
|
+
)
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
export default RadioButtonGroup
|
|
@@ -19,6 +19,8 @@ export interface TagProps extends HTMLAttributes<HTMLAnchorElement> {
|
|
|
19
19
|
className?: string
|
|
20
20
|
/** **(Optional)** Specify the URL that the Tag component will link to when clicked. */
|
|
21
21
|
href?: string
|
|
22
|
+
/** **(Optional)** Specify the Tag size. */
|
|
23
|
+
size?: "sm" | "md"
|
|
22
24
|
}
|
|
23
25
|
|
|
24
26
|
export const Tag = ({
|
|
@@ -27,12 +29,15 @@ export const Tag = ({
|
|
|
27
29
|
children,
|
|
28
30
|
className,
|
|
29
31
|
href,
|
|
32
|
+
size = "md",
|
|
30
33
|
...props
|
|
31
34
|
}: TagProps): JSX.Element => {
|
|
32
35
|
let element: TagProps["as"] = href ? "a" : "span"
|
|
33
36
|
const componentProps = {
|
|
34
37
|
className: clsx("coop-tag", bgPropToClass(background, className), className),
|
|
38
|
+
"data-size": size.length && size !== "md" ? size : undefined,
|
|
35
39
|
href,
|
|
40
|
+
|
|
36
41
|
...props,
|
|
37
42
|
}
|
|
38
43
|
if (as) {
|
package/src/index.ts
CHANGED
|
@@ -3,7 +3,6 @@ export * from "./components/Author"
|
|
|
3
3
|
export * from "./components/Button"
|
|
4
4
|
export * from "./components/Card"
|
|
5
5
|
export * from "./components/Checkbox"
|
|
6
|
-
export * from "./components/Checkbox/CheckboxGroup"
|
|
7
6
|
export * from "./components/Expandable"
|
|
8
7
|
export * from "./components/Field"
|
|
9
8
|
export * from "./components/FieldError"
|
|
@@ -12,6 +11,7 @@ export * from "./components/FieldLabel"
|
|
|
12
11
|
export * from "./components/Flourish"
|
|
13
12
|
export * from "./components/Image"
|
|
14
13
|
export * from "./components/Pill"
|
|
14
|
+
export * from "./components/RadioButton"
|
|
15
15
|
export * from "./components/RootSVG"
|
|
16
16
|
export * from "./components/SearchBox"
|
|
17
17
|
export * from "./components/Signpost"
|