@coopdigital/react 0.46.0 → 0.48.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 (198) hide show
  1. package/dist/components/AlertBanner/AlertBanner.d.ts +16 -4
  2. package/dist/components/AlertBanner/AlertBanner.js +8 -3
  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 +1 -1
  6. package/dist/components/Button/Button.js +1 -2
  7. package/dist/components/Card/Card.d.ts +4 -2
  8. package/dist/components/Card/Card.js +2 -2
  9. package/dist/components/Checkbox/Checkbox.d.ts +4 -2
  10. package/dist/components/Checkbox/Checkbox.js +3 -3
  11. package/dist/components/Expandable/Expandable.d.ts +4 -2
  12. package/dist/components/Expandable/Expandable.js +2 -2
  13. package/dist/components/Field/Field.d.ts +4 -2
  14. package/dist/components/Field/Field.js +4 -4
  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 +5 -6
  111. package/dist/components/Radio/Radio.d.ts +5 -3
  112. package/dist/components/Radio/Radio.js +6 -7
  113. package/dist/components/Searchbox/Searchbox.d.ts +4 -2
  114. package/dist/components/Searchbox/Searchbox.js +14 -9
  115. package/dist/components/Select/Select.d.ts +46 -0
  116. package/dist/components/Select/Select.js +29 -0
  117. package/dist/components/Select/index.d.ts +4 -0
  118. package/dist/components/Signpost/Signpost.d.ts +6 -4
  119. package/dist/components/Signpost/Signpost.js +3 -6
  120. package/dist/components/SkipNav/SkipNav.d.ts +4 -2
  121. package/dist/components/SkipNav/SkipNav.js +2 -2
  122. package/dist/components/Squircle/Squircle.d.ts +4 -2
  123. package/dist/components/Squircle/Squircle.js +2 -2
  124. package/dist/components/Tag/Tag.d.ts +5 -3
  125. package/dist/components/Tag/Tag.js +3 -6
  126. package/dist/components/TextInput/TextInput.d.ts +4 -2
  127. package/dist/components/TextInput/TextInput.js +3 -3
  128. package/dist/components/Textarea/Textarea.d.ts +4 -2
  129. package/dist/components/Textarea/Textarea.js +5 -6
  130. package/dist/index.d.ts +1 -0
  131. package/dist/index.js +1 -0
  132. package/package.json +10 -10
  133. package/src/components/AlertBanner/AlertBanner.tsx +22 -9
  134. package/src/components/Author/Author.tsx +5 -2
  135. package/src/components/Button/Button.tsx +2 -3
  136. package/src/components/Card/Card.tsx +5 -2
  137. package/src/components/Checkbox/Checkbox.tsx +11 -5
  138. package/src/components/Expandable/Expandable.tsx +10 -3
  139. package/src/components/Field/Field.tsx +7 -5
  140. package/src/components/FieldMarkers/Error.tsx +9 -3
  141. package/src/components/FieldMarkers/Hint.tsx +10 -4
  142. package/src/components/FieldMarkers/Label.tsx +9 -3
  143. package/src/components/FieldMarkers/Legend.tsx +9 -3
  144. package/src/components/Fieldset/Fieldset.tsx +9 -4
  145. package/src/components/Flourish/Flourish.tsx +5 -2
  146. package/src/components/Icon/AddIcon.tsx +9 -6
  147. package/src/components/Icon/ArrowDownIcon.tsx +9 -6
  148. package/src/components/Icon/ArrowLeftIcon.tsx +9 -6
  149. package/src/components/Icon/ArrowRightIcon.tsx +9 -6
  150. package/src/components/Icon/ArrowUpIcon.tsx +9 -6
  151. package/src/components/Icon/AvatarAltIcon.tsx +9 -6
  152. package/src/components/Icon/AvatarIcon.tsx +9 -6
  153. package/src/components/Icon/BasketIcon.tsx +9 -6
  154. package/src/components/Icon/CalendarIcon.tsx +9 -6
  155. package/src/components/Icon/ChevronDownIcon.tsx +9 -6
  156. package/src/components/Icon/ChevronLeftIcon.tsx +9 -6
  157. package/src/components/Icon/ChevronRightIcon.tsx +9 -6
  158. package/src/components/Icon/ChevronUpIcon.tsx +9 -6
  159. package/src/components/Icon/ClockIcon.tsx +9 -6
  160. package/src/components/Icon/CloseAltIcon.tsx +9 -6
  161. package/src/components/Icon/CloseIcon.tsx +9 -6
  162. package/src/components/Icon/CoopCardIcon.tsx +9 -6
  163. package/src/components/Icon/CoopIcon.tsx +9 -6
  164. package/src/components/Icon/CoopLocationIcon.tsx +9 -6
  165. package/src/components/Icon/DownloadIcon.tsx +9 -6
  166. package/src/components/Icon/HomeIcon.tsx +9 -6
  167. package/src/components/Icon/InformationIcon.tsx +9 -6
  168. package/src/components/Icon/LoadingIcon.tsx +9 -6
  169. package/src/components/Icon/LocationIcon.tsx +9 -6
  170. package/src/components/Icon/MailIcon.tsx +9 -6
  171. package/src/components/Icon/MenuIcon.tsx +9 -6
  172. package/src/components/Icon/MessageIcon.tsx +9 -6
  173. package/src/components/Icon/MinusIcon.tsx +9 -6
  174. package/src/components/Icon/OpenNewIcon.tsx +9 -6
  175. package/src/components/Icon/PencilIcon.tsx +9 -6
  176. package/src/components/Icon/PhoneIcon.tsx +9 -6
  177. package/src/components/Icon/QuestionIcon.tsx +9 -6
  178. package/src/components/Icon/ScooterIcon.tsx +9 -6
  179. package/src/components/Icon/SearchIcon.tsx +9 -6
  180. package/src/components/Icon/SettingsIcon.tsx +9 -6
  181. package/src/components/Icon/TickAltIcon.tsx +9 -6
  182. package/src/components/Icon/TickIcon.tsx +9 -6
  183. package/src/components/Icon/VanIcon.tsx +9 -6
  184. package/src/components/Icon/WarningIcon.tsx +9 -6
  185. package/src/components/Icon/WriteIcon.tsx +9 -6
  186. package/src/components/Image/Image.tsx +5 -2
  187. package/src/components/Pill/Pill.tsx +8 -7
  188. package/src/components/Radio/Radio.tsx +11 -8
  189. package/src/components/Searchbox/Searchbox.tsx +26 -21
  190. package/src/components/Select/Select.tsx +97 -0
  191. package/src/components/Select/index.ts +5 -0
  192. package/src/components/Signpost/Signpost.tsx +8 -8
  193. package/src/components/SkipNav/SkipNav.tsx +5 -2
  194. package/src/components/Squircle/Squircle.tsx +5 -2
  195. package/src/components/Tag/Tag.tsx +9 -8
  196. package/src/components/TextInput/TextInput.tsx +10 -5
  197. package/src/components/Textarea/Textarea.tsx +9 -7
  198. package/src/index.ts +1 -0
@@ -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,12 +1,14 @@
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
 
5
5
  import { StandardSizes } from "../../../src/types"
6
6
  import { useId } from "../../hooks/useId"
7
7
 
8
- export interface TextInputProps
9
- extends Omit<InputHTMLAttributes<HTMLInputElement>, "prefix" | "size" | "type"> {
8
+ export interface TextInputProps extends Omit<
9
+ InputHTMLAttributes<HTMLInputElement>,
10
+ "prefix" | "size" | "type"
11
+ > {
10
12
  /** **(Optional)** Specify additional CSS classes to be applied to the component. */
11
13
  className?: string
12
14
  /** **(Optional)** Specify whether the TextInput should be disabled. Refer to Experience Library guidance on disabled form controls and accessibility. */
@@ -21,6 +23,8 @@ export interface TextInputProps
21
23
  placeholder?: string
22
24
  /** **(Optional)** Specify the prefix. It can be any valid JSX or string. */
23
25
  prefix?: React.ReactNode
26
+ /** **(Optional)** Specify a custom React ref for this component. */
27
+ ref?: Ref<HTMLInputElement>
24
28
  /** **(Optional)** Specify the TextInput size. */
25
29
  size?: StandardSizes
26
30
  /** **(Optional)** Specify the suffix. It can be any valid JSX or string. */
@@ -50,6 +54,7 @@ export const TextInput = ({
50
54
  name,
51
55
  placeholder,
52
56
  prefix,
57
+ ref,
53
58
  size = "md",
54
59
  suffix,
55
60
  type = "text",
@@ -59,7 +64,7 @@ export const TextInput = ({
59
64
 
60
65
  const componentProps = {
61
66
  "aria-placeholder": placeholder ?? ariaPlaceholder ?? undefined,
62
- className: clsx("coop-text-input", className),
67
+ className: clsx("coop-text-input", "coop-field-element", className),
63
68
  "data-error": error || undefined,
64
69
  "data-size": size.length && size !== "md" ? size : undefined,
65
70
  disabled,
@@ -73,7 +78,7 @@ export const TextInput = ({
73
78
  return (
74
79
  <div className="coop-text-input-wrapper">
75
80
  {prefix && <span className="coop-text-input--prefix">{prefix}</span>}
76
- <input {...componentProps} />
81
+ <input {...componentProps} ref={ref} />
77
82
  {suffix && <span className="coop-text-input--suffix">{suffix}</span>}
78
83
  </div>
79
84
  )
@@ -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,22 +60,21 @@ 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,
71
- className: clsx("coop-textarea", className),
72
+ className: clsx("coop-textarea", "coop-field-element", className),
72
73
  cols,
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
package/src/index.ts CHANGED
@@ -12,6 +12,7 @@ export * from "./components/Pill"
12
12
  export * from "./components/Radio"
13
13
  export * from "./components/RootSVG"
14
14
  export * from "./components/Searchbox"
15
+ export * from "./components/Select"
15
16
  export * from "./components/Signpost"
16
17
  export * from "./components/SkipNav"
17
18
  export * from "./components/Squircle"