@coopdigital/react 1.8.2 → 1.10.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/Author/Author.js +2 -2
- package/dist/components/Button/Button.js +2 -2
- package/dist/components/LoadingSpinner/LoadingSpinner.d.ts +13 -0
- package/dist/components/LoadingSpinner/LoadingSpinner.js +16 -0
- package/dist/components/LoadingSpinner/index.d.ts +4 -0
- package/dist/components/Pill/Pill.js +2 -2
- package/dist/components/Tag/Tag.js +2 -2
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/package.json +3 -3
- package/src/components/Author/Author.tsx +2 -2
- package/src/components/Button/Button.tsx +2 -2
- package/src/components/LoadingSpinner/LoadingSpinner.tsx +35 -0
- package/src/components/LoadingSpinner/index.ts +5 -0
- package/src/components/Pill/Pill.tsx +3 -11
- package/src/components/Tag/Tag.tsx +2 -10
- package/src/index.ts +1 -0
|
@@ -5,14 +5,14 @@ import { Image } from '../Image/Image.js';
|
|
|
5
5
|
const Author = ({ author = "Co-op team", className, date, datePrefix = "", image = {
|
|
6
6
|
alt: "",
|
|
7
7
|
src: "https://s3.eu-west-1.amazonaws.com/assets.digital.coop.co.uk/oneweb/coop-logo-inverted.svg",
|
|
8
|
-
}, ref, size
|
|
8
|
+
}, ref, size, ...props }) => {
|
|
9
9
|
const imageProps = {
|
|
10
10
|
width: "56px",
|
|
11
11
|
...image,
|
|
12
12
|
};
|
|
13
13
|
const componentProps = {
|
|
14
14
|
className: clsx("coop-author", className),
|
|
15
|
-
"data-size": size
|
|
15
|
+
"data-size": (size === null || size === void 0 ? void 0 : size.length) ? size : undefined,
|
|
16
16
|
...props,
|
|
17
17
|
};
|
|
18
18
|
return (jsxs("div", { ...componentProps, ref: ref, children: [image && jsx(Image, { ...imageProps }), jsxs("div", { className: "coop-author--content", children: [jsxs("span", { children: [jsx("span", { children: datePrefix ? datePrefix + " " : "" }), jsx("span", { className: "coop-author--date", children: date })] }), jsxs("span", { children: ["by ", author] })] })] }));
|
|
@@ -3,7 +3,7 @@ import { jsxs, Fragment, jsx } from 'react/jsx-runtime';
|
|
|
3
3
|
import clsx from 'clsx';
|
|
4
4
|
import React, { useState, useCallback } from 'react';
|
|
5
5
|
import { hasUserBg } from '../../utils/index.js';
|
|
6
|
-
import {
|
|
6
|
+
import { LoadingSpinner } from '../LoadingSpinner/LoadingSpinner.js';
|
|
7
7
|
|
|
8
8
|
const Button = ({ as, children, className, href, isDisabled = false, isFullWidth = false, isLoading = false, loadingText = "Loading", onClick, ref, size, variant = "solid", ...props }) => {
|
|
9
9
|
const element = as !== null && as !== void 0 ? as : (href ? "a" : "button");
|
|
@@ -30,7 +30,7 @@ const Button = ({ as, children, className, href, isDisabled = false, isFullWidth
|
|
|
30
30
|
onClick: onClick ? handleClick : undefined,
|
|
31
31
|
...props,
|
|
32
32
|
};
|
|
33
|
-
const finalChildren = isPending || isLoading ? (jsxs(Fragment, { children: [loadingText, jsx(
|
|
33
|
+
const finalChildren = isPending || isLoading ? (jsxs(Fragment, { children: [loadingText, jsx(LoadingSpinner, {})] })) : (children);
|
|
34
34
|
return React.createElement(element, { ...componentProps, ref }, finalChildren);
|
|
35
35
|
};
|
|
36
36
|
Button.slot = { name: "Button" };
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { JSX, Ref, SVGProps } from "react";
|
|
2
|
+
export interface LoadingSpinnerProps extends SVGProps<SVGSVGElement> {
|
|
3
|
+
/** **(Optional)** Specify additional CSS classes to be applied to the component. */
|
|
4
|
+
className?: string;
|
|
5
|
+
/** **(Optional)** Specify a custom React ref for this component. */
|
|
6
|
+
ref?: Ref<SVGSVGElement>;
|
|
7
|
+
/** **(Optional)** Specify LoadingSpinner stroke. */
|
|
8
|
+
stroke?: string;
|
|
9
|
+
/** **(Optional)** Specify LoadingSpinner stroke width. */
|
|
10
|
+
strokeWidth?: string;
|
|
11
|
+
}
|
|
12
|
+
export declare const LoadingSpinner: ({ className, ref, stroke, strokeWidth, ...props }: LoadingSpinnerProps) => JSX.Element;
|
|
13
|
+
export default LoadingSpinner;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { jsx } from 'react/jsx-runtime';
|
|
2
|
+
import clsx from 'clsx';
|
|
3
|
+
import 'react';
|
|
4
|
+
import { LoadingIcon } from '../icons/LoadingIcon.js';
|
|
5
|
+
|
|
6
|
+
const LoadingSpinner = ({ className, ref, stroke = "currentColor", strokeWidth = "1px", ...props }) => {
|
|
7
|
+
const componentProps = {
|
|
8
|
+
className: clsx("coop-loading-spinner ", className),
|
|
9
|
+
stroke,
|
|
10
|
+
strokeWidth,
|
|
11
|
+
...props,
|
|
12
|
+
};
|
|
13
|
+
return jsx(LoadingIcon, { ...componentProps, ref: ref });
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
export { LoadingSpinner, LoadingSpinner as default };
|
|
@@ -8,12 +8,12 @@ const componentSlots = {
|
|
|
8
8
|
Children: null,
|
|
9
9
|
PillBadge: null,
|
|
10
10
|
};
|
|
11
|
-
const Pill = ({ as, children, className, href, ref, size
|
|
11
|
+
const Pill = ({ as, children, className, href, ref, size, ...props }) => {
|
|
12
12
|
const element = as !== null && as !== void 0 ? as : (href ? "a" : "span");
|
|
13
13
|
const slots = useSlots(componentSlots, children);
|
|
14
14
|
const componentProps = {
|
|
15
15
|
className: clsx("coop-pill", !hasUserBg(className) && "bg-tint-grey", className),
|
|
16
|
-
"data-size": size
|
|
16
|
+
"data-size": (size === null || size === void 0 ? void 0 : size.length) ? size : undefined,
|
|
17
17
|
href,
|
|
18
18
|
...props,
|
|
19
19
|
};
|
|
@@ -2,11 +2,11 @@ import clsx from 'clsx';
|
|
|
2
2
|
import React from 'react';
|
|
3
3
|
import { hasUserBg } from '../../utils/index.js';
|
|
4
4
|
|
|
5
|
-
const Tag = ({ as, children, className, href, ref, size
|
|
5
|
+
const Tag = ({ as, children, className, href, ref, size, ...props }) => {
|
|
6
6
|
const element = as !== null && as !== void 0 ? as : (href ? "a" : "span");
|
|
7
7
|
const componentProps = {
|
|
8
8
|
className: clsx("coop-tag", !hasUserBg(className) && "bg-tint-grey", className),
|
|
9
|
-
"data-size": size
|
|
9
|
+
"data-size": (size === null || size === void 0 ? void 0 : size.length) ? size : undefined,
|
|
10
10
|
href,
|
|
11
11
|
...props,
|
|
12
12
|
};
|
package/dist/index.d.ts
CHANGED
|
@@ -11,6 +11,7 @@ export * from "./components/Fieldset";
|
|
|
11
11
|
export * from "./components/Flourish";
|
|
12
12
|
export * from "./components/Form";
|
|
13
13
|
export * from "./components/Image";
|
|
14
|
+
export * from "./components/LoadingSpinner";
|
|
14
15
|
export * from "./components/Pill";
|
|
15
16
|
export * from "./components/Popover";
|
|
16
17
|
export * from "./components/Radio";
|
package/dist/index.js
CHANGED
|
@@ -11,6 +11,7 @@ export { Fieldset, FieldsetError, FieldsetFields, FieldsetHint, FieldsetLegend }
|
|
|
11
11
|
export { Flourish } from './components/Flourish/Flourish.js';
|
|
12
12
|
export { Form } from './components/Form/Form.js';
|
|
13
13
|
export { Image } from './components/Image/Image.js';
|
|
14
|
+
export { LoadingSpinner } from './components/LoadingSpinner/LoadingSpinner.js';
|
|
14
15
|
export { Pill, PillBadge } from './components/Pill/Pill.js';
|
|
15
16
|
export { Popover, PopoverAnchor, PopoverClose, PopoverContent, PopoverTrigger } from './components/Popover/Popover.js';
|
|
16
17
|
export { Radio } from './components/Radio/Radio.js';
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@coopdigital/react",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "1.
|
|
4
|
+
"version": "1.10.0",
|
|
5
5
|
"private": false,
|
|
6
6
|
"publishConfig": {
|
|
7
7
|
"access": "public"
|
|
@@ -100,11 +100,11 @@
|
|
|
100
100
|
"storybook": "$storybook"
|
|
101
101
|
},
|
|
102
102
|
"dependencies": {
|
|
103
|
-
"@coopdigital/styles": "^1.
|
|
103
|
+
"@coopdigital/styles": "^1.7.0",
|
|
104
104
|
"@radix-ui/react-popover": "^1.1.17",
|
|
105
105
|
"clsx": "^2.1.1",
|
|
106
106
|
"merge-refs": "^2.0.0",
|
|
107
107
|
"react-day-picker": "^10.0.1"
|
|
108
108
|
},
|
|
109
|
-
"gitHead": "
|
|
109
|
+
"gitHead": "9617cab1d149ce04be999b407f9128204dfc7edd"
|
|
110
110
|
}
|
|
@@ -31,7 +31,7 @@ const Author = ({
|
|
|
31
31
|
src: "https://s3.eu-west-1.amazonaws.com/assets.digital.coop.co.uk/oneweb/coop-logo-inverted.svg",
|
|
32
32
|
},
|
|
33
33
|
ref,
|
|
34
|
-
size
|
|
34
|
+
size,
|
|
35
35
|
...props
|
|
36
36
|
}: AuthorProps): JSX.Element => {
|
|
37
37
|
const imageProps: ImageProps = {
|
|
@@ -41,7 +41,7 @@ const Author = ({
|
|
|
41
41
|
|
|
42
42
|
const componentProps = {
|
|
43
43
|
className: clsx("coop-author", className),
|
|
44
|
-
"data-size": size
|
|
44
|
+
"data-size": size?.length ? size : undefined,
|
|
45
45
|
...props,
|
|
46
46
|
}
|
|
47
47
|
return (
|
|
@@ -6,7 +6,7 @@ import clsx from "clsx"
|
|
|
6
6
|
import React, { useCallback, useState } from "react"
|
|
7
7
|
|
|
8
8
|
import { hasUserBg } from "../../utils"
|
|
9
|
-
import {
|
|
9
|
+
import { LoadingSpinner } from "./../LoadingSpinner"
|
|
10
10
|
|
|
11
11
|
export interface ButtonProps extends ButtonHTMLAttributes<HTMLButtonElement> {
|
|
12
12
|
/** **(Optional)** Specify a custom element to override default `a` or `button`. */
|
|
@@ -94,7 +94,7 @@ const Button = ({
|
|
|
94
94
|
isPending || isLoading ? (
|
|
95
95
|
<>
|
|
96
96
|
{loadingText}
|
|
97
|
-
<
|
|
97
|
+
<LoadingSpinner />
|
|
98
98
|
</>
|
|
99
99
|
) : (
|
|
100
100
|
children
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import type { JSX, Ref, SVGProps } from "react"
|
|
2
|
+
|
|
3
|
+
import clsx from "clsx"
|
|
4
|
+
|
|
5
|
+
import { LoadingIcon } from "../icons"
|
|
6
|
+
|
|
7
|
+
export interface LoadingSpinnerProps extends SVGProps<SVGSVGElement> {
|
|
8
|
+
/** **(Optional)** Specify additional CSS classes to be applied to the component. */
|
|
9
|
+
className?: string
|
|
10
|
+
/** **(Optional)** Specify a custom React ref for this component. */
|
|
11
|
+
ref?: Ref<SVGSVGElement>
|
|
12
|
+
/** **(Optional)** Specify LoadingSpinner stroke. */
|
|
13
|
+
stroke?: string
|
|
14
|
+
/** **(Optional)** Specify LoadingSpinner stroke width. */
|
|
15
|
+
strokeWidth?: string
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
export const LoadingSpinner = ({
|
|
19
|
+
className,
|
|
20
|
+
ref,
|
|
21
|
+
stroke = "currentColor",
|
|
22
|
+
strokeWidth = "1px",
|
|
23
|
+
...props
|
|
24
|
+
}: LoadingSpinnerProps): JSX.Element => {
|
|
25
|
+
const componentProps = {
|
|
26
|
+
className: clsx("coop-loading-spinner ", className),
|
|
27
|
+
stroke,
|
|
28
|
+
strokeWidth,
|
|
29
|
+
...props,
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
return <LoadingIcon {...componentProps} ref={ref} />
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
export default LoadingSpinner
|
|
@@ -9,7 +9,7 @@ import { hasUserBg } from "../../utils"
|
|
|
9
9
|
|
|
10
10
|
export interface PillProps extends HTMLAttributes<HTMLAnchorElement> {
|
|
11
11
|
/** **(Optional)** Specify a custom element to override default `a` or `span`. */
|
|
12
|
-
// oxlint-disable-next-line
|
|
12
|
+
// oxlint-disable-next-line typescript/no-explicit-any
|
|
13
13
|
as?: React.FC<any> | ForwardRefExoticComponent<any> | string
|
|
14
14
|
/** **(Optional)** Main content inside the component. It can be any valid JSX or string. */
|
|
15
15
|
children?: React.ReactNode
|
|
@@ -35,22 +35,14 @@ const componentSlots = {
|
|
|
35
35
|
PillBadge: null,
|
|
36
36
|
}
|
|
37
37
|
|
|
38
|
-
const Pill = ({
|
|
39
|
-
as,
|
|
40
|
-
children,
|
|
41
|
-
className,
|
|
42
|
-
href,
|
|
43
|
-
ref,
|
|
44
|
-
size = "md",
|
|
45
|
-
...props
|
|
46
|
-
}: PillProps): JSX.Element => {
|
|
38
|
+
const Pill = ({ as, children, className, href, ref, size, ...props }: PillProps): JSX.Element => {
|
|
47
39
|
const element: PillProps["as"] = as ?? (href ? "a" : "span")
|
|
48
40
|
|
|
49
41
|
const slots = useSlots(componentSlots, children)
|
|
50
42
|
|
|
51
43
|
const componentProps = {
|
|
52
44
|
className: clsx("coop-pill", !hasUserBg(className) && "bg-tint-grey", className),
|
|
53
|
-
"data-size": size
|
|
45
|
+
"data-size": size?.length ? size : undefined,
|
|
54
46
|
href,
|
|
55
47
|
...props,
|
|
56
48
|
}
|
|
@@ -21,20 +21,12 @@ export interface TagProps extends HTMLAttributes<HTMLAnchorElement> {
|
|
|
21
21
|
size?: "sm" | "md"
|
|
22
22
|
}
|
|
23
23
|
|
|
24
|
-
const Tag = ({
|
|
25
|
-
as,
|
|
26
|
-
children,
|
|
27
|
-
className,
|
|
28
|
-
href,
|
|
29
|
-
ref,
|
|
30
|
-
size = "md",
|
|
31
|
-
...props
|
|
32
|
-
}: TagProps): JSX.Element => {
|
|
24
|
+
const Tag = ({ as, children, className, href, ref, size, ...props }: TagProps): JSX.Element => {
|
|
33
25
|
const element: TagProps["as"] = as ?? (href ? "a" : "span")
|
|
34
26
|
|
|
35
27
|
const componentProps = {
|
|
36
28
|
className: clsx("coop-tag", !hasUserBg(className) && "bg-tint-grey", className),
|
|
37
|
-
"data-size": size
|
|
29
|
+
"data-size": size?.length ? size : undefined,
|
|
38
30
|
href,
|
|
39
31
|
...props,
|
|
40
32
|
}
|
package/src/index.ts
CHANGED
|
@@ -11,6 +11,7 @@ export * from "./components/Fieldset"
|
|
|
11
11
|
export * from "./components/Flourish"
|
|
12
12
|
export * from "./components/Form"
|
|
13
13
|
export * from "./components/Image"
|
|
14
|
+
export * from "./components/LoadingSpinner"
|
|
14
15
|
export * from "./components/Pill"
|
|
15
16
|
export * from "./components/Popover"
|
|
16
17
|
export * from "./components/Radio"
|