@coopdigital/react 1.26.1 → 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 = {
10
- width: "56px",
11
- ...image
12
- };
5
+ const Author = ({ children, className, ref, size, ...props }) => {
13
6
  const componentProps = {
14
7
  className: clsx("coop-author", className),
15
8
  "data-size": size ?? void 0,
16
9
  ...props
17
10
  };
18
- return /* @__PURE__ */ jsxs("div", {
11
+ return /* @__PURE__ */ jsx("div", {
19
12
  ...componentProps,
20
13
  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
- })]
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,
22
+ width: "56px",
23
+ ...props
24
+ };
25
+ return /* @__PURE__ */ jsx(Image, { ...componentProps });
26
+ };
27
+ const AuthorMeta = ({ date, datePrefix, name = "Co-op team", ...props }) => {
28
+ const componentProps = {
29
+ name,
30
+ ...props
31
+ };
32
+ return /* @__PURE__ */ jsxs("div", {
33
+ className: "coop-author--content",
34
+ ...componentProps,
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 };
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.1",
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": "d973a1436fe2245a6af205621b69762c3d7f7d09"
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 ?? 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