@coopdigital/react 0.18.1 → 0.19.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/Button/Button.d.ts +1 -1
- package/dist/components/Button/Button.js +2 -4
- package/dist/components/Card/Card.d.ts +1 -1
- package/dist/components/Expandable/Expandable.d.ts +1 -1
- package/dist/components/Icon/LoadingIcon.d.ts +6 -0
- package/dist/components/Icon/LoadingIcon.js +12 -0
- package/dist/components/Icon/index.d.ts +1 -0
- package/dist/components/SearchBox/SearchBox.d.ts +1 -1
- package/dist/components/SearchBox/SearchBox.js +2 -2
- package/dist/components/Tag/Tag.d.ts +1 -1
- package/package.json +3 -3
- package/src/components/Button/Button.tsx +13 -18
- package/src/components/Card/Card.tsx +11 -1
- package/src/components/Expandable/Expandable.tsx +2 -1
- package/src/components/Icon/LoadingIcon.tsx +27 -0
- package/src/components/Icon/index.tsx +1 -0
- package/src/components/SearchBox/SearchBox.tsx +11 -3
- package/src/components/Tag/Tag.tsx +2 -1
|
@@ -22,7 +22,7 @@ export interface ButtonProps extends ButtonHTMLAttributes<HTMLButtonElement> {
|
|
|
22
22
|
/** **(Optional)** Specifies the Button size. */
|
|
23
23
|
size?: "sm" | "md" | "lg" | "xl";
|
|
24
24
|
/** **(Optional)** Specifies the Button variant. */
|
|
25
|
-
variant?: "
|
|
25
|
+
variant?: "green" | "blue" | "white" | "grey" | "green-ghost" | "blue-ghost" | "white-ghost" | "grey-ghost" | "text";
|
|
26
26
|
}
|
|
27
27
|
/**
|
|
28
28
|
* The Button component is an interactive element that people can use to take an action.
|
|
@@ -1,15 +1,13 @@
|
|
|
1
1
|
import { __rest, __awaiter } from '../../node_modules/tslib/tslib.es6.js';
|
|
2
2
|
import { jsxs, Fragment, jsx } from 'react/jsx-runtime';
|
|
3
3
|
import React, { useState, useCallback } from 'react';
|
|
4
|
+
import { LoadingIcon } from '../Icon/LoadingIcon.js';
|
|
4
5
|
|
|
5
|
-
const LoadingIcon = () => {
|
|
6
|
-
return (jsx("svg", { fill: "none", stroke: "currentColor", strokeLinecap: "round", strokeLinejoin: "round", strokeWidth: "2", viewBox: "0 0 24 24", xmlns: "http://www.w3.org/2000/svg", children: jsx("path", { d: "M21 12a9 9 0 1 1-6.219-8.56" }) }));
|
|
7
|
-
};
|
|
8
6
|
/**
|
|
9
7
|
* The Button component is an interactive element that people can use to take an action.
|
|
10
8
|
*/
|
|
11
9
|
const Button = (_a) => {
|
|
12
|
-
var { as, children, className = "", href, isDisabled = false, isFullWidth = false, isLoading = false, loadingText = "Loading", onClick, size = "md", variant = "
|
|
10
|
+
var { as, children, className = "", href, isDisabled = false, isFullWidth = false, isLoading = false, loadingText = "Loading", onClick, size = "md", variant = "green" } = _a, props = __rest(_a, ["as", "children", "className", "href", "isDisabled", "isFullWidth", "isLoading", "loadingText", "onClick", "size", "variant"]);
|
|
13
11
|
let element = href ? "a" : "button";
|
|
14
12
|
if (as) {
|
|
15
13
|
element = as;
|
|
@@ -5,7 +5,7 @@ export interface CardProps extends HTMLAttributes<HTMLDivElement> {
|
|
|
5
5
|
/** **(Optional)** Specifies the custom element to override default `a` */
|
|
6
6
|
as?: React.FC<AnchorHTMLAttributes<HTMLElement>> | ForwardRefExoticComponent<any> | string;
|
|
7
7
|
/** **(Optional)** Specifies the background color of the card. */
|
|
8
|
-
background?: "purple" | "pink" | "green" | "orange" | "red" | "yellow" | "lilac" | "blue";
|
|
8
|
+
background?: "purple" | "pink" | "green" | "orange" | "red" | "yellow" | "lilac" | "blue" | "brown" | "grey";
|
|
9
9
|
/** **(Optional)** Represents the content inside the badge. */
|
|
10
10
|
badge?: React.ReactNode;
|
|
11
11
|
/** **(Optional)** Specify badge position relative to top right corner. */
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { DetailsHTMLAttributes, JSX } from "react";
|
|
2
2
|
export interface ExpandableProps extends DetailsHTMLAttributes<HTMLDetailsElement> {
|
|
3
3
|
/** **(Optional)** Specifies the Expandable background color from the available options. */
|
|
4
|
-
background?: "
|
|
4
|
+
background?: "purple" | "pink" | "green" | "orange" | "red" | "yellow" | "lilac" | "blue" | "white" | "transparent" | "brown" | "grey";
|
|
5
5
|
/** Represents the content inside the Expandable component, only visible when expanded. It can be any valid JSX or string. */
|
|
6
6
|
children: React.ReactNode;
|
|
7
7
|
/** **(Optional)** Receives any className to be applied to Expandable component. */
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { __rest } from '../../node_modules/tslib/tslib.es6.js';
|
|
2
|
+
import { jsxs, jsx } from 'react/jsx-runtime';
|
|
3
|
+
import { useId } from 'react';
|
|
4
|
+
|
|
5
|
+
const LoadingIcon = (_a) => {
|
|
6
|
+
var { alt, className } = _a, props = __rest(_a, ["alt", "className"]);
|
|
7
|
+
const id = useId();
|
|
8
|
+
const componentProps = Object.assign({ "aria-labelledby": alt ? id : undefined, className: `coop-icon ${className !== null && className !== void 0 ? className : ""}`.trim(), "data-icon": "loading", fill: "none", role: alt ? "img" : undefined, viewBox: "0 0 24 24" }, props);
|
|
9
|
+
return (jsxs("svg", Object.assign({}, componentProps, { children: [alt ? jsx("title", { id: id, children: alt }) : null, jsx("path", { d: "M10.72 19.9a8 8 0 0 1-6.5-9.79 7.77 7.77 0 0 1 6.18-5.95 8 8 0 0 1 9.49 6.52A1.54 1.54 0 0 0 21.38 12h.13a1.37 1.37 0 0 0 1.38-1.54 11 11 0 1 0-12.7 12.39A1.54 1.54 0 0 0 12 21.34a1.47 1.47 0 0 0-1.28-1.44", fill: "currentColor" })] })));
|
|
10
|
+
};
|
|
11
|
+
|
|
12
|
+
export { LoadingIcon };
|
|
@@ -20,6 +20,7 @@ export { CoopLocationIcon } from "./CoopLocationIcon";
|
|
|
20
20
|
export { DownloadIcon } from "./DownloadIcon";
|
|
21
21
|
export { HomeIcon } from "./HomeIcon";
|
|
22
22
|
export { InformationIcon } from "./InformationIcon";
|
|
23
|
+
export { LoadingIcon } from "./LoadingIcon";
|
|
23
24
|
export { LocationIcon } from "./LocationIcon";
|
|
24
25
|
export { MailIcon } from "./MailIcon";
|
|
25
26
|
export { MenuIcon } from "./MenuIcon";
|
|
@@ -25,7 +25,7 @@ export interface SearchBoxProps extends HTMLAttributes<HTMLInputElement> {
|
|
|
25
25
|
/** **(Optional)** Receives any size to be applied to SearchBox component. */
|
|
26
26
|
size?: string;
|
|
27
27
|
/** **(Optional)** Receives the variant to be applied to SearchBox component. */
|
|
28
|
-
variant?: "
|
|
28
|
+
variant?: "green" | "blue" | "white" | "grey" | "green-ghost" | "blue-ghost" | "white-ghost" | "grey-ghost";
|
|
29
29
|
}
|
|
30
30
|
/**
|
|
31
31
|
* SearchBox component allows a person to enter a word or a phrase to find relevant content.
|
|
@@ -27,7 +27,7 @@ const defaultButtonProps = {
|
|
|
27
27
|
*/
|
|
28
28
|
const SearchBox = (_a) => {
|
|
29
29
|
var _b, _c;
|
|
30
|
-
var { action, "aria-placeholder": ariaPlaceholder, autoCapitalize = "off", autoComplete = "off", button = defaultButtonProps, className, label, labelVisible = false, name = "query", onSubmit, placeholder, size = "md", variant = "
|
|
30
|
+
var { action, "aria-placeholder": ariaPlaceholder, autoCapitalize = "off", autoComplete = "off", button = defaultButtonProps, className, label, labelVisible = false, name = "query", onSubmit, placeholder, size = "md", variant = "green" } = _a, props = __rest(_a, ["action", "aria-placeholder", "autoCapitalize", "autoComplete", "button", "className", "label", "labelVisible", "name", "onSubmit", "placeholder", "size", "variant"]);
|
|
31
31
|
const [isPending, setIsPending] = useState(false);
|
|
32
32
|
const handleSubmit = useCallback((event) => __awaiter(void 0, void 0, void 0, function* () {
|
|
33
33
|
event.preventDefault();
|
|
@@ -46,7 +46,7 @@ const SearchBox = (_a) => {
|
|
|
46
46
|
action: action !== null && action !== void 0 ? action : undefined,
|
|
47
47
|
className: `coop-search-box ${className !== null && className !== void 0 ? className : ""}`.trim(),
|
|
48
48
|
"data-size": size.length && size !== "md" ? size : undefined,
|
|
49
|
-
"data-variant": variant.length && variant !== "
|
|
49
|
+
"data-variant": variant.length && variant !== "green" ? variant : undefined,
|
|
50
50
|
onSubmit: onSubmit ? handleSubmit : undefined,
|
|
51
51
|
};
|
|
52
52
|
const buttonProps = {
|
|
@@ -10,7 +10,7 @@ export interface TagProps extends HTMLAttributes<HTMLAnchorElement> {
|
|
|
10
10
|
/** **(Optional)** Specifies the URL that the Tag component will link to when clicked. */
|
|
11
11
|
href?: string;
|
|
12
12
|
/** **(Optional)** Specifies the Tag background color from the available options. */
|
|
13
|
-
tagColor?: "white" | "
|
|
13
|
+
tagColor?: "white" | "purple" | "pink" | "green" | "orange" | "red" | "yellow" | "lilac" | "blue" | "brown" | "grey";
|
|
14
14
|
}
|
|
15
15
|
/**
|
|
16
16
|
* Tag is a simple component that is meant to communicate a brief message such as categories.
|
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.19.0",
|
|
5
5
|
"private": false,
|
|
6
6
|
"publishConfig": {
|
|
7
7
|
"access": "public"
|
|
@@ -45,7 +45,7 @@
|
|
|
45
45
|
"description": "",
|
|
46
46
|
"devDependencies": {
|
|
47
47
|
"@axe-core/playwright": "^4.10.1",
|
|
48
|
-
"@coopdigital/styles": "^0.
|
|
48
|
+
"@coopdigital/styles": "^0.16.0",
|
|
49
49
|
"@playwright/test": "^1.52.0",
|
|
50
50
|
"@storybook/addon-a11y": "^8.6.12",
|
|
51
51
|
"@storybook/addon-essentials": "^8.6.12",
|
|
@@ -67,5 +67,5 @@
|
|
|
67
67
|
"react": "^19.1.0",
|
|
68
68
|
"react-dom": "^19.1.0"
|
|
69
69
|
},
|
|
70
|
-
"gitHead": "
|
|
70
|
+
"gitHead": "c3b9ce837060a373926286d2a770796f75f8c168"
|
|
71
71
|
}
|
|
@@ -7,6 +7,8 @@ import type {
|
|
|
7
7
|
|
|
8
8
|
import React, { useCallback, useState } from "react"
|
|
9
9
|
|
|
10
|
+
import { LoadingIcon } from "../Icon"
|
|
11
|
+
|
|
10
12
|
export interface ButtonProps extends ButtonHTMLAttributes<HTMLButtonElement> {
|
|
11
13
|
/** **(Optional)** Specifies the custom element to override default `a` or `button`. */
|
|
12
14
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
@@ -30,29 +32,22 @@ export interface ButtonProps extends ButtonHTMLAttributes<HTMLButtonElement> {
|
|
|
30
32
|
/** **(Optional)** Specifies the Button size. */
|
|
31
33
|
size?: "sm" | "md" | "lg" | "xl"
|
|
32
34
|
/** **(Optional)** Specifies the Button variant. */
|
|
33
|
-
variant?:
|
|
35
|
+
variant?:
|
|
36
|
+
| "green"
|
|
37
|
+
| "blue"
|
|
38
|
+
| "white"
|
|
39
|
+
| "grey"
|
|
40
|
+
| "green-ghost"
|
|
41
|
+
| "blue-ghost"
|
|
42
|
+
| "white-ghost"
|
|
43
|
+
| "grey-ghost"
|
|
44
|
+
| "text"
|
|
34
45
|
}
|
|
35
46
|
|
|
36
47
|
type OnClickHandler =
|
|
37
48
|
| React.MouseEventHandler<HTMLButtonElement | HTMLAnchorElement>
|
|
38
49
|
| ((event: React.MouseEvent<HTMLButtonElement | HTMLAnchorElement>) => Promise<void>)
|
|
39
50
|
|
|
40
|
-
const LoadingIcon = () => {
|
|
41
|
-
return (
|
|
42
|
-
<svg
|
|
43
|
-
fill="none"
|
|
44
|
-
stroke="currentColor"
|
|
45
|
-
strokeLinecap="round"
|
|
46
|
-
strokeLinejoin="round"
|
|
47
|
-
strokeWidth="2"
|
|
48
|
-
viewBox="0 0 24 24"
|
|
49
|
-
xmlns="http://www.w3.org/2000/svg"
|
|
50
|
-
>
|
|
51
|
-
<path d="M21 12a9 9 0 1 1-6.219-8.56" />
|
|
52
|
-
</svg>
|
|
53
|
-
)
|
|
54
|
-
}
|
|
55
|
-
|
|
56
51
|
/**
|
|
57
52
|
* The Button component is an interactive element that people can use to take an action.
|
|
58
53
|
*/
|
|
@@ -67,7 +62,7 @@ export const Button = ({
|
|
|
67
62
|
loadingText = "Loading",
|
|
68
63
|
onClick,
|
|
69
64
|
size = "md",
|
|
70
|
-
variant = "
|
|
65
|
+
variant = "green",
|
|
71
66
|
...props
|
|
72
67
|
}: ButtonProps): JSX.Element => {
|
|
73
68
|
let element: ButtonProps["as"] = href ? "a" : "button"
|
|
@@ -10,7 +10,17 @@ export interface CardProps extends HTMLAttributes<HTMLDivElement> {
|
|
|
10
10
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
11
11
|
as?: React.FC<AnchorHTMLAttributes<HTMLElement>> | ForwardRefExoticComponent<any> | string
|
|
12
12
|
/** **(Optional)** Specifies the background color of the card. */
|
|
13
|
-
background?:
|
|
13
|
+
background?:
|
|
14
|
+
| "purple"
|
|
15
|
+
| "pink"
|
|
16
|
+
| "green"
|
|
17
|
+
| "orange"
|
|
18
|
+
| "red"
|
|
19
|
+
| "yellow"
|
|
20
|
+
| "lilac"
|
|
21
|
+
| "blue"
|
|
22
|
+
| "brown"
|
|
23
|
+
| "grey"
|
|
14
24
|
/** **(Optional)** Represents the content inside the badge. */
|
|
15
25
|
badge?: React.ReactNode
|
|
16
26
|
/** **(Optional)** Specify badge position relative to top right corner. */
|
|
@@ -3,7 +3,6 @@ import type { DetailsHTMLAttributes, JSX } from "react"
|
|
|
3
3
|
export interface ExpandableProps extends DetailsHTMLAttributes<HTMLDetailsElement> {
|
|
4
4
|
/** **(Optional)** Specifies the Expandable background color from the available options. */
|
|
5
5
|
background?:
|
|
6
|
-
| "grey"
|
|
7
6
|
| "purple"
|
|
8
7
|
| "pink"
|
|
9
8
|
| "green"
|
|
@@ -14,6 +13,8 @@ export interface ExpandableProps extends DetailsHTMLAttributes<HTMLDetailsElemen
|
|
|
14
13
|
| "blue"
|
|
15
14
|
| "white"
|
|
16
15
|
| "transparent"
|
|
16
|
+
| "brown"
|
|
17
|
+
| "grey"
|
|
17
18
|
/** Represents the content inside the Expandable component, only visible when expanded. It can be any valid JSX or string. */
|
|
18
19
|
children: React.ReactNode
|
|
19
20
|
/** **(Optional)** Receives any className to be applied to Expandable component. */
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { type SVGProps, useId } from "react"
|
|
2
|
+
|
|
3
|
+
interface IconProps extends SVGProps<SVGSVGElement> {
|
|
4
|
+
alt?: string
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
export const LoadingIcon = ({ alt, className, ...props }: IconProps) => {
|
|
8
|
+
const id = useId()
|
|
9
|
+
const componentProps = {
|
|
10
|
+
"aria-labelledby": alt ? id : undefined,
|
|
11
|
+
className: `coop-icon ${className ?? ""}`.trim(),
|
|
12
|
+
"data-icon": "loading",
|
|
13
|
+
fill: "none",
|
|
14
|
+
role: alt ? "img" : undefined,
|
|
15
|
+
viewBox: "0 0 24 24",
|
|
16
|
+
...props,
|
|
17
|
+
}
|
|
18
|
+
return (
|
|
19
|
+
<svg {...componentProps}>
|
|
20
|
+
{alt ? <title id={id}>{alt}</title> : null}
|
|
21
|
+
<path
|
|
22
|
+
d="M10.72 19.9a8 8 0 0 1-6.5-9.79 7.77 7.77 0 0 1 6.18-5.95 8 8 0 0 1 9.49 6.52A1.54 1.54 0 0 0 21.38 12h.13a1.37 1.37 0 0 0 1.38-1.54 11 11 0 1 0-12.7 12.39A1.54 1.54 0 0 0 12 21.34a1.47 1.47 0 0 0-1.28-1.44"
|
|
23
|
+
fill="currentColor"
|
|
24
|
+
/>
|
|
25
|
+
</svg>
|
|
26
|
+
)
|
|
27
|
+
}
|
|
@@ -20,6 +20,7 @@ export { CoopLocationIcon } from "./CoopLocationIcon"
|
|
|
20
20
|
export { DownloadIcon } from "./DownloadIcon"
|
|
21
21
|
export { HomeIcon } from "./HomeIcon"
|
|
22
22
|
export { InformationIcon } from "./InformationIcon"
|
|
23
|
+
export { LoadingIcon } from "./LoadingIcon"
|
|
23
24
|
export { LocationIcon } from "./LocationIcon"
|
|
24
25
|
export { MailIcon } from "./MailIcon"
|
|
25
26
|
export { MenuIcon } from "./MenuIcon"
|
|
@@ -26,7 +26,15 @@ export interface SearchBoxProps extends HTMLAttributes<HTMLInputElement> {
|
|
|
26
26
|
/** **(Optional)** Receives any size to be applied to SearchBox component. */
|
|
27
27
|
size?: string
|
|
28
28
|
/** **(Optional)** Receives the variant to be applied to SearchBox component. */
|
|
29
|
-
variant?:
|
|
29
|
+
variant?:
|
|
30
|
+
| "green"
|
|
31
|
+
| "blue"
|
|
32
|
+
| "white"
|
|
33
|
+
| "grey"
|
|
34
|
+
| "green-ghost"
|
|
35
|
+
| "blue-ghost"
|
|
36
|
+
| "white-ghost"
|
|
37
|
+
| "grey-ghost"
|
|
30
38
|
}
|
|
31
39
|
|
|
32
40
|
const defaultButtonProps: SearchBoxProps["button"] = {
|
|
@@ -64,7 +72,7 @@ export const SearchBox = ({
|
|
|
64
72
|
onSubmit,
|
|
65
73
|
placeholder,
|
|
66
74
|
size = "md",
|
|
67
|
-
variant = "
|
|
75
|
+
variant = "green",
|
|
68
76
|
...props
|
|
69
77
|
}: SearchBoxProps): JSX.Element => {
|
|
70
78
|
const [isPending, setIsPending] = useState(false)
|
|
@@ -92,7 +100,7 @@ export const SearchBox = ({
|
|
|
92
100
|
action: action ?? undefined,
|
|
93
101
|
className: `coop-search-box ${className ?? ""}`.trim(),
|
|
94
102
|
"data-size": size.length && size !== "md" ? size : undefined,
|
|
95
|
-
"data-variant": variant.length && variant !== "
|
|
103
|
+
"data-variant": variant.length && variant !== "green" ? variant : undefined,
|
|
96
104
|
onSubmit: onSubmit ? handleSubmit : undefined,
|
|
97
105
|
}
|
|
98
106
|
|
|
@@ -15,7 +15,6 @@ export interface TagProps extends HTMLAttributes<HTMLAnchorElement> {
|
|
|
15
15
|
/** **(Optional)** Specifies the Tag background color from the available options. */
|
|
16
16
|
tagColor?:
|
|
17
17
|
| "white"
|
|
18
|
-
| "grey"
|
|
19
18
|
| "purple"
|
|
20
19
|
| "pink"
|
|
21
20
|
| "green"
|
|
@@ -24,6 +23,8 @@ export interface TagProps extends HTMLAttributes<HTMLAnchorElement> {
|
|
|
24
23
|
| "yellow"
|
|
25
24
|
| "lilac"
|
|
26
25
|
| "blue"
|
|
26
|
+
| "brown"
|
|
27
|
+
| "grey"
|
|
27
28
|
}
|
|
28
29
|
|
|
29
30
|
/**
|