@coopdigital/react 1.19.1 → 1.21.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.
Files changed (155) hide show
  1. package/dist/components/AlertBanner/AlertBanner.js +5 -2
  2. package/dist/components/Author/Author.js +5 -2
  3. package/dist/components/Card/Card.d.ts +96 -49
  4. package/dist/components/Card/Card.js +61 -60
  5. package/dist/components/Card/index.d.ts +2 -2
  6. package/dist/components/Card/index.js +2 -2
  7. package/dist/components/Checkbox/Checkbox.js +5 -2
  8. package/dist/components/DatePicker/DatePicker.js +5 -4
  9. package/dist/components/DatePicker/datepicker-utils.js +12 -11
  10. package/dist/components/Dialog/Dialog.js +5 -2
  11. package/dist/components/Expandable/Expandable.js +5 -2
  12. package/dist/components/FieldMarkers/Error.js +5 -2
  13. package/dist/components/FieldMarkers/Hint.js +5 -2
  14. package/dist/components/FieldMarkers/Label.js +5 -2
  15. package/dist/components/Fieldset/Fieldset.js +10 -4
  16. package/dist/components/Flourish/Flourish.js +6 -3
  17. package/dist/components/Form/Form.js +5 -2
  18. package/dist/components/Image/Image.d.ts +3 -5
  19. package/dist/components/Image/Image.js +10 -7
  20. package/dist/components/LoadingSpinner/LoadingSpinner.js +5 -2
  21. package/dist/components/Logo/Logo.js +5 -2
  22. package/dist/components/Picture/Picture.d.ts +15 -0
  23. package/dist/components/Picture/Picture.js +17 -0
  24. package/dist/components/Picture/index.d.ts +2 -0
  25. package/dist/components/Picture/index.js +5 -0
  26. package/dist/components/Prose/Prose.js +5 -2
  27. package/dist/components/Radio/Radio.js +5 -2
  28. package/dist/components/Searchbox/Searchbox.js +3 -2
  29. package/dist/components/Select/Select.js +5 -2
  30. package/dist/components/Signpost/Signpost.js +6 -6
  31. package/dist/components/SkipNav/SkipNav.js +5 -2
  32. package/dist/components/Squircle/Squircle.d.ts +8 -4
  33. package/dist/components/Squircle/Squircle.js +39 -6
  34. package/dist/components/Squircle/index.d.ts +2 -2
  35. package/dist/components/ValidationSummary/ValidationSummary.js +5 -2
  36. package/dist/components/icons/AccountCircleFilledIcon.js +5 -2
  37. package/dist/components/icons/AccountCircleIcon.js +5 -2
  38. package/dist/components/icons/AccountFilledIcon.js +5 -2
  39. package/dist/components/icons/AccountIcon.js +5 -2
  40. package/dist/components/icons/AddIcon.js +5 -2
  41. package/dist/components/icons/AppsFilledIcon.js +5 -2
  42. package/dist/components/icons/AppsIcon.js +5 -2
  43. package/dist/components/icons/ArrowDownIcon.js +5 -2
  44. package/dist/components/icons/ArrowLeftIcon.js +5 -2
  45. package/dist/components/icons/ArrowRightIcon.js +5 -2
  46. package/dist/components/icons/ArrowUpIcon.js +5 -2
  47. package/dist/components/icons/BackspaceFilledIcon.js +5 -2
  48. package/dist/components/icons/BackspaceIcon.js +5 -2
  49. package/dist/components/icons/BasketFilledIcon.js +5 -2
  50. package/dist/components/icons/BasketIcon.js +5 -2
  51. package/dist/components/icons/BellFilledIcon.js +5 -2
  52. package/dist/components/icons/BellIcon.js +5 -2
  53. package/dist/components/icons/BroomIcon.js +5 -2
  54. package/dist/components/icons/CalendarFilledIcon.js +5 -2
  55. package/dist/components/icons/CalendarIcon.js +5 -2
  56. package/dist/components/icons/CashFilledIcon.js +5 -2
  57. package/dist/components/icons/CashIcon.js +5 -2
  58. package/dist/components/icons/ChevronDownIcon.js +5 -2
  59. package/dist/components/icons/ChevronLeftIcon.js +5 -2
  60. package/dist/components/icons/ChevronRightIcon.js +5 -2
  61. package/dist/components/icons/ChevronUpIcon.js +5 -2
  62. package/dist/components/icons/CircleBurgerFilledIcon.js +5 -2
  63. package/dist/components/icons/CircleBurgerIcon.js +5 -2
  64. package/dist/components/icons/ClipboardFilledIcon.js +5 -2
  65. package/dist/components/icons/ClipboardIcon.js +5 -2
  66. package/dist/components/icons/ClockFilledIcon.js +5 -2
  67. package/dist/components/icons/ClockIcon.js +5 -2
  68. package/dist/components/icons/CloseAltFilledIcon.js +5 -2
  69. package/dist/components/icons/CloseAltIcon.js +5 -2
  70. package/dist/components/icons/CogIcon.js +5 -2
  71. package/dist/components/icons/CommunityFilledIcon.js +5 -2
  72. package/dist/components/icons/CommunityIcon.js +5 -2
  73. package/dist/components/icons/ComputerIcon.js +5 -2
  74. package/dist/components/icons/ContactFilledIcon.js +5 -2
  75. package/dist/components/icons/ContactIcon.js +5 -2
  76. package/dist/components/icons/ContactlessFilledIcon.js +5 -2
  77. package/dist/components/icons/ContactlessIcon.js +5 -2
  78. package/dist/components/icons/CoopLiveIcon.js +5 -2
  79. package/dist/components/icons/CoopLocationFilledIcon.js +5 -2
  80. package/dist/components/icons/CoopLogoIcon.js +5 -2
  81. package/dist/components/icons/CoopMembershipCardFilledIcon.js +5 -2
  82. package/dist/components/icons/CreditCardFilledIcon.js +5 -2
  83. package/dist/components/icons/CreditCardIcon.js +5 -2
  84. package/dist/components/icons/CrossIcon.js +5 -2
  85. package/dist/components/icons/DocumentIcon.js +5 -2
  86. package/dist/components/icons/DownloadIcon.js +5 -2
  87. package/dist/components/icons/EnterStoreIcon.js +5 -2
  88. package/dist/components/icons/ExitStoreIcon.js +5 -2
  89. package/dist/components/icons/EyeFilledIcon.js +5 -2
  90. package/dist/components/icons/EyeIcon.js +5 -2
  91. package/dist/components/icons/EyeStrikeFilledIcon.js +5 -2
  92. package/dist/components/icons/EyeStrikeIcon.js +5 -2
  93. package/dist/components/icons/FeedbackFilledIcon.js +5 -2
  94. package/dist/components/icons/FeedbackIcon.js +5 -2
  95. package/dist/components/icons/FilterIcon.js +5 -2
  96. package/dist/components/icons/GiftCardFilledIcon.js +5 -2
  97. package/dist/components/icons/GiftCardIcon.js +5 -2
  98. package/dist/components/icons/GiftFilledIcon.js +5 -2
  99. package/dist/components/icons/GiftIcon.js +5 -2
  100. package/dist/components/icons/HelpFilledIcon.js +5 -2
  101. package/dist/components/icons/HelpIcon.js +5 -2
  102. package/dist/components/icons/HomeFilledIcon.js +5 -2
  103. package/dist/components/icons/HomeIcon.js +5 -2
  104. package/dist/components/icons/HowDoIAssistantIcon.js +5 -2
  105. package/dist/components/icons/InfoIcon.js +5 -2
  106. package/dist/components/icons/KebabIcon.js +5 -2
  107. package/dist/components/icons/LoadingIcon.js +5 -2
  108. package/dist/components/icons/LocationFilledIcon.js +5 -2
  109. package/dist/components/icons/LocationIcon.js +5 -2
  110. package/dist/components/icons/LogoutIcon.js +5 -2
  111. package/dist/components/icons/MailIcon.js +5 -2
  112. package/dist/components/icons/MenuIcon.js +5 -2
  113. package/dist/components/icons/MessageIcon.js +5 -2
  114. package/dist/components/icons/MinusIcon.js +5 -2
  115. package/dist/components/icons/NotesFilledIcon.js +5 -2
  116. package/dist/components/icons/NotesIcon.js +5 -2
  117. package/dist/components/icons/OpenNewIcon.js +5 -2
  118. package/dist/components/icons/OwnBagIcon.js +5 -2
  119. package/dist/components/icons/PadlockIcon.js +5 -2
  120. package/dist/components/icons/PencilIcon.js +5 -2
  121. package/dist/components/icons/PhoneIcon.js +5 -2
  122. package/dist/components/icons/PowerIcon.js +5 -2
  123. package/dist/components/icons/SaveFilledIcon.js +5 -2
  124. package/dist/components/icons/SaveIcon.js +5 -2
  125. package/dist/components/icons/ScooterIcon.js +5 -2
  126. package/dist/components/icons/SearchFilledIcon.js +5 -2
  127. package/dist/components/icons/SearchIcon.js +5 -2
  128. package/dist/components/icons/SendIcon.js +5 -2
  129. package/dist/components/icons/SpannerIcon.js +5 -2
  130. package/dist/components/icons/StarFilledIcon.js +5 -2
  131. package/dist/components/icons/StarIcon.js +5 -2
  132. package/dist/components/icons/TickAltFilledIcon.js +5 -2
  133. package/dist/components/icons/TickAltIcon.js +5 -2
  134. package/dist/components/icons/TickIcon.js +5 -2
  135. package/dist/components/icons/TruckIcon.js +5 -2
  136. package/dist/components/icons/UserWipeIcon.js +5 -2
  137. package/dist/components/icons/VoucherFilledIcon.js +5 -2
  138. package/dist/components/icons/VoucherIcon.js +5 -2
  139. package/dist/components/icons/WarningCircleFilledIcon.js +5 -2
  140. package/dist/components/icons/WarningCircleIcon.js +5 -2
  141. package/dist/components/icons/WarningFilledIcon.js +5 -2
  142. package/dist/components/icons/WarningIcon.js +5 -2
  143. package/dist/components/icons/WifiIcon.js +5 -2
  144. package/dist/components/icons/WriteIcon.js +5 -2
  145. package/dist/hooks/useSlots.js +4 -3
  146. package/dist/index.d.ts +5 -3
  147. package/dist/index.js +3 -2
  148. package/package.json +10 -10
  149. package/src/components/Card/Card.tsx +146 -100
  150. package/src/components/Image/Image.tsx +15 -22
  151. package/src/components/Picture/Picture.tsx +36 -0
  152. package/src/components/Picture/index.ts +5 -0
  153. package/src/components/Signpost/Signpost.tsx +1 -1
  154. package/src/components/Squircle/Squircle.tsx +50 -13
  155. package/src/index.ts +1 -0
@@ -4,7 +4,7 @@ import { jsx, jsxs } from "react/jsx-runtime";
4
4
  //#region src/components/icons/VoucherFilledIcon.tsx
5
5
  const VoucherFilledIcon = ({ alt, className, fill, id, ref, ...props }) => {
6
6
  const uid = useId(id);
7
- return /* @__PURE__ */ jsxs("svg", {
7
+ const componentProps = {
8
8
  "aria-labelledby": alt ? uid + "__title" : void 0,
9
9
  className: clsx("coop-icon", className),
10
10
  "data-icon": "voucher-filled",
@@ -12,7 +12,10 @@ const VoucherFilledIcon = ({ alt, className, fill, id, ref, ...props }) => {
12
12
  id: uid,
13
13
  role: alt ? "img" : void 0,
14
14
  viewBox: "0 0 32 32",
15
- ...props,
15
+ ...props
16
+ };
17
+ return /* @__PURE__ */ jsxs("svg", {
18
+ ...componentProps,
16
19
  ref,
17
20
  children: [alt ? /* @__PURE__ */ jsx("title", {
18
21
  id: uid + "__title",
@@ -4,7 +4,7 @@ import { jsx, jsxs } from "react/jsx-runtime";
4
4
  //#region src/components/icons/VoucherIcon.tsx
5
5
  const VoucherIcon = ({ alt, className, fill, id, ref, ...props }) => {
6
6
  const uid = useId(id);
7
- return /* @__PURE__ */ jsxs("svg", {
7
+ const componentProps = {
8
8
  "aria-labelledby": alt ? uid + "__title" : void 0,
9
9
  className: clsx("coop-icon", className),
10
10
  "data-icon": "voucher",
@@ -12,7 +12,10 @@ const VoucherIcon = ({ alt, className, fill, id, ref, ...props }) => {
12
12
  id: uid,
13
13
  role: alt ? "img" : void 0,
14
14
  viewBox: "0 0 32 32",
15
- ...props,
15
+ ...props
16
+ };
17
+ return /* @__PURE__ */ jsxs("svg", {
18
+ ...componentProps,
16
19
  ref,
17
20
  children: [alt ? /* @__PURE__ */ jsx("title", {
18
21
  id: uid + "__title",
@@ -4,7 +4,7 @@ import { jsx, jsxs } from "react/jsx-runtime";
4
4
  //#region src/components/icons/WarningCircleFilledIcon.tsx
5
5
  const WarningCircleFilledIcon = ({ alt, className, fill, id, ref, ...props }) => {
6
6
  const uid = useId(id);
7
- return /* @__PURE__ */ jsxs("svg", {
7
+ const componentProps = {
8
8
  "aria-labelledby": alt ? uid + "__title" : void 0,
9
9
  className: clsx("coop-icon", className),
10
10
  "data-icon": "warning-circle-filled",
@@ -12,7 +12,10 @@ const WarningCircleFilledIcon = ({ alt, className, fill, id, ref, ...props }) =>
12
12
  id: uid,
13
13
  role: alt ? "img" : void 0,
14
14
  viewBox: "0 0 32 32",
15
- ...props,
15
+ ...props
16
+ };
17
+ return /* @__PURE__ */ jsxs("svg", {
18
+ ...componentProps,
16
19
  ref,
17
20
  children: [alt ? /* @__PURE__ */ jsx("title", {
18
21
  id: uid + "__title",
@@ -4,7 +4,7 @@ import { jsx, jsxs } from "react/jsx-runtime";
4
4
  //#region src/components/icons/WarningCircleIcon.tsx
5
5
  const WarningCircleIcon = ({ alt, className, fill, id, ref, ...props }) => {
6
6
  const uid = useId(id);
7
- return /* @__PURE__ */ jsxs("svg", {
7
+ const componentProps = {
8
8
  "aria-labelledby": alt ? uid + "__title" : void 0,
9
9
  className: clsx("coop-icon", className),
10
10
  "data-icon": "warning-circle",
@@ -12,7 +12,10 @@ const WarningCircleIcon = ({ alt, className, fill, id, ref, ...props }) => {
12
12
  id: uid,
13
13
  role: alt ? "img" : void 0,
14
14
  viewBox: "0 0 32 32",
15
- ...props,
15
+ ...props
16
+ };
17
+ return /* @__PURE__ */ jsxs("svg", {
18
+ ...componentProps,
16
19
  ref,
17
20
  children: [
18
21
  alt ? /* @__PURE__ */ jsx("title", {
@@ -4,7 +4,7 @@ import { jsx, jsxs } from "react/jsx-runtime";
4
4
  //#region src/components/icons/WarningFilledIcon.tsx
5
5
  const WarningFilledIcon = ({ alt, className, fill, id, ref, ...props }) => {
6
6
  const uid = useId(id);
7
- return /* @__PURE__ */ jsxs("svg", {
7
+ const componentProps = {
8
8
  "aria-labelledby": alt ? uid + "__title" : void 0,
9
9
  className: clsx("coop-icon", className),
10
10
  "data-icon": "warning-filled",
@@ -12,7 +12,10 @@ const WarningFilledIcon = ({ alt, className, fill, id, ref, ...props }) => {
12
12
  id: uid,
13
13
  role: alt ? "img" : void 0,
14
14
  viewBox: "0 0 32 32",
15
- ...props,
15
+ ...props
16
+ };
17
+ return /* @__PURE__ */ jsxs("svg", {
18
+ ...componentProps,
16
19
  ref,
17
20
  children: [alt ? /* @__PURE__ */ jsx("title", {
18
21
  id: uid + "__title",
@@ -4,7 +4,7 @@ import { jsx, jsxs } from "react/jsx-runtime";
4
4
  //#region src/components/icons/WarningIcon.tsx
5
5
  const WarningIcon = ({ alt, className, fill, id, ref, ...props }) => {
6
6
  const uid = useId(id);
7
- return /* @__PURE__ */ jsxs("svg", {
7
+ const componentProps = {
8
8
  "aria-labelledby": alt ? uid + "__title" : void 0,
9
9
  className: clsx("coop-icon", className),
10
10
  "data-icon": "warning",
@@ -12,7 +12,10 @@ const WarningIcon = ({ alt, className, fill, id, ref, ...props }) => {
12
12
  id: uid,
13
13
  role: alt ? "img" : void 0,
14
14
  viewBox: "0 0 32 32",
15
- ...props,
15
+ ...props
16
+ };
17
+ return /* @__PURE__ */ jsxs("svg", {
18
+ ...componentProps,
16
19
  ref,
17
20
  children: [alt ? /* @__PURE__ */ jsx("title", {
18
21
  id: uid + "__title",
@@ -4,7 +4,7 @@ import { jsx, jsxs } from "react/jsx-runtime";
4
4
  //#region src/components/icons/WifiIcon.tsx
5
5
  const WifiIcon = ({ alt, className, fill, id, ref, ...props }) => {
6
6
  const uid = useId(id);
7
- return /* @__PURE__ */ jsxs("svg", {
7
+ const componentProps = {
8
8
  "aria-labelledby": alt ? uid + "__title" : void 0,
9
9
  className: clsx("coop-icon", className),
10
10
  "data-icon": "wifi",
@@ -12,7 +12,10 @@ const WifiIcon = ({ alt, className, fill, id, ref, ...props }) => {
12
12
  id: uid,
13
13
  role: alt ? "img" : void 0,
14
14
  viewBox: "0 0 32 32",
15
- ...props,
15
+ ...props
16
+ };
17
+ return /* @__PURE__ */ jsxs("svg", {
18
+ ...componentProps,
16
19
  ref,
17
20
  children: [alt ? /* @__PURE__ */ jsx("title", {
18
21
  id: uid + "__title",
@@ -4,7 +4,7 @@ import { jsx, jsxs } from "react/jsx-runtime";
4
4
  //#region src/components/icons/WriteIcon.tsx
5
5
  const WriteIcon = ({ alt, className, fill, id, ref, ...props }) => {
6
6
  const uid = useId(id);
7
- return /* @__PURE__ */ jsxs("svg", {
7
+ const componentProps = {
8
8
  "aria-labelledby": alt ? uid + "__title" : void 0,
9
9
  className: clsx("coop-icon", className),
10
10
  "data-icon": "write",
@@ -12,7 +12,10 @@ const WriteIcon = ({ alt, className, fill, id, ref, ...props }) => {
12
12
  id: uid,
13
13
  role: alt ? "img" : void 0,
14
14
  viewBox: "0 0 32 32",
15
- ...props,
15
+ ...props
16
+ };
17
+ return /* @__PURE__ */ jsxs("svg", {
18
+ ...componentProps,
16
19
  ref,
17
20
  children: [alt ? /* @__PURE__ */ jsx("title", {
18
21
  id: uid + "__title",
@@ -31,9 +31,10 @@ function getSlotName(node) {
31
31
  function useSlots(componentSlots, children, options) {
32
32
  return React.Children.toArray(children).reduce((slots, child) => {
33
33
  const slotName = getSlotName(child);
34
- if (child && slotName && isKey(componentSlots, slotName)) if (options?.collect?.includes(slotName)) slots[slotName] = slots[slotName] ? [...[slots[slotName]].flat(), child] : [child];
35
- else slots[slotName] = child;
36
- else if ("Children" in slots) slots.Children = slots.Children ? [...[slots.Children].flat(), child] : [child];
34
+ if (child && slotName && isKey(componentSlots, slotName)) {
35
+ if (options?.collect?.includes(slotName)) slots[slotName] = slots[slotName] ? [...[slots[slotName]].flat(), child] : [child];
36
+ else slots[slotName] = child;
37
+ } else if ("Children" in slots) slots.Children = slots.Children ? [...[slots.Children].flat(), child] : [child];
37
38
  return slots;
38
39
  }, { ...componentSlots });
39
40
  }
package/dist/index.d.ts CHANGED
@@ -2,7 +2,9 @@ import { AlertBanner, AlertBannerHeading, AlertBannerProps } from "./components/
2
2
  import { Image, ImageProps } from "./components/Image/Image.js";
3
3
  import { Author, AuthorProps } from "./components/Author/Author.js";
4
4
  import { Button, ButtonProps } from "./components/Button/Button.js";
5
- import { Card, CardBadge, CardBody, CardHeading, CardImage, CardLabel, CardProps } from "./components/Card/Card.js";
5
+ import { Picture, PictureProps } from "./components/Picture/Picture.js";
6
+ import "./components/Picture/index.js";
7
+ import { Card, CardBadge, CardContent, CardHeading, CardIcon, CardImage, CardLink, CardPicture, CardProps } from "./components/Card/Card.js";
6
8
  import { Checkbox, CheckboxProps } from "./components/Checkbox/Checkbox.js";
7
9
  import { DatePicker, DatePickerProps } from "./components/DatePicker/DatePicker.js";
8
10
  import { Dialog, DialogBody, DialogHeader, DialogProps } from "./components/Dialog/Dialog.js";
@@ -23,8 +25,8 @@ import { Searchbox, SearchboxButton, SearchboxInput, SearchboxProps } from "./co
23
25
  import { Select, SelectOption, SelectOptionGroup, SelectProps } from "./components/Select/Select.js";
24
26
  import { Signpost, SignpostProps } from "./components/Signpost/Signpost.js";
25
27
  import { SkipNav, SkipNavProps } from "./components/SkipNav/SkipNav.js";
26
- import { Squircle, SquircleProps } from "./components/Squircle/Squircle.js";
28
+ import { Squircle, SquircleProps, SquircleSvgProps } from "./components/Squircle/Squircle.js";
27
29
  import { Tag, TagProps } from "./components/Tag/Tag.js";
28
30
  import { Textarea, TextareaProps } from "./components/Textarea/Textarea.js";
29
31
  import { ValidationSummary, ValidationSummaryErrors, ValidationSummaryHeading, ValidationSummaryPrompt, ValidationSummaryProps } from "./components/ValidationSummary/ValidationSummary.js";
30
- export { AlertBanner, AlertBannerHeading, AlertBannerProps, Author, AuthorProps, Button, ButtonProps, Card, CardBadge, CardBody, CardHeading, CardImage, CardLabel, CardProps, Checkbox, CheckboxProps, DatePicker, DatePickerProps, 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, Pill, PillBadge, PillProps, Popover, PopoverAnchor, PopoverClose, PopoverContent, PopoverProps, PopoverTrigger, Radio, RadioProps, RootSVG, Searchbox, SearchboxButton, SearchboxInput, SearchboxProps, Select, SelectOption, SelectOptionGroup, SelectProps, Signpost, SignpostProps, SkipNav, SkipNavProps, Squircle, SquircleProps, Tag, TagProps, TextInput, TextInputProps, Textarea, TextareaProps, ValidationSummary, ValidationSummaryErrors, ValidationSummaryHeading, ValidationSummaryPrompt, ValidationSummaryProps };
32
+ export { AlertBanner, AlertBannerHeading, AlertBannerProps, Author, AuthorProps, Button, ButtonProps, Card, CardBadge, CardContent, CardHeading, CardIcon, CardImage, CardLink, CardPicture, CardProps, Checkbox, CheckboxProps, DatePicker, DatePickerProps, 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, Select, SelectOption, SelectOptionGroup, SelectProps, Signpost, SignpostProps, SkipNav, SkipNavProps, Squircle, SquircleProps, SquircleSvgProps, Tag, TagProps, TextInput, TextInputProps, Textarea, TextareaProps, ValidationSummary, ValidationSummaryErrors, ValidationSummaryHeading, ValidationSummaryPrompt, ValidationSummaryProps };
package/dist/index.js CHANGED
@@ -3,7 +3,8 @@ import { Image } from "./components/Image/Image.js";
3
3
  import { Author } from "./components/Author/Author.js";
4
4
  import { LoadingSpinner } from "./components/LoadingSpinner/LoadingSpinner.js";
5
5
  import { Button } from "./components/Button/Button.js";
6
- import { Card, CardBadge, CardBody, CardHeading, CardImage, CardLabel } from "./components/Card/Card.js";
6
+ import { Picture } from "./components/Picture/Picture.js";
7
+ import { Card, CardBadge, CardContent, CardHeading, CardIcon, CardImage, CardLink, CardPicture } from "./components/Card/Card.js";
7
8
  import { Checkbox } from "./components/Checkbox/Checkbox.js";
8
9
  import { Popover, PopoverAnchor, PopoverClose, PopoverContent, PopoverTrigger } from "./components/Popover/Popover.js";
9
10
  import { TextInput } from "./components/TextInput/TextInput.js";
@@ -27,4 +28,4 @@ import { Squircle } from "./components/Squircle/Squircle.js";
27
28
  import { Tag } from "./components/Tag/Tag.js";
28
29
  import { Textarea } from "./components/Textarea/Textarea.js";
29
30
  import { ValidationSummary, ValidationSummaryErrors, ValidationSummaryHeading, ValidationSummaryPrompt } from "./components/ValidationSummary/ValidationSummary.js";
30
- export { AlertBanner, AlertBannerHeading, Author, Button, Card, CardBadge, CardBody, CardHeading, CardImage, CardLabel, Checkbox, DatePicker, Dialog, DialogBody, DialogHeader, Expandable, ExpandableContent, ExpandableSummary, Field, FieldError, FieldHint, FieldLabel, Fieldset, FieldsetError, FieldsetFields, FieldsetHint, FieldsetLegend, Flourish, Form, Image, LoadingSpinner, Logo, PasswordInput, Pill, PillBadge, Popover, PopoverAnchor, PopoverClose, PopoverContent, PopoverTrigger, Radio, RootSVG, Searchbox, SearchboxButton, SearchboxInput, Select, SelectOption, SelectOptionGroup, Signpost, SkipNav, Squircle, Tag, TextInput, Textarea, ValidationSummary, ValidationSummaryErrors, ValidationSummaryHeading, ValidationSummaryPrompt };
31
+ export { AlertBanner, AlertBannerHeading, Author, Button, Card, CardBadge, CardContent, CardHeading, CardIcon, CardImage, CardLink, CardPicture, Checkbox, DatePicker, Dialog, DialogBody, DialogHeader, Expandable, ExpandableContent, ExpandableSummary, Field, FieldError, FieldHint, FieldLabel, Fieldset, FieldsetError, FieldsetFields, FieldsetHint, FieldsetLegend, Flourish, Form, Image, LoadingSpinner, Logo, PasswordInput, Picture, Pill, PillBadge, Popover, PopoverAnchor, PopoverClose, PopoverContent, PopoverTrigger, Radio, RootSVG, Searchbox, SearchboxButton, SearchboxInput, Select, SelectOption, SelectOptionGroup, Signpost, SkipNav, Squircle, Tag, TextInput, Textarea, ValidationSummary, ValidationSummaryErrors, ValidationSummaryHeading, ValidationSummaryPrompt };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@coopdigital/react",
3
3
  "type": "module",
4
- "version": "1.19.1",
4
+ "version": "1.21.0",
5
5
  "private": false,
6
6
  "publishConfig": {
7
7
  "access": "public"
@@ -66,20 +66,20 @@
66
66
  "devDependencies": {
67
67
  "@axe-core/playwright": "^4.13.0",
68
68
  "@playwright/test": "^1.62.1",
69
- "@storybook/addon-a11y": "^10.5.8",
70
- "@storybook/addon-docs": "^10.5.8",
71
- "@storybook/addon-onboarding": "^10.5.8",
72
- "@storybook/react-vite": "^10.5.8",
69
+ "@storybook/addon-a11y": "^10.5.10",
70
+ "@storybook/addon-docs": "^10.5.10",
71
+ "@storybook/addon-onboarding": "^10.5.10",
72
+ "@storybook/react-vite": "^10.5.10",
73
73
  "@testing-library/jest-dom": "^7.0.1",
74
- "@testing-library/react": "^16.3.2",
74
+ "@testing-library/react": "^16.3.3",
75
75
  "@types/react": "^19.2.18",
76
- "@types/react-dom": "^19.2.4",
76
+ "@types/react-dom": "^19.2.5",
77
77
  "@whitespace/storybook-addon-html": "^9.0.0",
78
78
  "react": "^19.2.8",
79
79
  "react-dom": "^19.2.8",
80
80
  "resize-observer-polyfill": "^1.5.1",
81
81
  "serve": "^14.2.6",
82
- "storybook": "^10.5.8",
82
+ "storybook": "^10.5.10",
83
83
  "storybook-addon-tag-badges": "^3.1.0"
84
84
  },
85
85
  "peerDependencies": {
@@ -103,12 +103,12 @@
103
103
  "storybook": "$storybook"
104
104
  },
105
105
  "dependencies": {
106
- "@coopdigital/styles": "^1.13.2",
106
+ "@coopdigital/styles": "^1.15.0",
107
107
  "@radix-ui/react-popover": "^1.1.23",
108
108
  "clsx": "^2.1.1",
109
109
  "date-fns": "^4.4.0",
110
110
  "merge-refs": "^2.0.0",
111
111
  "react-day-picker": "^10.0.1"
112
112
  },
113
- "gitHead": "63e8cb1427d5e504b3390bb1c1028a30c76c9053"
113
+ "gitHead": "a54fd337dade28ed2d1e1f7d4d0e2cfeb7b90c9e"
114
114
  }
@@ -1,152 +1,153 @@
1
- import type { ForwardRefExoticComponent, HTMLAttributes, JSX, Ref } from "react"
1
+ import type {
2
+ AnchorHTMLAttributes,
3
+ ForwardRefExoticComponent,
4
+ HTMLAttributes,
5
+ JSX,
6
+ Ref,
7
+ } from "react"
2
8
 
3
9
  import clsx from "clsx"
4
10
  import React from "react"
5
11
 
6
- import { ChevronRightIcon } from "@/components/icons/ChevronRightIcon"
7
12
  import { Image, ImageProps } from "@/components/Image"
13
+ import Picture, { PictureProps } from "@/components/Picture"
8
14
  import { useSlots } from "@/hooks/useSlots"
15
+ import { StandardSizes } from "@/types"
9
16
  import { hasUserBg } from "@/utils"
10
17
 
11
18
  export interface CardProps extends HTMLAttributes<HTMLDivElement> {
12
- /** **(Optional)** Specify how the card behaves across screen sizes.
19
+ /** **(Optional)** Specify how the Card behaves across screen sizes.
13
20
  *
14
- * When this is true, horizontal cards will switch to vertical on small screens, and vertical cards will switch to horizontal on small screens.
21
+ * For finer control, use utility classes or custom CSS to control flex-direction. */
22
+ adaptive?: "sm" | "md"
23
+ /** **(Optional)** Specify an element to use for the container.
15
24
  *
16
- * Default: false
25
+ * Default: `article`
17
26
  */
18
- adaptive?: boolean
19
- /** **(Optional)** Specify whether chevron is visible. */
20
- chevron?: boolean
21
- /** **(Optional)** Content inside the component. Children that are not assigned to a slot will be grouped together and rendered under the main Card content. */
27
+ as?: "article" | "section" | "figure" | "div"
28
+ /** **(Optional)** Content inside the component. */
22
29
  children?: React.ReactNode
23
- /** **(Optional)** Specify additional CSS classes to be applied to the component. */
30
+ /** **(Optional)** Specify additional CSS classes. */
24
31
  className?: string
25
- /** **(Optional)** Specify the URL that the Card will link to. */
26
- href?: string
27
- /** **(Optional)** Specify a custom element to use instead of `a`. */
28
- // oxlint-disable-next-line typescript/no-explicit-any
29
- hrefAs?: React.FC<any> | ForwardRefExoticComponent<any> | string
30
- /** **(Optional)** Specify the orientation of the Card.
31
- *
32
- * Default: vertical
33
- */
32
+ /** **(Optional)** Specify the Card orientation. */
34
33
  orientation?: "vertical" | "horizontal"
34
+ /** **(Optional)** Specify the Card padding. */
35
+ padding?: StandardSizes
36
+ /** **(Optional)** Specify the Card border radius. */
37
+ radius?: StandardSizes
35
38
  /** **(Optional)** Specify a custom React ref for this component. */
36
39
  ref?: Ref<HTMLDivElement>
37
40
  /** **(Optional)** Enable additional styles to use the Card as a signpost.
38
41
  *
39
- * Text is vertically aligned centrally and the chevron is enlarged. */
42
+ * Text is vertically aligned centrally and the Icon is enlarged. */
40
43
  signpost?: boolean
41
44
  }
42
45
 
43
- interface CardLabelProps extends HTMLAttributes<HTMLSpanElement> {
44
- /** **(Optional)** Content inside the Label. */
46
+ interface CardHeadingProps extends HTMLAttributes<HTMLDivElement> {
47
+ /** **(Optional)** Specify an element to use for the heading.
48
+ *
49
+ * Default: `h3`
50
+ */
51
+ as?: "h2" | "h3" | "h4" | "h5" | "h6" | "p" | "span" | "div" | "strong" | "figcaption"
52
+ /** **(Optional)** Content inside the component. */
45
53
  children?: React.ReactNode
46
- /** **(Optional)** Specify additional CSS classes to be applied to the Label. */
54
+ /** **(Optional)** Specify additional CSS classes. */
47
55
  className?: string
48
56
  }
49
57
 
50
- interface CardHeadingProps extends HTMLAttributes<HTMLDivElement> {
51
- /** **(Optional)** Specify a custom element to use instead of `h3`. */
52
- as?: "h2" | "h3" | "h4" | "h5" | "h6" | "p" | "span" | "div"
53
- /** **(Optional)** Content inside the Heading. */
58
+ // interface CardBodyProps extends HTMLAttributes<HTMLDivElement> {
59
+ // /** **(Optional)** Content inside the Body. */
60
+ // children?: React.ReactNode
61
+ // }
62
+
63
+ interface CardIconProps extends HTMLAttributes<HTMLDivElement> {
64
+ /** **(Optional)** Content inside the component. */
54
65
  children?: React.ReactNode
55
- /** **(Optional)** Specify additional CSS classes to be applied to the Heading. */
66
+ /** **(Optional)** Specify additional CSS classes. */
56
67
  className?: string
57
68
  }
58
69
 
59
- interface CardBodyProps extends HTMLAttributes<HTMLDivElement> {
60
- /** **(Optional)** Content inside the Body. */
70
+ interface CardContentProps extends HTMLAttributes<HTMLDivElement> {
71
+ /** **(Optional)** Content inside the component. */
61
72
  children?: React.ReactNode
73
+ /** **(Optional)** Specify additional CSS classes. */
74
+ className?: string
75
+ }
76
+
77
+ interface CardLinkProps extends AnchorHTMLAttributes<HTMLAnchorElement> {
78
+ /** **(Optional)** Specify an element to use instead of native `a`. */
79
+ // oxlint-disable-next-line typescript/no-explicit-any
80
+ as?: React.FC<any> | ForwardRefExoticComponent<any> | string
81
+ /** **(Optional)** Content inside the component. */
82
+ children?: React.ReactNode
83
+ /** **(Optional)** Specify additional CSS classes. */
84
+ className?: string
62
85
  }
63
86
 
64
87
  interface CardBadgeProps extends HTMLAttributes<HTMLDivElement> {
65
- /** **(Optional)** Specify on which side the Badge should appear. */
88
+ /** **(Optional)** Specify alignment relative to container.
89
+ *
90
+ * Default: `right`
91
+ */
66
92
  align?: "left" | "right"
67
- /** **(Optional)** Content inside the Badge. */
93
+ /** **(Optional)** Content inside the component. */
68
94
  children?: React.ReactNode
69
- /** **(Optional)** Specify additional CSS classes to be applied to the Badge. */
95
+ /** **(Optional)** Specify additional CSS classes. */
70
96
  className?: string
71
- /** **(Optional)** Specify badge position relative to top right corner. */
97
+ /** **(Optional)** Specify position relative to top corner.
98
+ *
99
+ * Default: `popout`
100
+ */
72
101
  position?: "inset" | "popout"
73
102
  }
74
103
 
75
- type CardImageProps = ImageProps & {
76
- /** **(Optional)** Specify on which side the Image should appear. */
104
+ interface CardPictureProps extends PictureProps {
105
+ /** **(Optional)** Specify on which side the Picture should appear. */
77
106
  align?: "left" | "right"
107
+ /** **(Optional)** Content inside the component. */
108
+ children?: React.ReactNode
109
+ /** **(Optional)** Specify additional CSS classes. */
110
+ className?: string
78
111
  }
79
112
 
80
113
  const componentSlots = {
81
114
  CardBadge: null,
82
- CardBody: null,
83
- CardHeading: null,
84
- CardImage: null,
85
- CardLabel: null,
86
115
  Children: null,
87
116
  }
88
117
 
89
- function getCardLinkElement(as: CardProps["hrefAs"], href?: string) {
90
- return {
91
- element: as ?? "a",
92
- props: {
93
- className: "coop-card--link",
94
- href,
95
- },
96
- }
97
- }
98
-
99
118
  const Card = ({
100
119
  adaptive,
101
- chevron = false,
120
+ as = "article",
102
121
  children,
103
122
  className,
104
- href,
105
- hrefAs,
106
123
  orientation,
124
+ padding,
125
+ radius,
107
126
  ref,
108
127
  signpost,
109
128
  ...props
110
129
  }: CardProps): JSX.Element => {
111
- const { element: linkElement, props: linkProps } = getCardLinkElement(hrefAs, href)
112
-
113
130
  const slots = { ...useSlots(componentSlots, children) }
114
- const hasLinkWrapper = href && !slots.CardHeading
115
131
 
116
132
  const componentProps = {
117
133
  className: clsx("coop-card", !hasUserBg(className) && "bg-white", className),
118
134
  "data-adaptive": adaptive ?? undefined,
119
135
  "data-orientation": orientation ?? undefined,
136
+ "data-padding": padding ?? undefined,
137
+ "data-radius": radius ?? undefined,
120
138
  "data-signpost": signpost ?? undefined,
121
139
  ...props,
122
140
  }
123
141
 
124
- if (href && slots.CardHeading) {
125
- slots.CardHeading = React.createElement(linkElement, linkProps, slots.CardHeading)
126
- }
142
+ const cardContent = React.createElement(as, { ref, ...componentProps }, slots.Children)
127
143
 
128
- return (
129
- <article ref={ref} {...componentProps}>
130
- {slots.CardImage}
144
+ return slots.CardBadge ? (
145
+ <div className="coop-card-wrapper">
146
+ {cardContent}
131
147
  {slots.CardBadge}
132
- {React.createElement(
133
- hasLinkWrapper ? linkElement : "div",
134
- hasLinkWrapper
135
- ? { className: "coop-card--content", href }
136
- : { className: "coop-card--content" },
137
- <>
138
- {slots.CardLabel}
139
- {slots.CardHeading}
140
- {slots.CardBody}
141
- {slots.Children}
142
- </>
143
- )}
144
- {(chevron || signpost) && (
145
- <span aria-hidden="true" className="coop-card--icon" role="presentation">
146
- <ChevronRightIcon />
147
- </span>
148
- )}
149
- </article>
148
+ </div>
149
+ ) : (
150
+ cardContent
150
151
  )
151
152
  }
152
153
 
@@ -163,47 +164,92 @@ const CardHeading = ({
163
164
  )
164
165
  }
165
166
 
166
- const CardLabel = ({ children, className, ...props }: CardLabelProps): JSX.Element => {
167
- return (
168
- <span className={clsx("coop-card--label", className)} {...props}>
169
- {children}
170
- </span>
171
- )
167
+ const CardIcon = ({ children, className, ...props }: CardIconProps): JSX.Element => {
168
+ const componentProps = {
169
+ className: clsx("coop-card--icon", className),
170
+ ...props,
171
+ }
172
+ return <span {...componentProps}>{children}</span>
172
173
  }
173
174
 
174
175
  const CardBadge = ({
175
176
  align = "right",
176
177
  children,
178
+ className,
177
179
  position = "popout",
178
180
  ...props
179
181
  }: CardBadgeProps): JSX.Element => {
180
- return (
181
- <div className="coop-card--badge" data-align={align} data-position={position} {...props}>
182
- {children}
183
- </div>
184
- )
182
+ const componentProps = {
183
+ className: clsx("coop-card--badge", className),
184
+ "data-align": align,
185
+ "data-position": position,
186
+ ...props,
187
+ }
188
+ return <div {...componentProps}>{children}</div>
189
+ }
190
+
191
+ // const CardBody = ({ children }: CardBodyProps): JSX.Element => {
192
+ // return <>{children}</>
193
+ // }
194
+
195
+ const CardPicture = ({
196
+ align,
197
+ children,
198
+ className,
199
+ crop,
200
+ ...props
201
+ }: CardPictureProps): JSX.Element => {
202
+ const componentProps = {
203
+ className: clsx("coop-card--picture", className),
204
+ "data-align": align ?? undefined,
205
+ "data-crop": crop ?? "wide",
206
+ ...props,
207
+ }
208
+ return <Picture {...componentProps}>{children}</Picture>
185
209
  }
186
210
 
187
- const CardBody = ({ children }: CardBodyProps): JSX.Element => {
188
- return <>{children}</>
211
+ const CardImage = (props: ImageProps): JSX.Element => <Image {...props} />
212
+
213
+ const CardContent = ({ children, className, ...props }: CardContentProps): JSX.Element => {
214
+ const componentProps = {
215
+ className: clsx("coop-card--content", className),
216
+ ...props,
217
+ }
218
+ return <div {...componentProps}>{children}</div>
189
219
  }
190
220
 
191
- const CardImage = ({ align, crop, ...props }: CardImageProps): JSX.Element => {
192
- return <Image {...{ ...props, crop: crop ?? "wide", "data-align": align ?? undefined }} />
221
+ const CardLink = ({
222
+ as = "a",
223
+ children,
224
+ className,
225
+ href,
226
+ ...props
227
+ }: CardLinkProps): JSX.Element => {
228
+ return React.createElement(
229
+ as,
230
+ { className: clsx("coop-card--link", className), href, ...props },
231
+ children
232
+ )
193
233
  }
194
234
 
195
235
  Card.slot = { name: "Card" }
196
- CardLabel.slot = { name: "CardLabel" }
197
236
  CardHeading.slot = { name: "CardHeading" }
198
237
  CardBadge.slot = { name: "CardBadge" }
199
- CardBody.slot = { name: "CardBody" }
238
+ CardIcon.slot = { name: "CardIcon" }
239
+ CardContent.slot = { name: "CardContent" }
200
240
  CardImage.slot = { name: "CardImage" }
241
+ CardLink.slot = { name: "CardLink" }
242
+
243
+ CardPicture.slot = { name: "CardPicture" }
201
244
 
202
- Card.Label = CardLabel
245
+ Card.Link = CardLink
203
246
  Card.Heading = CardHeading
204
247
  Card.Badge = CardBadge
205
- Card.Body = CardBody
248
+ Card.Content = CardContent
249
+ Card.Icon = CardIcon
206
250
  Card.Image = CardImage
207
251
 
252
+ Card.Picture = CardPicture
253
+
208
254
  export default Card
209
- export { Card, CardBadge, CardBody, CardHeading, CardImage, CardLabel }
255
+ export { Card, CardBadge, CardContent, CardHeading, CardIcon, CardImage, CardLink, CardPicture }