@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.
Files changed (207) hide show
  1. package/dist/components/AlertBanner/AlertBanner.d.ts +4 -2
  2. package/dist/components/AlertBanner/AlertBanner.js +2 -2
  3. package/dist/components/Author/Author.d.ts +4 -2
  4. package/dist/components/Author/Author.js +2 -2
  5. package/dist/components/Button/Button.d.ts +6 -4
  6. package/dist/components/Button/Button.js +4 -7
  7. package/dist/components/Card/Card.d.ts +4 -2
  8. package/dist/components/Card/Card.js +4 -4
  9. package/dist/components/Checkbox/Checkbox.d.ts +4 -2
  10. package/dist/components/Checkbox/Checkbox.js +2 -2
  11. package/dist/components/Expandable/Expandable.d.ts +4 -2
  12. package/dist/components/Expandable/Expandable.js +4 -4
  13. package/dist/components/Field/Field.d.ts +4 -2
  14. package/dist/components/Field/Field.js +7 -8
  15. package/dist/components/FieldMarkers/Error.d.ts +4 -2
  16. package/dist/components/FieldMarkers/Error.js +2 -2
  17. package/dist/components/FieldMarkers/Hint.d.ts +5 -3
  18. package/dist/components/FieldMarkers/Hint.js +2 -2
  19. package/dist/components/FieldMarkers/Label.d.ts +4 -2
  20. package/dist/components/FieldMarkers/Label.js +6 -2
  21. package/dist/components/FieldMarkers/Legend.d.ts +4 -2
  22. package/dist/components/FieldMarkers/Legend.js +2 -2
  23. package/dist/components/Fieldset/Fieldset.d.ts +4 -2
  24. package/dist/components/Fieldset/Fieldset.js +2 -4
  25. package/dist/components/Flourish/Flourish.d.ts +4 -2
  26. package/dist/components/Flourish/Flourish.js +2 -2
  27. package/dist/components/Icon/AddIcon.d.ts +1 -1
  28. package/dist/components/Icon/AddIcon.js +6 -5
  29. package/dist/components/Icon/ArrowDownIcon.d.ts +1 -1
  30. package/dist/components/Icon/ArrowDownIcon.js +6 -5
  31. package/dist/components/Icon/ArrowLeftIcon.d.ts +1 -1
  32. package/dist/components/Icon/ArrowLeftIcon.js +6 -5
  33. package/dist/components/Icon/ArrowRightIcon.d.ts +1 -1
  34. package/dist/components/Icon/ArrowRightIcon.js +6 -5
  35. package/dist/components/Icon/ArrowUpIcon.d.ts +1 -1
  36. package/dist/components/Icon/ArrowUpIcon.js +6 -5
  37. package/dist/components/Icon/AvatarAltIcon.d.ts +1 -1
  38. package/dist/components/Icon/AvatarAltIcon.js +6 -5
  39. package/dist/components/Icon/AvatarIcon.d.ts +1 -1
  40. package/dist/components/Icon/AvatarIcon.js +6 -5
  41. package/dist/components/Icon/BasketIcon.d.ts +1 -1
  42. package/dist/components/Icon/BasketIcon.js +6 -5
  43. package/dist/components/Icon/CalendarIcon.d.ts +1 -1
  44. package/dist/components/Icon/CalendarIcon.js +6 -5
  45. package/dist/components/Icon/ChevronDownIcon.d.ts +1 -1
  46. package/dist/components/Icon/ChevronDownIcon.js +6 -5
  47. package/dist/components/Icon/ChevronLeftIcon.d.ts +1 -1
  48. package/dist/components/Icon/ChevronLeftIcon.js +6 -5
  49. package/dist/components/Icon/ChevronRightIcon.d.ts +1 -1
  50. package/dist/components/Icon/ChevronRightIcon.js +6 -5
  51. package/dist/components/Icon/ChevronUpIcon.d.ts +1 -1
  52. package/dist/components/Icon/ChevronUpIcon.js +6 -5
  53. package/dist/components/Icon/ClockIcon.d.ts +1 -1
  54. package/dist/components/Icon/ClockIcon.js +6 -5
  55. package/dist/components/Icon/CloseAltIcon.d.ts +1 -1
  56. package/dist/components/Icon/CloseAltIcon.js +6 -5
  57. package/dist/components/Icon/CloseIcon.d.ts +1 -1
  58. package/dist/components/Icon/CloseIcon.js +6 -5
  59. package/dist/components/Icon/CoopCardIcon.d.ts +1 -1
  60. package/dist/components/Icon/CoopCardIcon.js +6 -5
  61. package/dist/components/Icon/CoopIcon.d.ts +1 -1
  62. package/dist/components/Icon/CoopIcon.js +6 -5
  63. package/dist/components/Icon/CoopLocationIcon.d.ts +1 -1
  64. package/dist/components/Icon/CoopLocationIcon.js +6 -5
  65. package/dist/components/Icon/DownloadIcon.d.ts +1 -1
  66. package/dist/components/Icon/DownloadIcon.js +6 -5
  67. package/dist/components/Icon/HomeIcon.d.ts +1 -1
  68. package/dist/components/Icon/HomeIcon.js +6 -5
  69. package/dist/components/Icon/InformationIcon.d.ts +1 -1
  70. package/dist/components/Icon/InformationIcon.js +6 -5
  71. package/dist/components/Icon/LoadingIcon.d.ts +1 -1
  72. package/dist/components/Icon/LoadingIcon.js +6 -5
  73. package/dist/components/Icon/LocationIcon.d.ts +1 -1
  74. package/dist/components/Icon/LocationIcon.js +6 -5
  75. package/dist/components/Icon/MailIcon.d.ts +1 -1
  76. package/dist/components/Icon/MailIcon.js +6 -5
  77. package/dist/components/Icon/MenuIcon.d.ts +1 -1
  78. package/dist/components/Icon/MenuIcon.js +6 -5
  79. package/dist/components/Icon/MessageIcon.d.ts +1 -1
  80. package/dist/components/Icon/MessageIcon.js +6 -5
  81. package/dist/components/Icon/MinusIcon.d.ts +1 -1
  82. package/dist/components/Icon/MinusIcon.js +6 -5
  83. package/dist/components/Icon/OpenNewIcon.d.ts +1 -1
  84. package/dist/components/Icon/OpenNewIcon.js +6 -5
  85. package/dist/components/Icon/PencilIcon.d.ts +1 -1
  86. package/dist/components/Icon/PencilIcon.js +6 -5
  87. package/dist/components/Icon/PhoneIcon.d.ts +1 -1
  88. package/dist/components/Icon/PhoneIcon.js +6 -5
  89. package/dist/components/Icon/QuestionIcon.d.ts +1 -1
  90. package/dist/components/Icon/QuestionIcon.js +6 -5
  91. package/dist/components/Icon/ScooterIcon.d.ts +1 -1
  92. package/dist/components/Icon/ScooterIcon.js +6 -5
  93. package/dist/components/Icon/SearchIcon.d.ts +1 -1
  94. package/dist/components/Icon/SearchIcon.js +6 -5
  95. package/dist/components/Icon/SettingsIcon.d.ts +1 -1
  96. package/dist/components/Icon/SettingsIcon.js +6 -5
  97. package/dist/components/Icon/TickAltIcon.d.ts +1 -1
  98. package/dist/components/Icon/TickAltIcon.js +6 -5
  99. package/dist/components/Icon/TickIcon.d.ts +1 -1
  100. package/dist/components/Icon/TickIcon.js +6 -5
  101. package/dist/components/Icon/VanIcon.d.ts +1 -1
  102. package/dist/components/Icon/VanIcon.js +6 -5
  103. package/dist/components/Icon/WarningIcon.d.ts +1 -1
  104. package/dist/components/Icon/WarningIcon.js +6 -5
  105. package/dist/components/Icon/WriteIcon.d.ts +1 -1
  106. package/dist/components/Icon/WriteIcon.js +6 -5
  107. package/dist/components/Image/Image.d.ts +4 -2
  108. package/dist/components/Image/Image.js +2 -2
  109. package/dist/components/Pill/Pill.d.ts +4 -2
  110. package/dist/components/Pill/Pill.js +7 -8
  111. package/dist/components/Radio/Radio.d.ts +20 -0
  112. package/dist/components/Radio/Radio.js +21 -0
  113. package/dist/components/Radio/index.d.ts +4 -0
  114. package/dist/components/{SearchBox/SearchBox.d.ts → Searchbox/Searchbox.d.ts} +10 -8
  115. package/dist/components/{SearchBox/SearchBox.js → Searchbox/Searchbox.js} +16 -11
  116. package/dist/components/Searchbox/index.d.ts +4 -0
  117. package/dist/components/Signpost/Signpost.d.ts +6 -4
  118. package/dist/components/Signpost/Signpost.js +3 -6
  119. package/dist/components/SkipNav/SkipNav.d.ts +4 -2
  120. package/dist/components/SkipNav/SkipNav.js +2 -2
  121. package/dist/components/Squircle/Squircle.d.ts +4 -2
  122. package/dist/components/Squircle/Squircle.js +2 -2
  123. package/dist/components/Tag/Tag.d.ts +5 -3
  124. package/dist/components/Tag/Tag.js +3 -6
  125. package/dist/components/TextInput/TextInput.d.ts +5 -3
  126. package/dist/components/TextInput/TextInput.js +2 -2
  127. package/dist/components/Textarea/Textarea.d.ts +4 -2
  128. package/dist/components/Textarea/Textarea.js +4 -5
  129. package/dist/{utils/slots.d.ts → hooks/useSlots.d.ts} +1 -1
  130. package/dist/{utils/slots.js → hooks/useSlots.js} +2 -2
  131. package/dist/index.d.ts +2 -2
  132. package/dist/index.js +2 -2
  133. package/package.json +3 -3
  134. package/src/components/AlertBanner/AlertBanner.tsx +6 -2
  135. package/src/components/Author/Author.tsx +5 -2
  136. package/src/components/Button/Button.tsx +10 -15
  137. package/src/components/Card/Card.tsx +7 -5
  138. package/src/components/Checkbox/Checkbox.tsx +6 -2
  139. package/src/components/Expandable/Expandable.tsx +12 -5
  140. package/src/components/Field/Field.tsx +10 -9
  141. package/src/components/FieldMarkers/Error.tsx +9 -3
  142. package/src/components/FieldMarkers/Hint.tsx +10 -4
  143. package/src/components/FieldMarkers/Label.tsx +9 -3
  144. package/src/components/FieldMarkers/Legend.tsx +9 -3
  145. package/src/components/Fieldset/Fieldset.tsx +9 -4
  146. package/src/components/Flourish/Flourish.tsx +5 -2
  147. package/src/components/Icon/AddIcon.tsx +9 -6
  148. package/src/components/Icon/ArrowDownIcon.tsx +9 -6
  149. package/src/components/Icon/ArrowLeftIcon.tsx +9 -6
  150. package/src/components/Icon/ArrowRightIcon.tsx +9 -6
  151. package/src/components/Icon/ArrowUpIcon.tsx +9 -6
  152. package/src/components/Icon/AvatarAltIcon.tsx +9 -6
  153. package/src/components/Icon/AvatarIcon.tsx +9 -6
  154. package/src/components/Icon/BasketIcon.tsx +9 -6
  155. package/src/components/Icon/CalendarIcon.tsx +9 -6
  156. package/src/components/Icon/ChevronDownIcon.tsx +9 -6
  157. package/src/components/Icon/ChevronLeftIcon.tsx +9 -6
  158. package/src/components/Icon/ChevronRightIcon.tsx +9 -6
  159. package/src/components/Icon/ChevronUpIcon.tsx +9 -6
  160. package/src/components/Icon/ClockIcon.tsx +9 -6
  161. package/src/components/Icon/CloseAltIcon.tsx +9 -6
  162. package/src/components/Icon/CloseIcon.tsx +9 -6
  163. package/src/components/Icon/CoopCardIcon.tsx +9 -6
  164. package/src/components/Icon/CoopIcon.tsx +9 -6
  165. package/src/components/Icon/CoopLocationIcon.tsx +9 -6
  166. package/src/components/Icon/DownloadIcon.tsx +9 -6
  167. package/src/components/Icon/HomeIcon.tsx +9 -6
  168. package/src/components/Icon/InformationIcon.tsx +9 -6
  169. package/src/components/Icon/LoadingIcon.tsx +9 -6
  170. package/src/components/Icon/LocationIcon.tsx +9 -6
  171. package/src/components/Icon/MailIcon.tsx +9 -6
  172. package/src/components/Icon/MenuIcon.tsx +9 -6
  173. package/src/components/Icon/MessageIcon.tsx +9 -6
  174. package/src/components/Icon/MinusIcon.tsx +9 -6
  175. package/src/components/Icon/OpenNewIcon.tsx +9 -6
  176. package/src/components/Icon/PencilIcon.tsx +9 -6
  177. package/src/components/Icon/PhoneIcon.tsx +9 -6
  178. package/src/components/Icon/QuestionIcon.tsx +9 -6
  179. package/src/components/Icon/ScooterIcon.tsx +9 -6
  180. package/src/components/Icon/SearchIcon.tsx +9 -6
  181. package/src/components/Icon/SettingsIcon.tsx +9 -6
  182. package/src/components/Icon/TickAltIcon.tsx +9 -6
  183. package/src/components/Icon/TickIcon.tsx +9 -6
  184. package/src/components/Icon/VanIcon.tsx +9 -6
  185. package/src/components/Icon/WarningIcon.tsx +9 -6
  186. package/src/components/Icon/WriteIcon.tsx +9 -6
  187. package/src/components/Image/Image.tsx +5 -2
  188. package/src/components/Pill/Pill.tsx +10 -9
  189. package/src/components/Radio/Radio.tsx +50 -0
  190. package/src/components/Radio/index.ts +5 -0
  191. package/src/components/{SearchBox/SearchBox.tsx → Searchbox/Searchbox.tsx} +33 -30
  192. package/src/components/Searchbox/index.ts +5 -0
  193. package/src/components/Signpost/Signpost.tsx +8 -8
  194. package/src/components/SkipNav/SkipNav.tsx +5 -2
  195. package/src/components/Squircle/Squircle.tsx +5 -2
  196. package/src/components/Tag/Tag.tsx +9 -8
  197. package/src/components/TextInput/TextInput.tsx +18 -3
  198. package/src/components/Textarea/Textarea.tsx +8 -6
  199. package/src/{utils/slots.ts → hooks/useSlots.ts} +1 -1
  200. package/src/index.ts +2 -2
  201. package/dist/components/RadioButton/RadioButton.d.ts +0 -18
  202. package/dist/components/RadioButton/RadioButton.js +0 -22
  203. package/dist/components/RadioButton/index.d.ts +0 -4
  204. package/dist/components/SearchBox/index.d.ts +0 -4
  205. package/src/components/RadioButton/RadioButton.tsx +0 -48
  206. package/src/components/RadioButton/index.ts +0 -5
  207. package/src/components/SearchBox/index.ts +0 -5
@@ -1,4 +1,4 @@
1
- import type { AnchorHTMLAttributes, ForwardRefExoticComponent, HTMLAttributes, JSX } from "react"
1
+ import type { ForwardRefExoticComponent, HTMLAttributes, JSX, Ref } from "react"
2
2
 
3
3
  import clsx from "clsx"
4
4
  import React from "react"
@@ -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<AnchorHTMLAttributes<HTMLElement>> | ForwardRefExoticComponent<any> | string
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
- let element: TagProps["as"] = href ? "a" : "span"
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
- if (as) {
39
- element = as
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?: "text" | "email" | "number" | "password" | "search" | "tel" | "url"
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 internalId = useId()
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
- ></textarea>
102
+ ref={ref}
103
+ />
102
104
  {showCounter && (
103
105
  <>
104
106
  <small
@@ -12,7 +12,7 @@ export function getSlotName(node: React.ReactNode): string | false {
12
12
  : false
13
13
  }
14
14
 
15
- export function getSlots<T>(
15
+ export function useSlots<T>(
16
16
  componentSlots: Slots<T>,
17
17
  children: React.ReactNode,
18
18
  options?: { collect?: string[] }
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/RadioButton"
12
+ export * from "./components/Radio"
13
13
  export * from "./components/RootSVG"
14
- export * from "./components/SearchBox"
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,4 +0,0 @@
1
- import RadioButton from "./RadioButton";
2
- export default RadioButton;
3
- export { RadioButton };
4
- export * from "./RadioButton";
@@ -1,4 +0,0 @@
1
- import SearchBox from "./SearchBox";
2
- export default SearchBox;
3
- export { SearchBox };
4
- export * from "./SearchBox";
@@ -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
@@ -1,5 +0,0 @@
1
- import RadioButton from "./RadioButton"
2
-
3
- export default RadioButton
4
- export { RadioButton }
5
- export * from "./RadioButton"
@@ -1,5 +0,0 @@
1
- import SearchBox from "./SearchBox"
2
-
3
- export default SearchBox
4
- export { SearchBox }
5
- export * from "./SearchBox"