@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.
- package/dist/components/AlertBanner/AlertBanner.d.ts +16 -4
- package/dist/components/AlertBanner/AlertBanner.js +8 -3
- package/dist/components/Author/Author.d.ts +4 -2
- package/dist/components/Author/Author.js +2 -2
- package/dist/components/Button/Button.d.ts +1 -1
- package/dist/components/Button/Button.js +1 -2
- package/dist/components/Card/Card.d.ts +4 -2
- package/dist/components/Card/Card.js +2 -2
- package/dist/components/Checkbox/Checkbox.d.ts +4 -2
- package/dist/components/Checkbox/Checkbox.js +3 -3
- package/dist/components/Expandable/Expandable.d.ts +4 -2
- package/dist/components/Expandable/Expandable.js +2 -2
- package/dist/components/Field/Field.d.ts +4 -2
- package/dist/components/Field/Field.js +4 -4
- 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 +5 -6
- package/dist/components/Radio/Radio.d.ts +5 -3
- package/dist/components/Radio/Radio.js +6 -7
- package/dist/components/Searchbox/Searchbox.d.ts +4 -2
- package/dist/components/Searchbox/Searchbox.js +14 -9
- package/dist/components/Select/Select.d.ts +46 -0
- package/dist/components/Select/Select.js +29 -0
- package/dist/components/Select/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 +4 -2
- package/dist/components/TextInput/TextInput.js +3 -3
- package/dist/components/Textarea/Textarea.d.ts +4 -2
- package/dist/components/Textarea/Textarea.js +5 -6
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/package.json +10 -10
- package/src/components/AlertBanner/AlertBanner.tsx +22 -9
- package/src/components/Author/Author.tsx +5 -2
- package/src/components/Button/Button.tsx +2 -3
- package/src/components/Card/Card.tsx +5 -2
- package/src/components/Checkbox/Checkbox.tsx +11 -5
- package/src/components/Expandable/Expandable.tsx +10 -3
- package/src/components/Field/Field.tsx +7 -5
- 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 +8 -7
- package/src/components/Radio/Radio.tsx +11 -8
- package/src/components/Searchbox/Searchbox.tsx +26 -21
- package/src/components/Select/Select.tsx +97 -0
- package/src/components/Select/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 +10 -5
- package/src/components/Textarea/Textarea.tsx +9 -7
- package/src/index.ts +1 -0
|
@@ -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,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
|
-
|
|
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
|
|
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
|
-
|
|
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"
|