@coopdigital/react 1.26.0 → 1.27.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.
@@ -3,25 +3,35 @@ import "../Image/index.js";
3
3
  import { HTMLAttributes, JSX, Ref } from "react";
4
4
  //#region src/components/Author/Author.d.ts
5
5
  export interface AuthorProps extends HTMLAttributes<HTMLDivElement> {
6
- /** Specify the Author name. */
7
- author?: string;
6
+ /** Content inside the component.
7
+ *
8
+ * This should be a set of `<Author.Image>` and `<Author.Meta>`. */
9
+ children?: React.ReactNode;
8
10
  /** Specify additional CSS classes. */
9
11
  className?: string;
12
+ /** Specify a custom React ref for this component. */
13
+ ref?: Ref<HTMLDivElement>;
14
+ /** Specify the component size. */
15
+ size?: "sm" | "md";
16
+ }
17
+ export interface AuthorMetaProps extends HTMLAttributes<HTMLDivElement> {
10
18
  /** Specify the date.
11
19
  *
12
20
  * Recommended format `dd mmmm yyyy` eg: 1 January 2000. */
13
21
  date?: string;
14
22
  /** Specify the text that will prefix the date, e.g. "Updated". */
15
23
  datePrefix?: string;
16
- /** Specify properties of the Author Image. */
17
- image?: ImageProps;
18
- /** Specify a custom React ref for this component. */
19
- ref?: Ref<HTMLDivElement>;
20
- /** Specify the component size. */
21
- size?: "sm" | "md";
24
+ /** Specify the Author name. */
25
+ name?: string;
26
+ }
27
+ export interface AuthorImageProps extends Partial<ImageProps> {
28
+ alt?: string;
29
+ src?: string;
22
30
  }
23
31
  declare const Author: {
24
- ({ author, className, date, datePrefix, image, ref, size, ...props }: AuthorProps): JSX.Element;
32
+ ({ children, className, ref, size, ...props }: AuthorProps): JSX.Element;
33
+ Image: ({ alt, src, ...props }: AuthorImageProps) => JSX.Element;
34
+ Meta: ({ date, datePrefix, name, ...props }: AuthorMetaProps) => JSX.Element;
25
35
  slot: {
26
36
  name: string;
27
37
  };
@@ -2,31 +2,44 @@ import { Image } from "../Image/Image.js";
2
2
  import clsx from "clsx";
3
3
  import { jsx, jsxs } from "react/jsx-runtime";
4
4
  //#region src/components/Author/Author.tsx
5
- const Author = ({ author = "Co-op team", className, date, datePrefix = "", image = {
6
- alt: "",
7
- src: "https://s3.eu-west-1.amazonaws.com/assets.digital.coop.co.uk/oneweb/coop-logo-inverted.svg"
8
- }, ref, size, ...props }) => {
9
- const imageProps = {
5
+ const Author = ({ children, className, ref, size, ...props }) => {
6
+ const componentProps = {
7
+ className: clsx("coop-author", className),
8
+ "data-size": size ?? void 0,
9
+ ...props
10
+ };
11
+ return /* @__PURE__ */ jsx("div", {
12
+ ...componentProps,
13
+ ref,
14
+ children
15
+ });
16
+ };
17
+ const COOP_LOGO_SRC = "https://s3.eu-west-1.amazonaws.com/assets.digital.coop.co.uk/oneweb/coop-logo-inverted.svg";
18
+ const AuthorImage = ({ alt = "", src = COOP_LOGO_SRC, ...props }) => {
19
+ const componentProps = {
20
+ alt,
21
+ src,
10
22
  width: "56px",
11
- ...image
23
+ ...props
12
24
  };
25
+ return /* @__PURE__ */ jsx(Image, { ...componentProps });
26
+ };
27
+ const AuthorMeta = ({ date, datePrefix, name = "Co-op team", ...props }) => {
13
28
  const componentProps = {
14
- className: clsx("coop-author", className),
15
- "data-size": size?.length ? size : void 0,
29
+ name,
16
30
  ...props
17
31
  };
18
32
  return /* @__PURE__ */ jsxs("div", {
33
+ className: "coop-author--content",
19
34
  ...componentProps,
20
- ref,
21
- children: [image && /* @__PURE__ */ jsx(Image, { ...imageProps }), /* @__PURE__ */ jsxs("div", {
22
- className: "coop-author--content",
23
- children: [/* @__PURE__ */ jsxs("span", { children: [/* @__PURE__ */ jsx("span", { children: datePrefix ? datePrefix + " " : "" }), /* @__PURE__ */ jsx("span", {
24
- className: "coop-author--date",
25
- children: date
26
- })] }), /* @__PURE__ */ jsxs("span", { children: ["by ", author] })]
27
- })]
35
+ children: [/* @__PURE__ */ jsxs("span", { children: [datePrefix && /* @__PURE__ */ jsx("span", { children: datePrefix + " " }), /* @__PURE__ */ jsx("span", {
36
+ className: "coop-author--date",
37
+ children: date
38
+ })] }), /* @__PURE__ */ jsxs("span", { children: ["by ", name] })]
28
39
  });
29
40
  };
41
+ Author.Image = AuthorImage;
42
+ Author.Meta = AuthorMeta;
30
43
  Author.slot = { name: "Author" };
31
44
  //#endregion
32
45
  export { Author, Author as default };
@@ -1,2 +1,2 @@
1
- import { Author, AuthorProps } from "./Author.js";
2
- export { Author, Author as default, AuthorProps };
1
+ import { Author, AuthorImageProps, AuthorMetaProps, AuthorProps } from "./Author.js";
2
+ export { Author, Author as default, AuthorImageProps, AuthorMetaProps, AuthorProps };
@@ -1,3 +1,4 @@
1
+ import { StandardSizes } from "../../types/index.js";
1
2
  import React, { ButtonHTMLAttributes, ForwardRefExoticComponent, JSX, Ref } from "react";
2
3
  //#region src/components/Button/Button.d.ts
3
4
  export interface ButtonProps extends ButtonHTMLAttributes<HTMLButtonElement> {
@@ -25,7 +26,7 @@ export interface ButtonProps extends ButtonHTMLAttributes<HTMLButtonElement> {
25
26
  /** Specify a custom React ref for this component. */
26
27
  ref?: Ref<HTMLElement>;
27
28
  /** Specify the component size. */
28
- size?: "sm" | "md" | "lg";
29
+ size?: StandardSizes;
29
30
  /** Specify the component variant. */
30
31
  variant?: "solid" | "ghost" | "text";
31
32
  }
@@ -1,3 +1,4 @@
1
+ import { StandardSizes } from "../../types/index.js";
1
2
  import { ComboboxItem, ComboboxOption } from "./combobox-utils.js";
2
3
  import { TextInputProps } from "../TextInput/TextInput.js";
3
4
  import "../TextInput/index.js";
@@ -75,7 +76,7 @@ export interface ComboboxProps extends Omit<HTMLAttributes<HTMLDivElement>, "onC
75
76
  /** Specify a custom React ref for this component. */
76
77
  ref?: Ref<HTMLDivElement>;
77
78
  /** Specify the component size. */
78
- size?: "sm" | "md" | "lg";
79
+ size?: StandardSizes;
79
80
  }
80
81
  export interface ComboboxControlsProps extends HTMLAttributes<HTMLDivElement> {
81
82
  /** Content inside the component.
@@ -13,7 +13,7 @@ const Pill = ({ as, children, className, href, ref, size, ...props }) => {
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?.length ? size : void 0,
16
+ "data-size": size ?? void 0,
17
17
  href,
18
18
  ...props
19
19
  };
@@ -6,11 +6,11 @@ export interface SectionProps extends HTMLAttributes<HTMLDivElement> {
6
6
  * Default: `<section>`
7
7
  */
8
8
  as?: React.FC<any> | string;
9
- /** **(Optional)** Content inside the component. */
9
+ /** Content inside the component. */
10
10
  children?: ReactNode;
11
- /** **(Optional)** Specify additional CSS classes. */
11
+ /** Specify additional CSS classes. */
12
12
  className?: string;
13
- /** **(Optional)** Specify a custom React ref for this component. */
13
+ /** Specify a custom React ref for this component. */
14
14
  ref?: Ref<HTMLDivElement>;
15
15
  }
16
16
  export declare const Section: ({ as, children, className, ref, ...props }: SectionProps) => JSX.Element;
@@ -6,7 +6,7 @@ const Tag = ({ as, children, className, href, ref, size, ...props }) => {
6
6
  const element = as ?? (href ? "a" : "span");
7
7
  const componentProps = {
8
8
  className: clsx("coop-tag", !hasUserBg(className) && "bg-tint-grey", className),
9
- "data-size": size?.length ? size : void 0,
9
+ "data-size": size ?? void 0,
10
10
  href,
11
11
  ...props
12
12
  };
@@ -9,7 +9,7 @@ const TextInput = ({ className, disabled, error = false, fit = false, id, name,
9
9
  className: clsx("coop-text-input", className),
10
10
  "data-error": error || void 0,
11
11
  "data-fit": fit || void 0,
12
- "data-size": size?.length ? size : void 0,
12
+ "data-size": size ?? void 0,
13
13
  disabled,
14
14
  id: id ?? field?.id,
15
15
  name,
@@ -6,11 +6,11 @@ export interface WrapperProps extends HTMLAttributes<HTMLDivElement> {
6
6
  * Default: `<div>`
7
7
  */
8
8
  as?: React.FC<any> | string;
9
- /** **(Optional)** Content inside the component. */
9
+ /** Content inside the component. */
10
10
  children?: ReactNode;
11
- /** **(Optional)** Specify additional CSS classes. */
11
+ /** Specify additional CSS classes. */
12
12
  className?: string;
13
- /** **(Optional)** Specify a custom React ref for this component. */
13
+ /** Specify a custom React ref for this component. */
14
14
  ref?: Ref<HTMLDivElement>;
15
15
  }
16
16
  export declare const Wrapper: ({ as, children, className, ref, ...props }: WrapperProps) => JSX.Element;
package/dist/index.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  import { AlertBanner, AlertBannerHeading, AlertBannerProps } from "./components/AlertBanner/AlertBanner.js";
2
2
  import { Image, ImageProps } from "./components/Image/Image.js";
3
- import { Author, AuthorProps } from "./components/Author/Author.js";
3
+ import { Author, AuthorImageProps, AuthorMetaProps, AuthorProps } from "./components/Author/Author.js";
4
4
  import { Box, BoxProps } from "./components/Box/Box.js";
5
5
  import "./components/Box/index.js";
6
6
  import { Button, ButtonProps } from "./components/Button/Button.js";
@@ -38,4 +38,4 @@ import { Textarea, TextareaProps } from "./components/Textarea/Textarea.js";
38
38
  import { ValidationSummary, ValidationSummaryErrors, ValidationSummaryHeading, ValidationSummaryPrompt, ValidationSummaryProps } from "./components/ValidationSummary/ValidationSummary.js";
39
39
  import { Wrapper, WrapperProps } from "./components/Wrapper/Wrapper.js";
40
40
  import "./components/Wrapper/index.js";
41
- export { AlertBanner, AlertBannerHeading, AlertBannerProps, Author, AuthorProps, Box, BoxProps, Button, ButtonProps, Card, CardBadge, CardContent, CardHeading, CardIcon, CardImage, CardLink, CardPicture, CardProps, Checkbox, CheckboxProps, Combobox, ComboboxControlsProps, ComboboxInputProps, ComboboxOptionsProps, ComboboxProps, DatePicker, DatePickerProps, type DateType, type DateTypeStr, Dialog, DialogBody, DialogHeader, DialogProps, Expandable, ExpandableContent, ExpandableProps, ExpandableSummary, Field, FieldError, FieldHint, FieldLabel, Fieldset, FieldsetError, FieldsetFields, FieldsetHint, FieldsetLegend, FieldsetProps, Flourish, FlourishProps, Form, FormProps, Image, ImageProps, LoadingSpinner, LoadingSpinnerProps, Logo, LogoProps, PasswordInput, PasswordInputProps, Picture, PictureProps, Pill, PillBadge, PillProps, Popover, PopoverAnchor, PopoverClose, PopoverContent, PopoverProps, PopoverTrigger, Radio, RadioProps, RootSVG, Searchbox, SearchboxButton, SearchboxInput, SearchboxProps, Section, SectionProps, Select, SelectOption, SelectOptionGroup, SelectProps, Signpost, SignpostProps, SkipNav, SkipNavProps, Squircle, SquircleProps, SquircleSvgProps, Tag, TagProps, TextInput, TextInputProps, Textarea, TextareaProps, ValidationSummary, ValidationSummaryErrors, ValidationSummaryHeading, ValidationSummaryPrompt, ValidationSummaryProps, Wrapper, WrapperProps };
41
+ export { AlertBanner, AlertBannerHeading, AlertBannerProps, Author, AuthorImageProps, AuthorMetaProps, AuthorProps, Box, BoxProps, Button, ButtonProps, Card, CardBadge, CardContent, CardHeading, CardIcon, CardImage, CardLink, CardPicture, CardProps, Checkbox, CheckboxProps, Combobox, ComboboxControlsProps, ComboboxInputProps, ComboboxOptionsProps, ComboboxProps, DatePicker, DatePickerProps, type DateType, type DateTypeStr, Dialog, DialogBody, DialogHeader, DialogProps, Expandable, ExpandableContent, ExpandableProps, ExpandableSummary, Field, FieldError, FieldHint, FieldLabel, Fieldset, FieldsetError, FieldsetFields, FieldsetHint, FieldsetLegend, FieldsetProps, Flourish, FlourishProps, Form, FormProps, Image, ImageProps, LoadingSpinner, LoadingSpinnerProps, Logo, LogoProps, PasswordInput, PasswordInputProps, Picture, PictureProps, Pill, PillBadge, PillProps, Popover, PopoverAnchor, PopoverClose, PopoverContent, PopoverProps, PopoverTrigger, Radio, RadioProps, RootSVG, Searchbox, SearchboxButton, SearchboxInput, SearchboxProps, Section, SectionProps, Select, SelectOption, SelectOptionGroup, SelectProps, Signpost, SignpostProps, SkipNav, SkipNavProps, Squircle, SquircleProps, SquircleSvgProps, Tag, TagProps, TextInput, TextInputProps, Textarea, TextareaProps, ValidationSummary, ValidationSummaryErrors, ValidationSummaryHeading, ValidationSummaryPrompt, ValidationSummaryProps, Wrapper, WrapperProps };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@coopdigital/react",
3
3
  "type": "module",
4
- "version": "1.26.0",
4
+ "version": "1.27.0",
5
5
  "private": false,
6
6
  "publishConfig": {
7
7
  "access": "public"
@@ -116,5 +116,5 @@
116
116
  "merge-refs": "^2.0.0",
117
117
  "react-day-picker": "^10.0.1"
118
118
  },
119
- "gitHead": "3835a0b5cd0562f01905240d8df20d4b042323db"
119
+ "gitHead": "be63994a207321f5f4f86ca4c8fd0c88c037be35"
120
120
  }
@@ -5,61 +5,86 @@ import clsx from "clsx"
5
5
  import { Image, ImageProps } from "@/components/Image"
6
6
 
7
7
  export interface AuthorProps extends HTMLAttributes<HTMLDivElement> {
8
- /** Specify the Author name. */
9
- author?: string
8
+ /** Content inside the component.
9
+ *
10
+ * This should be a set of `<Author.Image>` and `<Author.Meta>`. */
11
+ children?: React.ReactNode
10
12
  /** Specify additional CSS classes. */
11
13
  className?: string
14
+ /** Specify a custom React ref for this component. */
15
+ ref?: Ref<HTMLDivElement>
16
+ /** Specify the component size. */
17
+ size?: "sm" | "md"
18
+ }
19
+
20
+ export interface AuthorMetaProps extends HTMLAttributes<HTMLDivElement> {
12
21
  /** Specify the date.
13
22
  *
14
23
  * Recommended format `dd mmmm yyyy` eg: 1 January 2000. */
15
24
  date?: string
16
25
  /** Specify the text that will prefix the date, e.g. "Updated". */
17
26
  datePrefix?: string
18
- /** Specify properties of the Author Image. */
19
- image?: ImageProps
20
- /** Specify a custom React ref for this component. */
21
- ref?: Ref<HTMLDivElement>
22
- /** Specify the component size. */
23
- size?: "sm" | "md"
27
+ /** Specify the Author name. */
28
+ name?: string
29
+ }
30
+ export interface AuthorImageProps extends Partial<ImageProps> {
31
+ alt?: string
32
+ src?: string
24
33
  }
25
34
 
26
- const Author = ({
27
- author = "Co-op team",
28
- className,
29
- date,
30
- datePrefix = "",
31
- image = {
32
- alt: "",
33
- src: "https://s3.eu-west-1.amazonaws.com/assets.digital.coop.co.uk/oneweb/coop-logo-inverted.svg",
34
- },
35
- ref,
36
- size,
35
+ const Author = ({ children, className, ref, size, ...props }: AuthorProps): JSX.Element => {
36
+ const componentProps = {
37
+ className: clsx("coop-author", className),
38
+ "data-size": size ?? undefined,
39
+ ...props,
40
+ }
41
+ return (
42
+ <div {...componentProps} ref={ref}>
43
+ {children}
44
+ </div>
45
+ )
46
+ }
47
+
48
+ const COOP_LOGO_SRC =
49
+ "https://s3.eu-west-1.amazonaws.com/assets.digital.coop.co.uk/oneweb/coop-logo-inverted.svg"
50
+
51
+ const AuthorImage = ({
52
+ alt = "",
53
+ src = COOP_LOGO_SRC,
37
54
  ...props
38
- }: AuthorProps): JSX.Element => {
39
- const imageProps: ImageProps = {
55
+ }: AuthorImageProps): JSX.Element => {
56
+ const componentProps = {
57
+ alt,
58
+ src,
40
59
  width: "56px",
41
- ...image,
60
+ ...props,
42
61
  }
62
+ return <Image {...componentProps} />
63
+ }
43
64
 
65
+ const AuthorMeta = ({
66
+ date,
67
+ datePrefix,
68
+ name = "Co-op team",
69
+ ...props
70
+ }: AuthorMetaProps): JSX.Element => {
44
71
  const componentProps = {
45
- className: clsx("coop-author", className),
46
- "data-size": size?.length ? size : undefined,
72
+ name,
47
73
  ...props,
48
74
  }
49
75
  return (
50
- <div {...componentProps} ref={ref}>
51
- {image && <Image {...imageProps} />}
52
- <div className="coop-author--content">
53
- <span>
54
- <span>{datePrefix ? datePrefix + " " : ""}</span>
55
- <span className="coop-author--date">{date}</span>
56
- </span>
57
- <span>by {author}</span>
58
- </div>
76
+ <div className="coop-author--content" {...componentProps}>
77
+ <span>
78
+ {datePrefix && <span>{datePrefix + " "}</span>}
79
+ <span className="coop-author--date">{date}</span>
80
+ </span>
81
+ <span>by {name}</span>
59
82
  </div>
60
83
  )
61
84
  }
62
85
 
86
+ Author.Image = AuthorImage
87
+ Author.Meta = AuthorMeta
63
88
  Author.slot = { name: "Author" }
64
89
 
65
90
  export default Author
@@ -6,6 +6,7 @@ import clsx from "clsx"
6
6
  import React, { useCallback, useState } from "react"
7
7
 
8
8
  import { LoadingSpinner } from "@/components/LoadingSpinner"
9
+ import { StandardSizes } from "@/types"
9
10
  import { hasUserBg } from "@/utils"
10
11
 
11
12
  export interface ButtonProps extends ButtonHTMLAttributes<HTMLButtonElement> {
@@ -34,7 +35,7 @@ export interface ButtonProps extends ButtonHTMLAttributes<HTMLButtonElement> {
34
35
  /** Specify a custom React ref for this component. */
35
36
  ref?: Ref<HTMLElement>
36
37
  /** Specify the component size. */
37
- size?: "sm" | "md" | "lg"
38
+ size?: StandardSizes
38
39
  /** Specify the component variant. */
39
40
  variant?: "solid" | "ghost" | "text"
40
41
  }
@@ -25,6 +25,7 @@ import { useField } from "@/components/Field/Field.context"
25
25
  import { ChevronDownIcon } from "@/components/icons"
26
26
  import { TextInput, TextInputProps } from "@/components/TextInput"
27
27
  import { useSlots } from "@/hooks"
28
+ import { StandardSizes } from "@/types"
28
29
  import { getSlotProp } from "@/utils"
29
30
 
30
31
  export interface ComboboxProps extends Omit<
@@ -101,7 +102,7 @@ export interface ComboboxProps extends Omit<
101
102
  /** Specify a custom React ref for this component. */
102
103
  ref?: Ref<HTMLDivElement>
103
104
  /** Specify the component size. */
104
- size?: "sm" | "md" | "lg"
105
+ size?: StandardSizes
105
106
  }
106
107
 
107
108
  export interface ComboboxControlsProps extends HTMLAttributes<HTMLDivElement> {
@@ -47,7 +47,7 @@ const Pill = ({ as, children, className, href, ref, size, ...props }: PillProps)
47
47
 
48
48
  const componentProps = {
49
49
  className: clsx("coop-pill", !hasUserBg(className) && "bg-tint-grey", className),
50
- "data-size": size?.length ? size : undefined,
50
+ "data-size": size ?? undefined,
51
51
  href,
52
52
  ...props,
53
53
  }
@@ -10,11 +10,11 @@ export interface SectionProps extends HTMLAttributes<HTMLDivElement> {
10
10
  */
11
11
  // oxlint-disable-next-line typescript/no-explicit-any
12
12
  as?: React.FC<any> | string
13
- /** **(Optional)** Content inside the component. */
13
+ /** Content inside the component. */
14
14
  children?: ReactNode
15
- /** **(Optional)** Specify additional CSS classes. */
15
+ /** Specify additional CSS classes. */
16
16
  className?: string
17
- /** **(Optional)** Specify a custom React ref for this component. */
17
+ /** Specify a custom React ref for this component. */
18
18
  ref?: Ref<HTMLDivElement>
19
19
  }
20
20
 
@@ -29,7 +29,7 @@ const Tag = ({ as, children, className, href, ref, size, ...props }: TagProps):
29
29
 
30
30
  const componentProps = {
31
31
  className: clsx("coop-tag", !hasUserBg(className) && "bg-tint-grey", className),
32
- "data-size": size?.length ? size : undefined,
32
+ "data-size": size ?? undefined,
33
33
  href,
34
34
  ...props,
35
35
  }
@@ -80,7 +80,7 @@ const TextInput = ({
80
80
  className: clsx("coop-text-input", className),
81
81
  "data-error": error || undefined,
82
82
  "data-fit": fit || undefined,
83
- "data-size": size?.length ? size : undefined,
83
+ "data-size": size ?? undefined,
84
84
  disabled,
85
85
  id: id ?? field?.id,
86
86
  name,
@@ -10,11 +10,11 @@ export interface WrapperProps extends HTMLAttributes<HTMLDivElement> {
10
10
  */
11
11
  // oxlint-disable-next-line typescript/no-explicit-any
12
12
  as?: React.FC<any> | string
13
- /** **(Optional)** Content inside the component. */
13
+ /** Content inside the component. */
14
14
  children?: ReactNode
15
- /** **(Optional)** Specify additional CSS classes. */
15
+ /** Specify additional CSS classes. */
16
16
  className?: string
17
- /** **(Optional)** Specify a custom React ref for this component. */
17
+ /** Specify a custom React ref for this component. */
18
18
  ref?: Ref<HTMLDivElement>
19
19
  }
20
20