@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 {
|
|
1
|
+
import type { ForwardRefExoticComponent, HTMLAttributes, JSX, Ref } from "react"
|
|
2
2
|
|
|
3
3
|
import clsx from "clsx"
|
|
4
4
|
import React from "react"
|
|
@@ -8,13 +8,15 @@ import { hasUserBg } from "../../../src/utils"
|
|
|
8
8
|
export interface TagProps extends HTMLAttributes<HTMLAnchorElement> {
|
|
9
9
|
/** **(Optional)** Specify a custom element to override default `a` or `span`. */
|
|
10
10
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
11
|
-
as?: React.FC<
|
|
11
|
+
as?: React.FC<any> | ForwardRefExoticComponent<any> | string
|
|
12
12
|
/** **(Optional)** Main content inside the component. It can be any valid JSX or string. */
|
|
13
13
|
children?: React.ReactNode
|
|
14
14
|
/** **(Optional)** Specify additional CSS classes to be applied to the component. */
|
|
15
15
|
className?: string
|
|
16
16
|
/** **(Optional)** Specify the URL that the Tag component will link to when clicked. */
|
|
17
17
|
href?: string
|
|
18
|
+
/** **(Optional)** Specify a custom React ref for this component. */
|
|
19
|
+
ref?: Ref<HTMLElement>
|
|
18
20
|
/** **(Optional)** Specify the Tag size. */
|
|
19
21
|
size?: "sm" | "md"
|
|
20
22
|
}
|
|
@@ -24,21 +26,20 @@ export const Tag = ({
|
|
|
24
26
|
children,
|
|
25
27
|
className,
|
|
26
28
|
href,
|
|
29
|
+
ref,
|
|
27
30
|
size = "md",
|
|
28
31
|
...props
|
|
29
32
|
}: TagProps): JSX.Element => {
|
|
30
|
-
|
|
33
|
+
const element: TagProps["as"] = as ?? (href ? "a" : "span")
|
|
34
|
+
|
|
31
35
|
const componentProps = {
|
|
32
36
|
className: clsx("coop-tag", !hasUserBg(className) && "bg-tint-grey", className),
|
|
33
37
|
"data-size": size.length && size !== "md" ? size : undefined,
|
|
34
38
|
href,
|
|
35
|
-
|
|
36
39
|
...props,
|
|
37
40
|
}
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
}
|
|
41
|
-
return React.createElement(element, { ...componentProps }, children)
|
|
41
|
+
|
|
42
|
+
return React.createElement(element, { ...componentProps, ref }, children)
|
|
42
43
|
}
|
|
43
44
|
|
|
44
45
|
export default Tag
|
|
@@ -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
|
|
|
@@ -21,12 +21,26 @@ export interface TextInputProps
|
|
|
21
21
|
placeholder?: string
|
|
22
22
|
/** **(Optional)** Specify the prefix. It can be any valid JSX or string. */
|
|
23
23
|
prefix?: React.ReactNode
|
|
24
|
+
/** **(Optional)** Specify a custom React ref for this component. */
|
|
25
|
+
ref?: Ref<HTMLInputElement>
|
|
24
26
|
/** **(Optional)** Specify the TextInput size. */
|
|
25
27
|
size?: StandardSizes
|
|
26
28
|
/** **(Optional)** Specify the suffix. It can be any valid JSX or string. */
|
|
27
29
|
suffix?: React.ReactNode
|
|
28
30
|
/** **(Optional)** Specify the TextInput type. */
|
|
29
|
-
type?:
|
|
31
|
+
type?:
|
|
32
|
+
| "text"
|
|
33
|
+
| "email"
|
|
34
|
+
| "number"
|
|
35
|
+
| "password"
|
|
36
|
+
| "search"
|
|
37
|
+
| "tel"
|
|
38
|
+
| "url"
|
|
39
|
+
| "date"
|
|
40
|
+
| "datetime-local"
|
|
41
|
+
| "week"
|
|
42
|
+
| "month"
|
|
43
|
+
| "time"
|
|
30
44
|
}
|
|
31
45
|
|
|
32
46
|
export const TextInput = ({
|
|
@@ -38,6 +52,7 @@ export const TextInput = ({
|
|
|
38
52
|
name,
|
|
39
53
|
placeholder,
|
|
40
54
|
prefix,
|
|
55
|
+
ref,
|
|
41
56
|
size = "md",
|
|
42
57
|
suffix,
|
|
43
58
|
type = "text",
|
|
@@ -61,7 +76,7 @@ export const TextInput = ({
|
|
|
61
76
|
return (
|
|
62
77
|
<div className="coop-text-input-wrapper">
|
|
63
78
|
{prefix && <span className="coop-text-input--prefix">{prefix}</span>}
|
|
64
|
-
<input {...componentProps} />
|
|
79
|
+
<input {...componentProps} ref={ref} />
|
|
65
80
|
{suffix && <span className="coop-text-input--suffix">{suffix}</span>}
|
|
66
81
|
</div>
|
|
67
82
|
)
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { ChangeEvent, JSX, TextareaHTMLAttributes } from "react"
|
|
1
|
+
import type { ChangeEvent, JSX, Ref, TextareaHTMLAttributes } from "react"
|
|
2
2
|
|
|
3
3
|
import clsx from "clsx"
|
|
4
4
|
import { useState } from "react"
|
|
@@ -39,6 +39,8 @@ export interface TextareaProps extends TextareaHTMLAttributes<HTMLTextAreaElemen
|
|
|
39
39
|
name: string
|
|
40
40
|
/** **(Optional)** Specify the Textarea placeholder text. Do not use in place of a form label. */
|
|
41
41
|
placeholder?: string
|
|
42
|
+
/** **(Optional)** Specify a custom React ref for this component. */
|
|
43
|
+
ref?: Ref<HTMLTextAreaElement>
|
|
42
44
|
/** Specify the number of rows (lines of text) in the Textarea. Defaults to `4`. */
|
|
43
45
|
rows?: number
|
|
44
46
|
/** **(Optional)** Specify the Textarea size. */
|
|
@@ -58,13 +60,12 @@ export const Textarea = ({
|
|
|
58
60
|
name,
|
|
59
61
|
onChange: userOnChange = undefined,
|
|
60
62
|
placeholder,
|
|
63
|
+
ref,
|
|
61
64
|
rows = 4,
|
|
62
65
|
size = "md",
|
|
63
66
|
...props
|
|
64
67
|
}: TextareaProps): JSX.Element => {
|
|
65
|
-
const
|
|
66
|
-
|
|
67
|
-
id = id ?? internalId
|
|
68
|
+
const uid = useId(id)
|
|
68
69
|
|
|
69
70
|
const componentProps = {
|
|
70
71
|
"aria-placeholder": placeholder ?? ariaPlaceholder ?? undefined,
|
|
@@ -73,7 +74,7 @@ export const Textarea = ({
|
|
|
73
74
|
"data-error": error ?? undefined,
|
|
74
75
|
"data-size": size.length && size !== "md" ? size : undefined,
|
|
75
76
|
disabled,
|
|
76
|
-
id,
|
|
77
|
+
id: uid,
|
|
77
78
|
maxLength: cutoff ? maxLength : undefined,
|
|
78
79
|
name,
|
|
79
80
|
placeholder,
|
|
@@ -98,7 +99,8 @@ export const Textarea = ({
|
|
|
98
99
|
userOnChange?.(e)
|
|
99
100
|
handleChange(e)
|
|
100
101
|
}}
|
|
101
|
-
|
|
102
|
+
ref={ref}
|
|
103
|
+
/>
|
|
102
104
|
{showCounter && (
|
|
103
105
|
<>
|
|
104
106
|
<small
|
package/src/index.ts
CHANGED
|
@@ -9,9 +9,9 @@ export * from "./components/Fieldset"
|
|
|
9
9
|
export * from "./components/Flourish"
|
|
10
10
|
export * from "./components/Image"
|
|
11
11
|
export * from "./components/Pill"
|
|
12
|
-
export * from "./components/
|
|
12
|
+
export * from "./components/Radio"
|
|
13
13
|
export * from "./components/RootSVG"
|
|
14
|
-
export * from "./components/
|
|
14
|
+
export * from "./components/Searchbox"
|
|
15
15
|
export * from "./components/Signpost"
|
|
16
16
|
export * from "./components/SkipNav"
|
|
17
17
|
export * from "./components/Squircle"
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import { type InputHTMLAttributes, type JSX } from "react";
|
|
2
|
-
import { StandardSizes } from "src/types";
|
|
3
|
-
export interface RadioButtonProps extends Omit<InputHTMLAttributes<HTMLInputElement>, "size" | "type"> {
|
|
4
|
-
/** **(Optional)** Specify additional CSS classes to be applied to the component. */
|
|
5
|
-
className?: string;
|
|
6
|
-
/** **(Optional)** Specify whether the RadioButton should be disabled. Refer to Experience Library guidance on disabled form controls and accessibility. */
|
|
7
|
-
disabled?: boolean;
|
|
8
|
-
/** **(Optional)** Specify the RadioButton error state. */
|
|
9
|
-
error?: boolean;
|
|
10
|
-
/** **(Optional)** Specify the RadioButton id. Will be auto-generated if not set. */
|
|
11
|
-
id?: string;
|
|
12
|
-
/** Specify the RadioButton name. */
|
|
13
|
-
name: string;
|
|
14
|
-
/** **(Optional)** Specify the RadioButton size. */
|
|
15
|
-
size?: StandardSizes;
|
|
16
|
-
}
|
|
17
|
-
export declare const RadioButton: ({ className, disabled, error, id, name, size, ...props }: RadioButtonProps) => JSX.Element;
|
|
18
|
-
export default RadioButton;
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
import { jsx } from 'react/jsx-runtime';
|
|
2
|
-
import clsx from 'clsx';
|
|
3
|
-
import { useId } from 'react';
|
|
4
|
-
|
|
5
|
-
const RadioButton = ({ className, disabled, error = false, id, name, size = "md", ...props }) => {
|
|
6
|
-
const internalId = useId();
|
|
7
|
-
id = id !== null && id !== void 0 ? id : internalId;
|
|
8
|
-
const componentProps = {
|
|
9
|
-
className: clsx("coop-radio-button", className),
|
|
10
|
-
"data-error": error || undefined,
|
|
11
|
-
"data-size": size.length && size !== "md" ? size : undefined,
|
|
12
|
-
disabled,
|
|
13
|
-
id,
|
|
14
|
-
name,
|
|
15
|
-
type: "radio",
|
|
16
|
-
...props,
|
|
17
|
-
};
|
|
18
|
-
//const formItemProps = { "aria-disabled": disabled ? true : undefined }
|
|
19
|
-
return jsx("input", { ...componentProps });
|
|
20
|
-
};
|
|
21
|
-
|
|
22
|
-
export { RadioButton, RadioButton as default };
|
|
@@ -1,48 +0,0 @@
|
|
|
1
|
-
import clsx from "clsx"
|
|
2
|
-
import { type InputHTMLAttributes, type JSX, useId } from "react"
|
|
3
|
-
import { StandardSizes } from "src/types"
|
|
4
|
-
|
|
5
|
-
export interface RadioButtonProps
|
|
6
|
-
extends Omit<InputHTMLAttributes<HTMLInputElement>, "size" | "type"> {
|
|
7
|
-
/** **(Optional)** Specify additional CSS classes to be applied to the component. */
|
|
8
|
-
className?: string
|
|
9
|
-
/** **(Optional)** Specify whether the RadioButton should be disabled. Refer to Experience Library guidance on disabled form controls and accessibility. */
|
|
10
|
-
disabled?: boolean
|
|
11
|
-
/** **(Optional)** Specify the RadioButton error state. */
|
|
12
|
-
error?: boolean
|
|
13
|
-
/** **(Optional)** Specify the RadioButton id. Will be auto-generated if not set. */
|
|
14
|
-
id?: string
|
|
15
|
-
/** Specify the RadioButton name. */
|
|
16
|
-
name: string
|
|
17
|
-
/** **(Optional)** Specify the RadioButton size. */
|
|
18
|
-
size?: StandardSizes
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
export const RadioButton = ({
|
|
22
|
-
className,
|
|
23
|
-
disabled,
|
|
24
|
-
error = false,
|
|
25
|
-
id,
|
|
26
|
-
name,
|
|
27
|
-
size = "md",
|
|
28
|
-
...props
|
|
29
|
-
}: RadioButtonProps): JSX.Element => {
|
|
30
|
-
const internalId = useId()
|
|
31
|
-
|
|
32
|
-
id = id ?? internalId
|
|
33
|
-
|
|
34
|
-
const componentProps = {
|
|
35
|
-
className: clsx("coop-radio-button", className),
|
|
36
|
-
"data-error": error || undefined,
|
|
37
|
-
"data-size": size.length && size !== "md" ? size : undefined,
|
|
38
|
-
disabled,
|
|
39
|
-
id,
|
|
40
|
-
name,
|
|
41
|
-
type: "radio",
|
|
42
|
-
...props,
|
|
43
|
-
}
|
|
44
|
-
//const formItemProps = { "aria-disabled": disabled ? true : undefined }
|
|
45
|
-
return <input {...componentProps} />
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
export default RadioButton
|